diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 1b30dbc..08f36cf 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -52,8 +52,10 @@ + + diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoGetSize.cs b/Assets/IsoTools/PlayMaker/Actions/IsoGetSize.cs new file mode 100644 index 0000000..009d073 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoGetSize.cs @@ -0,0 +1,57 @@ +using UnityEngine; +using HutongGames.PlayMaker; + +namespace IsoTools.PlayMaker.Actions { + [ActionCategory("IsoTools")] + [HutongGames.PlayMaker.Tooltip("Gets the Size of a IsoObject and stores it in a Vector3 Variable or each Axis in a Float Variable")] + public class IsoGetSize : FsmStateAction { + [RequiredField] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + + [UIHint(UIHint.Variable)] + public FsmFloat x; + + [UIHint(UIHint.Variable)] + public FsmFloat y; + + [UIHint(UIHint.Variable)] + public FsmFloat z; + + public bool everyFrame; + + public override void Reset() { + gameObject = null; + vector = null; + x = null; + y = null; + z = null; + everyFrame = false; + } + + public override void OnEnter() { + DoGetSize(); + if ( !everyFrame ) { + Finish(); + } + } + + public override void OnUpdate() { + DoGetSize(); + } + + void DoGetSize() { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + var iso_object = go ? go.GetComponent() : null; + if ( iso_object ) { + var size = iso_object.size; + vector.Value = size; + x.Value = size.x; + y.Value = size.y; + z.Value = size.z; + } + } + } +} // IsoTools.PlayMaker.Actions \ No newline at end of file diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoGetSize.cs.meta b/Assets/IsoTools/PlayMaker/Actions/IsoGetSize.cs.meta new file mode 100644 index 0000000..763dd15 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoGetSize.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 786db15115e7f4363b18ae4aadcf2e3b +timeCreated: 1450014652 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoSetPosition.cs b/Assets/IsoTools/PlayMaker/Actions/IsoSetPosition.cs index 86953c4..cd201b5 100644 --- a/Assets/IsoTools/PlayMaker/Actions/IsoSetPosition.cs +++ b/Assets/IsoTools/PlayMaker/Actions/IsoSetPosition.cs @@ -6,21 +6,16 @@ namespace IsoTools.PlayMaker.Actions { [HutongGames.PlayMaker.Tooltip("Sets the Position of a IsoObject. To leave any axis unchanged, set variable to 'None'.")] public class IsoSetPosition : FsmStateAction { [RequiredField] - [HutongGames.PlayMaker.Tooltip("The GameObject to position.")] public FsmOwnerDefault gameObject; [UIHint(UIHint.Variable)] - [HutongGames.PlayMaker.Tooltip("Use a stored Vector3 position, and/or set individual axis below.")] public FsmVector3 vector; public FsmFloat x; public FsmFloat y; public FsmFloat z; - [HutongGames.PlayMaker.Tooltip("Repeat every frame.")] public bool everyFrame; - - [HutongGames.PlayMaker.Tooltip("Perform in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] public bool lateUpdate; public override void Reset() { diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoSetSize.cs b/Assets/IsoTools/PlayMaker/Actions/IsoSetSize.cs new file mode 100644 index 0000000..00acef8 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoSetSize.cs @@ -0,0 +1,75 @@ +using UnityEngine; +using HutongGames.PlayMaker; + +namespace IsoTools.PlayMaker.Actions { + [ActionCategory("IsoTools")] + [HutongGames.PlayMaker.Tooltip("Sets the Size of a IsoObject. To leave any axis unchanged, set variable to 'None'.")] + public class IsoSetSize : FsmStateAction { + [RequiredField] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + + public bool everyFrame; + public bool lateUpdate; + + public override void Reset() { + gameObject = null; + vector = null; + x = new FsmFloat{UseVariable = true}; + y = new FsmFloat{UseVariable = true}; + z = new FsmFloat{UseVariable = true}; + everyFrame = false; + lateUpdate = false; + } + + public override void OnEnter() { + if ( !everyFrame && !lateUpdate ) { + DoSetSize(); + Finish(); + } + } + + public override void OnUpdate() { + if ( !lateUpdate ) { + DoSetSize(); + } + } + + public override void OnLateUpdate() { + if ( lateUpdate ) { + DoSetSize(); + } + if ( !everyFrame ) { + Finish(); + } + } + + void DoSetSize() { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + var iso_object = go ? go.GetComponent() : null; + if ( iso_object ) { + var size = vector.IsNone + ? iso_object.size + : vector.Value; + + if ( !x.IsNone ) { + size.x = x.Value; + } + if ( !y.IsNone ) { + size.y = y.Value; + } + if ( !z.IsNone ) { + size.z = z.Value; + } + + iso_object.size = size; + } + } + } +} // IsoTools.PlayMaker.Actions \ No newline at end of file diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoSetSize.cs.meta b/Assets/IsoTools/PlayMaker/Actions/IsoSetSize.cs.meta new file mode 100644 index 0000000..a29d1e0 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoSetSize.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9692e258041de4188a3b9b796750b7a0 +timeCreated: 1450014664 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoSetTilePosition.cs b/Assets/IsoTools/PlayMaker/Actions/IsoSetTilePosition.cs index 357de0a..07876e6 100644 --- a/Assets/IsoTools/PlayMaker/Actions/IsoSetTilePosition.cs +++ b/Assets/IsoTools/PlayMaker/Actions/IsoSetTilePosition.cs @@ -6,21 +6,16 @@ namespace IsoTools.PlayMaker.Actions { [HutongGames.PlayMaker.Tooltip("Sets the TilePosition of a IsoObject. To leave any axis unchanged, set variable to 'None'.")] public class IsoSetTilePosition : FsmStateAction { [RequiredField] - [HutongGames.PlayMaker.Tooltip("The GameObject to position.")] public FsmOwnerDefault gameObject; [UIHint(UIHint.Variable)] - [HutongGames.PlayMaker.Tooltip("Use a stored Vector3 position, and/or set individual axis below.")] public FsmVector3 vector; public FsmFloat x; public FsmFloat y; public FsmFloat z; - [HutongGames.PlayMaker.Tooltip("Repeat every frame.")] public bool everyFrame; - - [HutongGames.PlayMaker.Tooltip("Perform in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] public bool lateUpdate; public override void Reset() { @@ -35,45 +30,45 @@ namespace IsoTools.PlayMaker.Actions { public override void OnEnter() { if ( !everyFrame && !lateUpdate ) { - DoSetPosition(); + DoSetTilePosition(); Finish(); } } public override void OnUpdate() { if ( !lateUpdate ) { - DoSetPosition(); + DoSetTilePosition(); } } public override void OnLateUpdate() { if ( lateUpdate ) { - DoSetPosition(); + DoSetTilePosition(); } if ( !everyFrame ) { Finish(); } } - void DoSetPosition() { + void DoSetTilePosition() { var go = Fsm.GetOwnerDefaultTarget(gameObject); var iso_object = go ? go.GetComponent() : null; if ( iso_object ) { - var position = vector.IsNone + var tile_position = vector.IsNone ? iso_object.tilePosition : vector.Value; if ( !x.IsNone ) { - position.x = x.Value; + tile_position.x = x.Value; } if ( !y.IsNone ) { - position.y = y.Value; + tile_position.y = y.Value; } if ( !z.IsNone ) { - position.z = z.Value; + tile_position.z = z.Value; } - iso_object.tilePosition = position; + iso_object.tilePosition = tile_position; } } } diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoTranslate.cs b/Assets/IsoTools/PlayMaker/Actions/IsoTranslate.cs index fb324f9..e1cae18 100644 --- a/Assets/IsoTools/PlayMaker/Actions/IsoTranslate.cs +++ b/Assets/IsoTools/PlayMaker/Actions/IsoTranslate.cs @@ -6,32 +6,18 @@ namespace IsoTools.PlayMaker.Actions { [HutongGames.PlayMaker.Tooltip("Translates a IsoObject. Use a Vector3 variable and/or XYZ components. To leave any axis unchanged, set variable to 'None'.")] public class IsoTranslate : FsmStateAction { [RequiredField] - [HutongGames.PlayMaker.Tooltip("The game object to translate.")] public FsmOwnerDefault gameObject; [UIHint(UIHint.Variable)] - [HutongGames.PlayMaker.Tooltip("A translation vector. NOTE: You can override individual axis below.")] public FsmVector3 vector; - [HutongGames.PlayMaker.Tooltip("Translation along x axis.")] public FsmFloat x; - - [HutongGames.PlayMaker.Tooltip("Translation along y axis.")] public FsmFloat y; - - [HutongGames.PlayMaker.Tooltip("Translation along z axis.")] public FsmFloat z; - [HutongGames.PlayMaker.Tooltip("Translate over one second")] public bool perSecond; - - [HutongGames.PlayMaker.Tooltip("Repeat every frame.")] public bool everyFrame; - - [HutongGames.PlayMaker.Tooltip("Perform the translate in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] public bool lateUpdate; - - [HutongGames.PlayMaker.Tooltip("Perform the translate in FixedUpdate. This is useful when working with rigid bodies and physics.")] public bool fixedUpdate; public override void Reset() {