diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental.meta new file mode 100644 index 00000000..03005b34 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 597aa59f12d39f64ca7cdea69c411e01 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine.meta new file mode 100644 index 00000000..8a9f9cd3 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9780d9045dcee404c99afe7c3dbeaafc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art.meta new file mode 100644 index 00000000..22df1073 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5186dfe4deea404aa096dcadc808d91 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials.meta new file mode 100644 index 00000000..a0c7df46 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8642e137fd429da4bb1bc9d7fe02fefe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials/Player.mat b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials/Player.mat new file mode 100644 index 00000000..b89e9027 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials/Player.mat @@ -0,0 +1,133 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 32 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Player + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _AlphaToMask: 0 + - _Blend: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _DstBlendAlpha: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 0.9882353, g: 1, b: 0.29411766, a: 1} + - _Color: {r: 0.9882353, g: 1, b: 0.29411763, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] +--- !u!114 &4273482156878478107 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 7 diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials/Player.mat.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials/Player.mat.meta new file mode 100644 index 00000000..0b6a761e --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Art/Materials/Player.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3a2d60913cf4bc942a9cf1f67623d1a9 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes.meta new file mode 100644 index 00000000..fe79e9b9 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 239bc3e07bb6cf24f8edbaf508871891 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/StateMachine.unity b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/StateMachine.unity new file mode 100644 index 00000000..25a9f2a7 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/StateMachine.unity @@ -0,0 +1,296 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1001 &542156272 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3122259494672607327, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_Name + value: Common + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalPosition.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5183454963766305521, guid: 4f7249f35d9553d4491ca18ff93478a3, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 4f7249f35d9553d4491ca18ff93478a3, type: 3} +--- !u!1 &1386482408 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1386482410} + - component: {fileID: 1386482409} + m_Layer: 0 + m_Name: SpinningCube_Version02_DOTSasdf + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1386482409 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1386482408} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 45a335734b1572644a6a5d09d87adc65, type: 3} + m_Name: + m_EditorClassIdentifier: + _SceneAsset: {fileID: 102900000, guid: 85f02b9a3c60b91408e976145814a961, type: 3} + _HierarchyColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + AutoLoadScene: 1 + _SceneGUID: + Value: + x: 2847018840 + y: 1100678851 + z: 1097309824 + w: 379208069 +--- !u!4 &1386482410 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1386482408} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1814342439 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1814342444} + - component: {fileID: 1814342445} + m_Layer: 0 + m_Name: StateMachine + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1814342444 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1814342439} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1814342445 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1814342439} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 672c51cd61b685542920a0588a0b3f54, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 542156272} + - {fileID: 1814342444} + - {fileID: 1386482410} diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/StateMachine.unity.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/StateMachine.unity.meta new file mode 100644 index 00000000..b04ee566 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/StateMachine.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f8fe08f11badfec4ea50aab3356e7260 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes.meta new file mode 100644 index 00000000..e3e9fb1d --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e8f1edabc4ef6e64783194be3ead01fd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes/StateMachine_SubScene.unity b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes/StateMachine_SubScene.unity new file mode 100644 index 00000000..cddae501 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes/StateMachine_SubScene.unity @@ -0,0 +1,317 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &58781224 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 58781228} + - component: {fileID: 58781227} + - component: {fileID: 58781226} + - component: {fileID: 58781229} + m_Layer: 0 + m_Name: StateMachineTest + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &58781226 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 58781224} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 3a2d60913cf4bc942a9cf1f67623d1a9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &58781227 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 58781224} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &58781228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 58781224} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &58781229 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 58781224} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 716abc68a53a4ad6827ad9949b52b883, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &954058987 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 954058989} + - component: {fileID: 954058988} + m_Layer: 0 + m_Name: ---------- Systems ----------- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &954058988 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 954058987} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e4bd367752a957644a1419fad5d66606, type: 3} + m_Name: + m_EditorClassIdentifier: + DividerType: 2 +--- !u!4 &954058989 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 954058987} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 11.32872, y: 8.170444, z: 1.3793705} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1749204824 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1749204826} + - component: {fileID: 1749204825} + m_Layer: 0 + m_Name: --------- Instances ---------- + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1749204825 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1749204824} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e4bd367752a957644a1419fad5d66606, type: 3} + m_Name: + m_EditorClassIdentifier: + DividerType: 3 +--- !u!4 &1749204826 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1749204824} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 11.32872, y: 8.170444, z: 1.3793705} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 954058989} + - {fileID: 1749204826} + - {fileID: 58781228} diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes/StateMachine_SubScene.unity.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes/StateMachine_SubScene.unity.meta new file mode 100644 index 00000000..ea8ab78c --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scenes/SubScenes/StateMachine_SubScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 85f02b9a3c60b91408e976145814a961 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts.meta new file mode 100644 index 00000000..8c1ffd99 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e6147c504f1c3084c94ce5a770bcf40d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime.meta new file mode 100644 index 00000000..0c5059b2 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 02558f1ea8bf8994c9b1568271752f73 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings.meta new file mode 100644 index 00000000..3e1917ef --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 450c1584a6114a68bc07bdc234ff88d9 +timeCreated: 1717013711 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTag.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTag.cs new file mode 100644 index 00000000..744c0d13 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTag.cs @@ -0,0 +1,8 @@ +using Unity.Entities; + +namespace RMC.DOTS.Demos.StateMachine +{ + public struct MyMovementEntityTag : IComponentData + { + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTag.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTag.cs.meta new file mode 100644 index 00000000..b1ec51f8 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTag.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2ac46cc690544549b30a7b40b3c7a6c3 +timeCreated: 1717017725 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTagAuthoring.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTagAuthoring.cs new file mode 100644 index 00000000..e299087e --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTagAuthoring.cs @@ -0,0 +1,44 @@ +using RMC.DOTS.Systems.StateMachine; +using Unity.Entities; +using Unity.Mathematics; +using UnityEngine; + +namespace RMC.DOTS.Demos.StateMachine +{ + public class MyMovementEntityTagAuthoring : MonoBehaviour + { + public Entity entity; + + public class Test01AuthoringBaker : Baker + { + public override void Bake(MyMovementEntityTagAuthoring authoring) + { + authoring.entity = GetEntity(TransformUsageFlags.Dynamic); + + // TODO: Remove this? How else can I turn on the first state easily? + //(This is more of a "how to easily find an entity?" question than an SM question) + AddComponent(authoring.entity); + + //Give this entity 1) an ID and 2) a state to be in + AddComponent(authoring.entity); + AddComponent(authoring.entity); + + AddComponent(authoring.entity, + new RotationComponent() + { + RotationDelta = new float3(0, 0.25f, 0), + DurationInSeconds = 1 + }); + + AddComponent(authoring.entity, + new TranslationComponent() + { + TranslationDelta = new float3(0, 0.25f, 0), + DurationInSeconds = 1 + }); + + } + } + + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTagAuthoring.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTagAuthoring.cs.meta new file mode 100644 index 00000000..92e1b87b --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Authorings/MyMovementEntityTagAuthoring.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 716abc68a53a4ad6827ad9949b52b883 +timeCreated: 1717010959 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components.meta new file mode 100644 index 00000000..27d8c09d --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9a03356de03c46fab341397bf0163041 +timeCreated: 1717013683 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/RotationComponent.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/RotationComponent.cs new file mode 100644 index 00000000..1a06fbe4 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/RotationComponent.cs @@ -0,0 +1,12 @@ +using Unity.Entities; +using Unity.Mathematics; + +namespace RMC.DOTS.Demos.StateMachine +{ + public struct RotationComponent : IComponentData + { + public float3 RotationDelta; + public float DurationInSeconds; + } +} + diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/RotationComponent.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/RotationComponent.cs.meta new file mode 100644 index 00000000..f3ac78f0 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/RotationComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 83b93edb290735e4eac7153930e55982 +timeCreated: 1688706574 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/TranslationComponent.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/TranslationComponent.cs new file mode 100644 index 00000000..3b1e4ae3 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/TranslationComponent.cs @@ -0,0 +1,11 @@ +using Unity.Entities; +using Unity.Mathematics; + +namespace RMC.DOTS.Demos.StateMachine +{ + public struct TranslationComponent : IComponentData + { + public float3 TranslationDelta; + public float DurationInSeconds; + } +} diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/TranslationComponent.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/TranslationComponent.cs.meta new file mode 100644 index 00000000..0fd802ba --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/Components/TranslationComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 87008116b7fe48c9a8a4b64e10148d29 +timeCreated: 1717013436 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/RMC.DOTS.Demos.StateMachine.Runtime.asmdef b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/RMC.DOTS.Demos.StateMachine.Runtime.asmdef new file mode 100644 index 00000000..1846640b --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/RMC.DOTS.Demos.StateMachine.Runtime.asmdef @@ -0,0 +1,27 @@ +{ + "name": "RMC.DOTS.Demos.StateMachine.Runtime", + "rootNamespace": "", + "references": [ + "GUID:d28bf24cef16ed84cb4cb180b9c77ac3", + "GUID:330ce21097b4d554fa95a74295bc3b8f", + "GUID:2665a8d13d1b3f18800f46e256720795", + "GUID:734d92eba21c94caba915361bd5ac177", + "GUID:63afb046c8423dd448ae7aba042ea63d", + "GUID:a5baed0c9693541a5bd947d336ec7659", + "GUID:e0cd26848372d4e5c891c569017e11f1", + "GUID:d8b63aba1907145bea998dd612889d6b", + "GUID:5f3cf485eb0554709a8abbeace890c86", + "GUID:8819f35a0fc84499b990e90a4ca1911f", + "GUID:75469ad4d38634e559750d17036d5f7c", + "GUID:f2381d29563bc3c49ab35691478f3482" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/RMC.DOTS.Demos.StateMachine.Runtime.asmdef.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/RMC.DOTS.Demos.StateMachine.Runtime.asmdef.meta new file mode 100644 index 00000000..68966411 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/RMC.DOTS.Demos.StateMachine.Runtime.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 621c109dda757314790fac8a3c51da86 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.cs new file mode 100644 index 00000000..24320745 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.cs @@ -0,0 +1,40 @@ +using RMC.DOTS.Systems.StateMachine; +using Unity.Collections; +using Unity.Entities; +using UnityEngine; + +namespace RMC.DOTS.Demos.StateMachine +{ + /// + /// See + /// + public class StateMachine : MonoBehaviour + { + // Initialization -------------------------------- + protected void Start() + { + Debug.Log("StateMachine Demo. Watch the console."); + + MyMovementStateMachineSystem myMovementStateMachineSystem = + World.DefaultGameObjectInjectionWorld.CreateSystemManaged(); + + // TODO + // 1. remove the need for the Test01 component. Find another way to set the **FIRST** state + // 2. Rethink the need for "RotationComponent". Does it make sense, or just move that DATA into the related state? + EntityQuery query = new EntityQueryBuilder(Allocator.Temp) + .WithAllRW() + .Build(World.DefaultGameObjectInjectionWorld.EntityManager); + + using (query) + { + var entities = query.ToEntityArray(Allocator.Temp); + foreach (Entity entity in entities) + { + myMovementStateMachineSystem. + RequestStateChange(entity); + } + } + + } + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.cs.meta new file mode 100644 index 00000000..53ee69a3 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 672c51cd61b685542920a0588a0b3f54 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.meta new file mode 100644 index 00000000..98a646e9 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c25aa59df703f84aa03818cf1817526 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementBaseState.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementBaseState.cs new file mode 100644 index 00000000..ca4e6261 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementBaseState.cs @@ -0,0 +1,48 @@ +using RMC.DOTS.Systems.StateMachine; +using UnityEngine; +using Unity.Entities; + +namespace RMC.DOTS.Demos.StateMachine +{ + public class MyMovementBaseState : StateMachineSystemBase.State + { + protected float StateElapsedTimeInSeconds { get; private set; } + + protected void RequestStateChangePerTransitions(Entity entity) + { + // Toggle + if (IsInState(entity)) + { + RequestStateChange(entity); + } + else if (IsInState(entity)) + { + RequestStateChange(entity); + } + else + { + Debug.LogError("Unknown State"); + } + } + + public override void OnEnter(Entity entity) + { + base.OnEnter(entity); + StateElapsedTimeInSeconds = 0; + Debug.LogFormat("{0}.OnEnter() {1}\n\n", entity.ToString(), GetType().Name); + } + + public override void OnUpdate(Entity entity) + { + base.OnUpdate(entity); + StateElapsedTimeInSeconds += World.Time.DeltaTime; + //Debug.LogFormat("{0}.OnUpdate() {1}\n\n", entity.ToString(), GetType().Name); + } + + public override void OnExit(Entity entity) + { + base.OnExit(entity); + //Debug.LogFormat("{0}.OnExit() {1}\n\n", entity.ToString(), GetType().Name); + } + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementBaseState.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementBaseState.cs.meta new file mode 100644 index 00000000..c9abe7f1 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementBaseState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 18e31fa1c1cc53745a79d2292263cc4c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementStateMachineSystem.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementStateMachineSystem.cs new file mode 100644 index 00000000..23dfe224 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementStateMachineSystem.cs @@ -0,0 +1,18 @@ +using RMC.DOTS.Systems.StateMachine; +using Unity.Entities; + +namespace RMC.DOTS.Demos.StateMachine +{ + struct MyMovementStateSystemTag : IComponentData{} + + partial class MyMovementStateMachineSystem : StateMachineSystem + { + protected override void OnCreate() + { + base.OnCreate(); + + RegisterState(); + RegisterState(); + } + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementStateMachineSystem.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementStateMachineSystem.cs.meta new file mode 100644 index 00000000..40f75454 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/MyMovementStateMachineSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f256d90c619949c19c2570c0744962c6 +timeCreated: 1717013774 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States.meta new file mode 100644 index 00000000..e605e0d1 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a68a041232e1ba34c932502af82c58f7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementRotationState.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementRotationState.cs new file mode 100644 index 00000000..4f399051 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementRotationState.cs @@ -0,0 +1,43 @@ +using RMC.DOTS.Systems.StateMachine; +using UnityEngine; +using Unity.Entities; +using Unity.Mathematics; +using Unity.Transforms; + +namespace RMC.DOTS.Demos.StateMachine +{ + public class MyMovementRotationState : MyMovementBaseState + { + public override void OnUpdate(Entity entity) + { + base.OnUpdate(entity); + var deltaTime = System.World.Time.DeltaTime; + + // Check Component + if (!EntityManager.HasComponent(entity) || + !EntityManager.HasComponent(entity)) + { + return; + } + + // Get Component + RotationComponent rotationComponent = EntityManager.GetComponentData(entity); + LocalTransform localTransform = EntityManager.GetComponentData(entity); + + // Consider Transition + if (StateElapsedTimeInSeconds >= rotationComponent.DurationInSeconds) + { + RequestStateChangePerTransitions(entity); + } + else + { + // Update Component + quaternion rotation = quaternion.Euler(rotationComponent.RotationDelta * deltaTime); + localTransform.Rotation = math.mul(localTransform.Rotation, rotation); + + // Set Component + EntityManager.SetComponentData(entity, localTransform); + } + } + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementRotationState.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementRotationState.cs.meta new file mode 100644 index 00000000..77db7f21 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementRotationState.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: aa417349d6a64208b5855142905c6526 +timeCreated: 1717013904 \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementTranslationState.cs b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementTranslationState.cs new file mode 100644 index 00000000..584904b9 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementTranslationState.cs @@ -0,0 +1,39 @@ +using Unity.Entities; +using Unity.Transforms; + +namespace RMC.DOTS.Demos.StateMachine +{ + public class MyMovementTranslationState : MyMovementBaseState + { + public override void OnUpdate(Entity entity) + { + base.OnUpdate(entity); + var deltaTime = System.World.Time.DeltaTime; + + // Check Component + if (!EntityManager.HasComponent(entity) || + !EntityManager.HasComponent(entity)) + { + return; + } + + // Get Component + TranslationComponent translationComponent = EntityManager.GetComponentData(entity); + LocalTransform localTransform = EntityManager.GetComponentData(entity); + + // Consider Transition + if (StateElapsedTimeInSeconds >= translationComponent.DurationInSeconds) + { + RequestStateChangePerTransitions(entity); + } + else + { + // Update Component + localTransform.Position += translationComponent.TranslationDelta * deltaTime; + + // Set Component + EntityManager.SetComponentData(entity, localTransform); + } + } + } +} \ No newline at end of file diff --git a/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementTranslationState.cs.meta b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementTranslationState.cs.meta new file mode 100644 index 00000000..f2202cb7 --- /dev/null +++ b/RMC DOTS/Samples~/3. RMC DOTS Library Demos/Demos/~Experimental/StateMachine/Scripts/Runtime/StateMachine/States/MyMovementTranslationState.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6a609b031873430698afec4a2b39373d +timeCreated: 1717013898 \ No newline at end of file diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine.meta b/RMC DOTS/Scripts/Runtime/Systems/StateMachine.meta new file mode 100644 index 00000000..f793fea7 --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c2cfdb19195fd4e4493b318563aa42e0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/.gitignore b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/.gitignore new file mode 100644 index 00000000..c527e02d --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/projectSettingsUpdater.xml +/.idea.TzarGames.StateMachineECS.iml +/contentModel.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/encodings.xml b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/encodings.xml new file mode 100644 index 00000000..df87cf95 --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/indexLayout.xml b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/indexLayout.xml new file mode 100644 index 00000000..7b08163c --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/vcs.xml b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/.idea/.idea.TzarGames.StateMachineECS.dir/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateID.cs b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateID.cs new file mode 100644 index 00000000..2ac05f4f --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateID.cs @@ -0,0 +1,16 @@ +using Unity.Entities; + +namespace RMC.DOTS.Systems.StateMachine +{ + [System.Serializable] + public struct StateID : IComponentData + { + internal int currentStateID; + internal int stateIdToSwitch; + public void RequestSwitchToState(int stateID) + { + stateIdToSwitch = stateID; + } + public int StateIdToSwitch => stateIdToSwitch; + } +} \ No newline at end of file diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateID.cs.meta b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateID.cs.meta new file mode 100644 index 00000000..ac76cfc4 --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateID.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7a9e40554dd64f75b894bc6d000f7e61 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateMachineSystemBase.cs b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateMachineSystemBase.cs new file mode 100644 index 00000000..a28a625d --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateMachineSystemBase.cs @@ -0,0 +1,342 @@ +using Unity.Collections; +using System.Collections.Generic; +using Unity.Entities; +using UnityEngine; + +namespace RMC.DOTS.Systems.StateMachine +{ + public abstract partial class StateMachineSystemBase : SystemBase + { + EntityQuery _stateQuery; + List stateProcessors = new List(); + EntityCommandBufferSystem commandBufferSystem; + + protected EntityCommandBuffer Commands { get; private set; } + int stateIdCounter = 1; + + protected override void OnCreate() + { + base.OnCreate(); + commandBufferSystem = InitializeEntityCommandBufferSystem(); + _stateQuery = GetStateEntityQuery(); + } + + protected abstract EntityQuery GetStateEntityQuery(); + + protected virtual EntityCommandBufferSystem InitializeEntityCommandBufferSystem() + { + return World.GetExistingSystemManaged(); + } + + bool commandsInitializedEarly = false; + + protected void InitilizeCommandsEarly() + { + if(commandsInitializedEarly) + { + return; + } + Commands = commandBufferSystem.CreateCommandBuffer(); + commandsInitializedEarly = true; + } + + protected override void OnUpdate() + { + + if(commandsInitializedEarly == false) + { + Commands = commandBufferSystem.CreateCommandBuffer(); + } + else + { + commandsInitializedEarly = false; + } + + updateStates(); + } + + void updateStates() + { + + for (int i = 0; i < stateProcessors.Count; i++) + { + var state = stateProcessors[i]; + state.OnBeforeUpdate(); + } + + using(var chunks = _stateQuery.ToArchetypeChunkArray(Allocator.Temp)) + { + // EXIT + foreach (var chunk in chunks) + { + var entities = chunk.GetNativeArray(GetEntityTypeHandle()); + var stateIds = chunk.GetNativeArray(GetComponentTypeHandle()); + + for (int i = 0; i < chunk.Count; i++) + { + var entity = entities[i]; + var stateId = stateIds[i]; + + for (int j = 0; j < stateProcessors.Count; j++) + { + var stateProcessor = stateProcessors[j]; + + if (stateId.StateIdToSwitch == stateId.currentStateID) + { + continue; + } + + if (stateId.StateIdToSwitch == stateProcessor.ID) + { + continue; + } + + if(stateId.currentStateID != stateProcessor.ID) + { + continue; + } + + stateProcessor.OnExit(entity); + } + } + } + + // ENTER + foreach (var chunk in chunks) + { + var entities = chunk.GetNativeArray(GetEntityTypeHandle()); + var stateIds = chunk.GetNativeArray(GetComponentTypeHandle()); + + for (int c = 0; c < chunk.Count; c++) + { + var entity = entities[c]; + var stateId = stateIds[c]; + + for (int i = 0; i < stateProcessors.Count; i++) + { + var state = stateProcessors[i]; + + if (stateId.StateIdToSwitch == stateId.currentStateID) + { + continue; + } + + if (stateId.StateIdToSwitch != state.ID) + { + continue; + } + + stateId.currentStateID = state.ID; + stateId.stateIdToSwitch = state.ID; + stateIds[c] = stateId; + + state.OnEnter(entity); + } + } + } + + // UPDATE + foreach (var chunk in chunks) + { + var entities = chunk.GetNativeArray(GetEntityTypeHandle()); + var stateIds = chunk.GetNativeArray(GetComponentTypeHandle()); + + for (int c = 0; c < chunk.Count; c++) + { + var entity = entities[c]; + var stateId = stateIds[c]; + + for (int i = 0; i < stateProcessors.Count; i++) + { + var state = stateProcessors[i]; + + if (stateId.currentStateID != state.ID || stateId.stateIdToSwitch != state.ID) + { + continue; + } + + state.OnUpdate(entity); + } + } + } + } + + for (int i = 0; i < stateProcessors.Count; i++) + { + var state = stateProcessors[i]; + state.OnAfterUpdate(); + } + } + + private int GetStateIndex() where T : State + { + foreach (var state in stateProcessors) + { + if (state is T) + { + return state.ID; + } + } + return -1; + } + + protected T RegisterState() where T : State, new() + { + var state = new T(); + RegisterState(state); + return state; + } + + protected void RegisterState(State state) + { + var stateType = state.GetType(); + + bool replaced = false; + + for (int i = 0; i < stateProcessors.Count; i++) + { + var otherState = stateProcessors[i]; + var otherType = otherState.GetType(); + + if (stateType.IsSubclassOf(otherType)) + { + stateProcessors[i] = state; + replaced = true; + } + } + if (replaced == false) + { + stateProcessors.Add(state); + } + + state.ID = stateIdCounter; + stateIdCounter++; + state.Initialize(this); + } + + public bool IsInState(Entity e) where T : State + { + if (HasComponent(e) == false) + return false; + var stateId = GetComponent(e); + var stateIndex = GetStateIndex(); + return stateIndex == stateId.currentStateID; + } + + public void RequestStateChange(Entity entity) where T : State + { + var id = GetStateIndex(); + + if(id == -1) + { + throw new System.InvalidOperationException($"No registered state found with type {typeof(T).Name}"); + } + var stateId = GetComponent(entity); + stateId.RequestSwitchToState(id); + SetComponent(entity, stateId); + } + + public class State + { + internal int ID; + + public StateMachineSystemBase System { get; protected set; } + protected EntityCommandBuffer Commands; + protected EntityManager EntityManager; + protected World World; + + + public virtual void Initialize(StateMachineSystemBase system) + { + System = system; + EntityManager = System.EntityManager; + World = System.World; + } + + public bool IsPendingStateChange(Entity entity) + { + var stateId = GetComponent(entity); + return stateId.currentStateID != stateId.stateIdToSwitch; + } + + public bool Exists(Entity entity) + { + return System.EntityManager.Exists(entity); + } + + public bool HasComponent(Entity entity) where T : unmanaged, IComponentData + { + return System.HasComponent(entity); + } + + public bool HasBuffer(Entity entity) where T : unmanaged, IBufferElementData + { + return System.HasBuffer(entity); + } + + public T GetComponent(Entity entity) where T : unmanaged, IComponentData + { + return System.GetComponent(entity); + } + + public DynamicBuffer GetBuffer(Entity entity) where T : unmanaged, IBufferElementData + { + return System.GetBuffer(entity); + } + + public T GetComponentObject(Entity entity) + { + return System.EntityManager.GetComponentObject(entity); + } + + public void SetComponent(Entity entity, T data) where T : unmanaged, IComponentData + { + System.SetComponent(entity, data); + } + + protected EntityQuery GetEntityQuery(params ComponentType[] types) + { + return System.GetEntityQuery(types); + } + + public bool IsInState(Entity e) where K : State + { + return System.IsInState(e); + } + + public void RequestStateChange(Entity entity) where K : State + { + System.RequestStateChange(entity); + } + + public virtual void OnBeforeUpdate() + { + Commands = System.Commands; + } + + public virtual void OnAfterUpdate() + { + } + + public virtual void OnEnter(Entity entity) + { + } + + public virtual void OnExit(Entity entity) + { + } + + public virtual void OnUpdate(Entity entity) + { + } + } + } + + public partial class StateMachineSystem : StateMachineSystemBase where S : struct, IComponentData + { + protected override EntityQuery GetStateEntityQuery() + { + return GetEntityQuery(typeof(StateID), ComponentType.ReadOnly()); + } + } +} \ No newline at end of file diff --git a/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateMachineSystemBase.cs.meta b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateMachineSystemBase.cs.meta new file mode 100644 index 00000000..639b47e0 --- /dev/null +++ b/RMC DOTS/Scripts/Runtime/Systems/StateMachine/StateMachineSystemBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3c0e8ad4200c67449e02242f83c47f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index a1536949..1a8b0e30 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.rmc.rmc-dots", "displayName": "RMC DOTS", - "version": "1.5.3", + "version": "1.5.4", "unity": "2022.3", "description": "DOTS library for Unity Development by Rivello Multimedia Consulting", "keywords": [