Skip to content

Commit

Permalink
#116 Fixed 'Movable' trait in World Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
willneedit committed Jun 25, 2024
1 parent 876a0b9 commit ba92697
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Assets/Arteranos/Scenes/ScratchPad.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4a6bec223e9b1cc4d8ddf3f3b4f6d7d0, type: 3}
m_Name:
m_EditorClassIdentifier:
IsInEditMode: 0
LockXAxis: 1
LockYAxis: 1
LockZAxis: 1
LockXAxis: 0
LockYAxis: 0
LockZAxis: 0
isInEditMode: 1
--- !u!114 &6642253553766238805
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
16 changes: 15 additions & 1 deletion Assets/Arteranos/WorldEdit/Base/WorldEditorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,32 @@ namespace Arteranos.WorldEdit
public class WorldEditorData : MonoBehaviour
{
// Are we in the edit mode at all?
public bool IsInEditMode = false;
public bool IsInEditMode
{
get => isInEditMode;
set
{
bool old = isInEditMode;
isInEditMode = value;
if (old != value) NotifyEditorModeChanged();
}
}

// Movement and rotation constraints
public bool LockXAxis = false;
public bool LockYAxis = false;
public bool LockZAxis = false;
public bool isInEditMode = false;

public event Action<WorldChange> OnWorldChanged;
public event Action<bool> OnEditorModeChanged;

public void NotifyWorldChanged(WorldChange worldChange)
=> OnWorldChanged?.Invoke(worldChange);

public void NotifyEditorModeChanged()
=> OnEditorModeChanged?.Invoke(IsInEditMode);

public void DoApply(WorldChange worldChange)
{
IEnumerator Cor()
Expand Down
4 changes: 3 additions & 1 deletion Assets/Arteranos/WorldEdit/Base/WorldObjectComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ public void CommitStates()

private void SetIsMovable()
{
mover.enabled = !IsLocked;
mover.enabled = EditorData.IsInEditMode
? !IsLocked
: IsGrabbable;
}

public WorldObjectPatch MakePatch(bool complete = false)
Expand Down

0 comments on commit ba92697

Please sign in to comment.