diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index ada9a54..9f150c2 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -51,9 +51,11 @@ + + @@ -69,6 +71,7 @@ + diff --git a/Assets/IsoTools/Examples/Scenes/Scene07.unity b/Assets/IsoTools/Examples/Scenes/Scene07.unity index 2cc01a5..d96e290 100644 --- a/Assets/IsoTools/Examples/Scenes/Scene07.unity +++ b/Assets/IsoTools/Examples/Scenes/Scene07.unity @@ -102,7 +102,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalPosition.z - value: 1.4000001 + value: 1.5000001 objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalRotation.x @@ -281,10 +281,26 @@ Light: m_ShadowRadius: 0 m_ShadowAngle: 0 m_AreaSize: {x: 1, y: 1} ---- !u!1 &672353206 stripped +--- !u!1 &672353206 GameObject: + m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - m_PrefabInternal: {fileID: 1492170142} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 672353210} + - 212: {fileID: 672353209} + - 114: {fileID: 672353208} + - 114: {fileID: 672353211} + - 114: {fileID: 672353207} + - 114: {fileID: 672353212} + m_Layer: 0 + m_Name: Cube_1x1x1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!114 &672353207 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1228,7 +1244,7 @@ MonoBehaviour: watermark: password: locked: 0 - preprocessed: 0 + preprocessed: 1 ExposedEvents: [] RestartOnEnable: 1 EnableDebugFlow: 0 @@ -1246,6 +1262,95 @@ MonoBehaviour: handleApplicationEvents: 0 fsmTemplate: {fileID: 0} eventHandlerComponentsAdded: 0 +--- !u!114 &672353208 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 672353206} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a9c584f9a39449438abc7ba59a68778, type: 3} + m_Name: + m_EditorClassIdentifier: + _mode: 0 + _size: {x: 1, y: 1, z: 1} + _position: {x: 2, y: 2, z: 0} + _isAlignment: 1 + _isShowBounds: 0 +--- !u!212 &672353209 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 21217528, guid: c1b9b2ad3a021c549aa9190df3101248, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 672353206} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: dda1716486a64604ba1c99ad9655eeb2, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 +--- !u!4 &672353210 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 672353206} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.0000038146973, y: 31.999998, z: 1} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 +--- !u!114 &672353211 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 672353206} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b256250c588ee4e4590a3e58eaa69b1d, type: 3} + m_Name: + m_EditorClassIdentifier: + _material: {fileID: 0} + _isTrigger: 1 + _size: {x: 1, y: 1, z: 1} + _offset: {x: 0.5, y: 0.5, z: 0.5} +--- !u!114 &672353212 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 672353206} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3} + m_Name: + m_EditorClassIdentifier: + _isKinematic: 1 + _interpolation: 0 + _collisionDetectionMode: 0 --- !u!1001 &1364277118 Prefab: m_ObjectHideFlags: 0 @@ -1263,7 +1368,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalPosition.z - value: 1.3000001 + value: 1.4000001 objectReference: {fileID: 0} - target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} propertyPath: m_LocalRotation.x @@ -1358,64 +1463,375 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2} m_IsPrefabParent: 0 ---- !u!1001 &1492170142 -Prefab: +--- !u!1 &1708422616 +GameObject: m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.x - value: -0.0000038146973 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.y - value: 31.999998 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalPosition.z - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: m_RootOrder - value: 4 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _position.x - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _position.y - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _position.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - propertyPath: _mode - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} - m_IsPrefabParent: 0 + m_PrefabParentObject: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1708422620} + - 212: {fileID: 1708422619} + - 114: {fileID: 1708422618} + - 114: {fileID: 1708422617} + - 114: {fileID: 1708422622} + - 114: {fileID: 1708422621} + m_Layer: 0 + m_Name: Cube_1x1x1 (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1708422617 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1708422616} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b256250c588ee4e4590a3e58eaa69b1d, type: 3} + m_Name: + m_EditorClassIdentifier: + _material: {fileID: 0} + _isTrigger: 1 + _size: {x: 1, y: 1, z: 1} + _offset: {x: 0.5, y: 0.5, z: 0.5} +--- !u!114 &1708422618 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1708422616} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a9c584f9a39449438abc7ba59a68778, type: 3} + m_Name: + m_EditorClassIdentifier: + _mode: 0 + _size: {x: 1, y: 1, z: 1} + _position: {x: 4, y: 4, z: 0} + _isAlignment: 1 + _isShowBounds: 0 +--- !u!212 &1708422619 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 21217528, guid: c1b9b2ad3a021c549aa9190df3101248, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1708422616} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: dda1716486a64604ba1c99ad9655eeb2, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 +--- !u!4 &1708422620 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1708422616} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.0000076293945, y: 63.999996, z: 1.3000001} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 7 +--- !u!114 &1708422621 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1708422616} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1384774831, guid: de72a6d2da64d114d95e3c5a01cfaec5, type: 3} + m_Name: + m_EditorClassIdentifier: + fsm: + dataVersion: 2 + usedInTemplate: {fileID: 0} + name: FSM + startState: idle + states: + - name: idle + description: + colorIndex: 0 + position: + serializedVersion: 2 + x: 50 + y: 100 + width: 100 + height: 16 + isBreakpoint: 0 + isSequence: 0 + hideUnused: 0 + transitions: [] + actionData: + actionNames: + - IsoTools.PlayMaker.Actions.IsoTriggerEvent + customNames: + - + actionEnabled: 01 + actionIsOpen: 01 + actionStartIndex: 00000000 + actionHashCodes: 0e080104 + unityObjectParams: [] + fsmGameObjectParams: + - useVariable: 1 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: {fileID: 0} + fsmOwnerDefaultParams: + - ownerOption: 0 + gameObject: + useVariable: 0 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: {fileID: 0} + animationCurveParams: [] + functionCallParams: [] + fsmTemplateControlParams: [] + fsmEventTargetParams: [] + fsmPropertyParams: [] + layoutOptionParams: [] + fsmStringParams: + - useVariable: 0 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: Untagged + fsmObjectParams: [] + fsmVarParams: [] + fsmArrayParams: [] + fsmEnumParams: [] + fsmFloatParams: [] + fsmIntParams: [] + fsmBoolParams: [] + fsmVector2Params: [] + fsmVector3Params: [] + fsmColorParams: [] + fsmRectParams: [] + fsmQuaternionParams: [] + stringParams: + - TO_UP + byteData: 00000000 + arrayParamSizes: + arrayParamTypes: [] + customTypeSizes: + customTypeNames: [] + paramDataType: 1400000007000000120000001700000013000000 + paramName: + - gameObject + - triggerType + - collideTag + - sendEvent + - storeIsoCollider + paramDataPos: 0000000000000000000000000000000000000000 + paramByteDataSize: 0000000004000000000000000000000000000000 + - name: up + description: + colorIndex: 0 + position: + serializedVersion: 2 + x: 390 + y: 146 + width: 100 + height: 32 + isBreakpoint: 0 + isSequence: 0 + hideUnused: 0 + transitions: + - fsmEvent: + name: FINISHED + isSystemEvent: 1 + isGlobal: 0 + toState: idle + linkStyle: 0 + linkConstraint: 0 + colorIndex: 0 + actionData: + actionNames: + - IsoTools.PlayMaker.Actions.IsoTranslate + customNames: + - + actionEnabled: 01 + actionIsOpen: 01 + actionStartIndex: 00000000 + actionHashCodes: 8ef87600 + unityObjectParams: [] + fsmGameObjectParams: [] + fsmOwnerDefaultParams: + - ownerOption: 0 + gameObject: + useVariable: 0 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: {fileID: 0} + animationCurveParams: [] + functionCallParams: [] + fsmTemplateControlParams: [] + fsmEventTargetParams: [] + fsmPropertyParams: [] + layoutOptionParams: [] + fsmStringParams: [] + fsmObjectParams: [] + fsmVarParams: [] + fsmArrayParams: [] + fsmEnumParams: [] + fsmFloatParams: + - useVariable: 1 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: 0 + - useVariable: 1 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: 0 + - useVariable: 0 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: 0.2 + fsmIntParams: [] + fsmBoolParams: [] + fsmVector2Params: [] + fsmVector3Params: + - useVariable: 1 + name: + tooltip: + showInInspector: 0 + networkSync: 0 + value: {x: 0, y: 0, z: 0} + fsmColorParams: [] + fsmRectParams: [] + fsmQuaternionParams: [] + stringParams: [] + byteData: 00000000 + arrayParamSizes: + arrayParamTypes: [] + customTypeSizes: + customTypeNames: [] + paramDataType: 140000001c0000000f0000000f0000000f00000001000000010000000100000001000000 + paramName: + - gameObject + - vector + - x + - y + - z + - perSecond + - everyFrame + - lateUpdate + - fixedUpdate + paramDataPos: 000000000000000000000000010000000200000000000000010000000200000003000000 + paramByteDataSize: 000000000000000000000000000000000000000001000000010000000100000001000000 + events: + - name: FINISHED + isSystemEvent: 1 + isGlobal: 0 + - name: TO_UP + isSystemEvent: 0 + isGlobal: 0 + globalTransitions: + - fsmEvent: + name: TO_UP + isSystemEvent: 0 + isGlobal: 0 + toState: up + linkStyle: 0 + linkConstraint: 0 + colorIndex: 0 + variables: + floatVariables: [] + intVariables: [] + boolVariables: [] + stringVariables: [] + vector2Variables: [] + vector3Variables: [] + colorVariables: [] + rectVariables: [] + quaternionVariables: [] + gameObjectVariables: [] + objectVariables: [] + materialVariables: [] + textureVariables: [] + arrayVariables: [] + enumVariables: [] + categories: + - + variableCategoryIDs: + description: + docUrl: + showStateLabel: 1 + maxLoopCount: 0 + watermark: + password: + locked: 0 + preprocessed: 1 + ExposedEvents: [] + RestartOnEnable: 1 + EnableDebugFlow: 0 + EnableBreakpoints: 1 + activeStateName: + mouseEvents: 0 + handleTriggerEnter: 0 + handleTriggerExit: 0 + handleTriggerStay: 0 + handleCollisionEnter: 0 + handleCollisionExit: 0 + handleCollisionStay: 0 + handleOnGUI: 0 + handleFixedUpdate: 1 + handleApplicationEvents: 0 + fsmTemplate: {fileID: 0} + eventHandlerComponentsAdded: 0 +--- !u!114 &1708422622 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1708422616} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3} + m_Name: + m_EditorClassIdentifier: + _isKinematic: 1 + _interpolation: 0 + _collisionDetectionMode: 0 --- !u!1 &1761473855 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoCollisionEvent.cs b/Assets/IsoTools/PlayMaker/Actions/IsoCollisionEvent.cs new file mode 100644 index 0000000..ceb4b0b --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoCollisionEvent.cs @@ -0,0 +1,90 @@ +using UnityEngine; +using HutongGames.PlayMaker; + +namespace IsoTools.PlayMaker.Actions { + public enum IsoCollisionType { + IsoCollisionEnter, + IsoCollisionExit + } + [ActionCategory("IsoTools")] + [HutongGames.PlayMaker.Tooltip( + "Detect physics collision events.")] + public class IsoCollisionEvent : IsoComponentAction { + [RequiredField] + [CheckForComponent(typeof(IsoObject))] + [HutongGames.PlayMaker.Title("IsoObject (In)")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [HutongGames.PlayMaker.Title("Collision Type (In)")] + public IsoCollisionType collisionType; + + [RequiredField] + [UIHint(UIHint.Tag)] + [HutongGames.PlayMaker.Title("Collide Tag (In)")] + public FsmString collideTag; + + [HutongGames.PlayMaker.Title("Send Event (In)")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [HutongGames.PlayMaker.Title("Store Iso Collider (Out)")] + public FsmGameObject storeIsoCollider; + + [UIHint(UIHint.Variable)] + [HutongGames.PlayMaker.Title("Store Force (Out)")] + public FsmFloat storeForce; + + IsoFSMEvents isoFSMEvents = null; + + public override void Reset() { + gameObject = null; + collisionType = IsoCollisionType.IsoCollisionEnter; + collideTag = "Untagged"; + sendEvent = null; + storeIsoCollider = null; + storeForce = null; + } + + public override void OnEnter() { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if ( go ) { + isoFSMEvents = go.AddComponent(); + isoFSMEvents.Init(this); + } + } + + public override void OnExit() { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if ( go ) { + if ( isoFSMEvents ) { + GameObject.Destroy(isoFSMEvents); + isoFSMEvents = null; + } + } + } + + public override void DoIsoCollisionEnter(IsoCollision collision) { + if ( collisionType == IsoCollisionType.IsoCollisionEnter ) { + DoAction(collision); + } + } + + public override void DoIsoCollisionExit(IsoCollision collision) { + if ( collisionType == IsoCollisionType.IsoCollisionExit ) { + DoAction(collision); + } + } + + void DoAction(IsoCollision collision) { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if ( UpdateCache(go) ) { + if ( collision.collider.gameObject.tag == collideTag.Value ) { + storeIsoCollider.Value = collision.collider.gameObject; + storeForce.Value = collision.relativeVelocity.magnitude; + Fsm.Event(sendEvent); + } + } + } + } +} // IsoTools.PlayMaker.Actions \ No newline at end of file diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoCollisionEvent.cs.meta b/Assets/IsoTools/PlayMaker/Actions/IsoCollisionEvent.cs.meta new file mode 100644 index 0000000..255ff6d --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoCollisionEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7174ef4b510b84720b2155b405a8bd7d +timeCreated: 1450293230 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoComponentAction.cs b/Assets/IsoTools/PlayMaker/Actions/IsoComponentAction.cs index 056cf48..4eed628 100644 --- a/Assets/IsoTools/PlayMaker/Actions/IsoComponentAction.cs +++ b/Assets/IsoTools/PlayMaker/Actions/IsoComponentAction.cs @@ -6,6 +6,12 @@ namespace IsoTools.PlayMaker.Actions { T _cachedComponent; GameObject _cachedGameObject; + public virtual void DoIsoTriggerEnter(IsoCollider collider) {} + public virtual void DoIsoTriggerExit (IsoCollider collider) {} + + public virtual void DoIsoCollisionEnter(IsoCollision collision) {} + public virtual void DoIsoCollisionExit (IsoCollision collision) {} + protected IsoWorld isoWorld { get { return _cachedComponent as IsoWorld; } } diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoFSMEvents.cs b/Assets/IsoTools/PlayMaker/Actions/IsoFSMEvents.cs new file mode 100644 index 0000000..ba4f911 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoFSMEvents.cs @@ -0,0 +1,42 @@ +using UnityEngine; +using HutongGames.PlayMaker; + +namespace IsoTools.PlayMaker.Actions { + public class IsoFSMEvents : MonoBehaviour { + IsoComponentAction _action = null; + bool _started = false; + + public void Init(IsoComponentAction action) { + _action = action; + } + + void Start() { + Debug.Assert(_action != null, this); + _started = true; + } + + void OnIsoTriggerEnter(IsoCollider collider) { + if ( _action != null && _started ) { + _action.DoIsoTriggerEnter(collider); + } + } + + void OnIsoTriggerExit(IsoCollider collider) { + if ( _action != null && _started ) { + _action.DoIsoTriggerExit(collider); + } + } + + void OnIsoCollisionEnter(IsoCollision collision) { + if ( _action != null && _started ) { + _action.DoIsoCollisionEnter(collision); + } + } + + void OnIsoCollisionExit(IsoCollision collision) { + if ( _action != null && _started ) { + _action.DoIsoCollisionExit(collision); + } + } + } +} \ No newline at end of file diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoFSMEvents.cs.meta b/Assets/IsoTools/PlayMaker/Actions/IsoFSMEvents.cs.meta new file mode 100644 index 0000000..e42ac81 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoFSMEvents.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 31abbce806315444e9a6cf895d9f625e +timeCreated: 1450292724 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoTriggerEvent.cs b/Assets/IsoTools/PlayMaker/Actions/IsoTriggerEvent.cs new file mode 100644 index 0000000..d0c4349 --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoTriggerEvent.cs @@ -0,0 +1,84 @@ +using UnityEngine; +using HutongGames.PlayMaker; + +namespace IsoTools.PlayMaker.Actions { + public enum IsoTriggerType { + IsoTriggerEnter, + IsoTriggerExit + } + [ActionCategory("IsoTools")] + [HutongGames.PlayMaker.Tooltip( + "Detect physics trigger events.")] + public class IsoTriggerEvent : IsoComponentAction { + [RequiredField] + [CheckForComponent(typeof(IsoObject))] + [HutongGames.PlayMaker.Title("IsoObject (In)")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [HutongGames.PlayMaker.Title("Trigger Type (In)")] + public IsoTriggerType triggerType; + + [RequiredField] + [UIHint(UIHint.Tag)] + [HutongGames.PlayMaker.Title("Collide Tag (In)")] + public FsmString collideTag; + + [HutongGames.PlayMaker.Title("Send Event (In)")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [HutongGames.PlayMaker.Title("Store Iso Collider (Out)")] + public FsmGameObject storeIsoCollider; + + IsoFSMEvents isoFSMEvents = null; + + public override void Reset() { + gameObject = null; + triggerType = IsoTriggerType.IsoTriggerEnter; + collideTag = "Untagged"; + sendEvent = null; + storeIsoCollider = null; + } + + public override void OnEnter() { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if ( go ) { + isoFSMEvents = go.AddComponent(); + isoFSMEvents.Init(this); + } + } + + public override void OnExit() { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if ( go ) { + if ( isoFSMEvents ) { + GameObject.Destroy(isoFSMEvents); + isoFSMEvents = null; + } + } + } + + public override void DoIsoTriggerEnter(IsoCollider collider) { + if ( triggerType == IsoTriggerType.IsoTriggerEnter ) { + DoAction(collider); + } + } + + public override void DoIsoTriggerExit(IsoCollider collider) { + if ( triggerType == IsoTriggerType.IsoTriggerExit ) { + DoAction(collider); + } + } + + void DoAction(IsoCollider collider) { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if ( UpdateCache(go) ) { + if ( collider.gameObject.tag == collideTag.Value ) { + storeIsoCollider.Value = collider.gameObject; + Fsm.Event(sendEvent); + } + } + } + } +} // IsoTools.PlayMaker.Actions \ No newline at end of file diff --git a/Assets/IsoTools/PlayMaker/Actions/IsoTriggerEvent.cs.meta b/Assets/IsoTools/PlayMaker/Actions/IsoTriggerEvent.cs.meta new file mode 100644 index 0000000..35debee --- /dev/null +++ b/Assets/IsoTools/PlayMaker/Actions/IsoTriggerEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 626aa5f53a36f4d7c8c392e4cb7e0beb +timeCreated: 1450293242 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: