Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy/Paste Item Location in addition to Rotation #759

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ValheimPlus/AdvancedBuildingMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ABM

// Save and Load object rotation
static Quaternion savedRotation;
private static Vector3 savedPosition;

public static void Run(ref Player __instance)
{
Expand Down Expand Up @@ -135,13 +136,27 @@ private static void listenToHotKeysAndDoWork()

changeModificationSpeed();

// Copying/Pasting
if (Input.GetKeyUp(Configuration.Current.AdvancedBuildingMode.copyObjectRotation))
{
savedRotation = component.transform.rotation;
notifyUser("Copied Rotation");
}
if (Input.GetKeyUp(Configuration.Current.AdvancedBuildingMode.pasteObjectRotation))
{
component.transform.rotation = savedRotation;
notifyUser("Pasted Rotation");
}
if (Input.GetKeyUp(Configuration.Current.AdvancedBuildingMode.copyObjectRotationAndPosition))
{
savedRotation = component.transform.rotation;
savedPosition = component.transform.position;
notifyUser("Copied Rotation and Position");
}
if (Input.GetKeyUp(Configuration.Current.AdvancedBuildingMode.pasteObjectRotationAndPosition))
{
component.transform.SetPositionAndRotation(savedPosition, savedRotation);
notifyUser("Pasted Rotation and Position");
}

var currentRotationAngleDegrees = BASE_ROTATION_ANGLE_DEGREES * currentModificationSpeed;
Expand Down
14 changes: 14 additions & 0 deletions ValheimPlus/AdvancedEditingMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AEM

// Save and Load object rotation
static Quaternion savedRotation;
private static Vector3 savedPosition;

// Executing the raycast to find the object
public static bool ExecuteRayCast(Player playerInstance)
Expand Down Expand Up @@ -234,10 +235,23 @@ private static void listenToHotKeysAndDoWork()
if (Input.GetKeyUp(Configuration.Current.AdvancedEditingMode.copyObjectRotation))
{
savedRotation = HitPiece.transform.rotation;
notifyUser("Copied Rotation");
}
if (Input.GetKeyUp(Configuration.Current.AdvancedEditingMode.pasteObjectRotation))
{
HitPiece.transform.rotation = savedRotation;
notifyUser("Pasted Rotation");
}
if (Input.GetKeyUp(Configuration.Current.AdvancedEditingMode.copyObjectRotationAndPosition))
{
savedRotation = HitPiece.transform.rotation;
savedPosition = HitPiece.transform.position;
notifyUser("Copied Rotation and Position");
}
if (Input.GetKeyUp(Configuration.Current.AdvancedEditingMode.pasteObjectRotationAndPosition))
{
HitPiece.transform.SetPositionAndRotation(savedPosition, savedRotation);
notifyUser("Pasted Rotation and Position");
}

// Maximum distance between player and placed piece
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class AdvancedBuildingModeConfiguration : BaseConfig<AdvancedBuildingMode

public KeyCode copyObjectRotation { get; internal set; } = KeyCode.Keypad7;
public KeyCode pasteObjectRotation { get; internal set; } = KeyCode.Keypad8;
public KeyCode copyObjectRotationAndPosition { get; internal set; } = KeyCode.Keypad4;
public KeyCode pasteObjectRotationAndPosition { get; internal set; } = KeyCode.Keypad5;

public KeyCode increaseScrollSpeed { get; internal set; } = KeyCode.KeypadPlus;
public KeyCode decreaseScrollSpeed { get; internal set; } = KeyCode.KeypadMinus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ public class AdvancedEditingModeConfiguration : BaseConfig<AdvancedEditingModeCo
public KeyCode resetAdvancedEditingMode { get; internal set; } = KeyCode.F7;
public KeyCode abortAndExitAdvancedEditingMode { get; internal set; } = KeyCode.F8;
public KeyCode confirmPlacementOfAdvancedEditingMode { get; internal set; } = KeyCode.KeypadEnter;

public KeyCode copyObjectRotation { get; internal set; } = KeyCode.Keypad7;
public KeyCode pasteObjectRotation { get; internal set; } = KeyCode.Keypad8;
public KeyCode copyObjectRotationAndPosition { get; internal set; } = KeyCode.Keypad4;
public KeyCode pasteObjectRotationAndPosition { get; internal set; } = KeyCode.Keypad5;

public KeyCode increaseScrollSpeed { get; internal set; } = KeyCode.KeypadPlus;
public KeyCode decreaseScrollSpeed { get; internal set; } = KeyCode.KeypadMinus;
Expand Down
12 changes: 12 additions & 0 deletions valheim_plus.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ copyObjectRotation=Keypad7
; Apply the copied object rotation to the currently selected object in ABM
pasteObjectRotation=Keypad8

; Copy the object rotation and position of the currently selected object in ABM
copyObjectRotationAndPosition=Keypad4

; Apply the copied object rotation and position to the currently selected object in ABM
pasteObjectRotationAndPosition=Keypad5

; Increases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.
increaseScrollSpeed=KeypadPlus

Expand Down Expand Up @@ -57,6 +63,12 @@ copyObjectRotation=Keypad7
; Apply the copied object rotation to the currently selected object in AEM
pasteObjectRotation=Keypad8

; Copy the object rotation and position of the currently selected object in ABM
copyObjectRotationAndPosition=Keypad4

; Apply the copied object rotation and position to the currently selected object in ABM
pasteObjectRotationAndPosition=Keypad5

; Increases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.
increaseScrollSpeed=KeypadPlus

Expand Down
21 changes: 21 additions & 0 deletions vplusconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@
"defaultValue": "Keypad8",
"defaultType": "KeyCode"
},

"copyObjectRotationAndPosition": {
"description": "Copy the object rotation and position of the currently selected object in ABM",
"defaultValue": "Keypad4",
"defaultType": "KeyCode"
},
"pasteObjectRotationAndPosition": {
"description": "Apply the copied object rotation and position to the currently selected object in ABM",
"defaultValue": "Keypad5",
"defaultType": "KeyCode"
},
"increaseScrollSpeed": {
"description": "Increases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.",
"defaultValue": "KeypadPlus",
Expand Down Expand Up @@ -98,6 +109,16 @@
"defaultValue": "Keypad8",
"defaultType": "KeyCode"
},
"copyObjectRotationAndPosition": {
"description": "Copy the object rotation and position of the currently selected object in AEM",
"defaultValue": "Keypad4",
"defaultType": "KeyCode"
},
"pasteObjectRotationAndPosition": {
"description": "Apply the copied object rotation and position to the currently selected object in AEM",
"defaultValue": "Keypad5",
"defaultType": "KeyCode"
},
"increaseScrollSpeed": {
"description": "Increases the amount an object rotates and moves. Holding Shift will increase in increments of 10 instead of 1.",
"defaultValue": "KeypadPlus",
Expand Down