From 5eec25b924b8541d723a06c978483b18abd20b6d Mon Sep 17 00:00:00 2001 From: Christopher Lucian Date: Sun, 15 Apr 2018 21:43:26 -0700 Subject: [PATCH] Human Navigation System Moves Forward --- Assets/GameCode/ComponentTypes.meta | 8 ++++++ Assets/GameCode/ComponentTypes/Human.cs | 6 +++++ Assets/GameCode/ComponentTypes/Human.cs.meta | 11 ++++++++ Assets/GameCode/HumanNavigationSystem.cs | 25 +++++++++++++++++++ ....cs.meta => HumanNavigationSystem.cs.meta} | 0 Assets/GameCode/ZombieSimulatorBootstrap.cs | 6 ++++- Assets/GameCode/ZombieSpawnSystem.cs | 8 ------ Assets/Scenes/ECS Zombie Simulator.unity | 6 ++--- 8 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 Assets/GameCode/ComponentTypes.meta create mode 100644 Assets/GameCode/ComponentTypes/Human.cs create mode 100644 Assets/GameCode/ComponentTypes/Human.cs.meta create mode 100644 Assets/GameCode/HumanNavigationSystem.cs rename Assets/GameCode/{ZombieSpawnSystem.cs.meta => HumanNavigationSystem.cs.meta} (100%) delete mode 100644 Assets/GameCode/ZombieSpawnSystem.cs diff --git a/Assets/GameCode/ComponentTypes.meta b/Assets/GameCode/ComponentTypes.meta new file mode 100644 index 0000000..f440d44 --- /dev/null +++ b/Assets/GameCode/ComponentTypes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 927c89852ba988a4b855fb50106203cb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameCode/ComponentTypes/Human.cs b/Assets/GameCode/ComponentTypes/Human.cs new file mode 100644 index 0000000..948bfb9 --- /dev/null +++ b/Assets/GameCode/ComponentTypes/Human.cs @@ -0,0 +1,6 @@ +using Unity.Entities; + +public struct Human : IComponentData +{ + +} diff --git a/Assets/GameCode/ComponentTypes/Human.cs.meta b/Assets/GameCode/ComponentTypes/Human.cs.meta new file mode 100644 index 0000000..e122e6b --- /dev/null +++ b/Assets/GameCode/ComponentTypes/Human.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf8e5f6a04b680a46b5821bf82958e22 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameCode/HumanNavigationSystem.cs b/Assets/GameCode/HumanNavigationSystem.cs new file mode 100644 index 0000000..8b1de50 --- /dev/null +++ b/Assets/GameCode/HumanNavigationSystem.cs @@ -0,0 +1,25 @@ +using Unity.Entities; +using Unity.Transforms2D; + +class HumanNavigationSystem : ComponentSystem +{ + public struct HumanData + { + public int Length; + public ComponentDataArray Position; + public ComponentDataArray Heading; + public ComponentDataArray Human; + } + + [Inject] private HumanData humanDatum; + + protected override void OnUpdate() + { + for (int index = 0; index < humanDatum.Length; ++index) + { + Heading2D heading2D = humanDatum.Heading[index]; + heading2D.Value = new Unity.Mathematics.float2(1f, 0f); + humanDatum.Heading[index] = heading2D; + } + } +} diff --git a/Assets/GameCode/ZombieSpawnSystem.cs.meta b/Assets/GameCode/HumanNavigationSystem.cs.meta similarity index 100% rename from Assets/GameCode/ZombieSpawnSystem.cs.meta rename to Assets/GameCode/HumanNavigationSystem.cs.meta diff --git a/Assets/GameCode/ZombieSimulatorBootstrap.cs b/Assets/GameCode/ZombieSimulatorBootstrap.cs index 4417292..a4a959f 100644 --- a/Assets/GameCode/ZombieSimulatorBootstrap.cs +++ b/Assets/GameCode/ZombieSimulatorBootstrap.cs @@ -54,7 +54,11 @@ private static void DefineArchetypes(EntityManager entityManager) { //Humans - Composition of the humans - HumanArchetype = entityManager.CreateArchetype(typeof(MoveSpeed), typeof(Heading2D), typeof(Position2D), typeof(TransformMatrix)); + HumanArchetype = entityManager.CreateArchetype(typeof(Human), + typeof(Heading2D), + typeof(MoveSpeed), + typeof(Position2D), + typeof(TransformMatrix)); } diff --git a/Assets/GameCode/ZombieSpawnSystem.cs b/Assets/GameCode/ZombieSpawnSystem.cs deleted file mode 100644 index ab8f706..0000000 --- a/Assets/GameCode/ZombieSpawnSystem.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Unity.Entities; - -class ZombieSpawnSystem : ComponentSystem -{ - protected override void OnUpdate() - { - } -} diff --git a/Assets/Scenes/ECS Zombie Simulator.unity b/Assets/Scenes/ECS Zombie Simulator.unity index b5fe672..8edd88a 100644 --- a/Assets/Scenes/ECS Zombie Simulator.unity +++ b/Assets/Scenes/ECS Zombie Simulator.unity @@ -179,13 +179,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 282840810} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 30, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!1 &657261335 GameObject: m_ObjectHideFlags: 0