From 2079ebf17aba90ad4f0c2778e5f62e3749eb9730 Mon Sep 17 00:00:00 2001 From: Jason Weimann Date: Wed, 18 Apr 2018 22:31:40 -0700 Subject: [PATCH] Zombies kill humans --- Assets/GameCode/HumanInfectionSystem.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Assets/GameCode/HumanInfectionSystem.cs b/Assets/GameCode/HumanInfectionSystem.cs index b7c3d94..d22608d 100644 --- a/Assets/GameCode/HumanInfectionSystem.cs +++ b/Assets/GameCode/HumanInfectionSystem.cs @@ -5,6 +5,30 @@ using Unity.Transforms2D; using UnityEngine; +class HumanToZombieSystem : ComponentSystem +{ + struct HumansToConvertData + { + public int Length; + public ComponentDataArray Humans; + public EntityArray Entities; + } + + [Inject] private HumansToConvertData humanData; + + protected override void OnUpdate() + { + for (int i = 0; i < humanData.Length; i++) + { + Human human = humanData.Humans[i]; + if (human.IsInfected == 1) + { + PostUpdateCommands.DestroyEntity(humanData.Entities[i]); + } + } + } +} + class HumanInfectionSystem : JobComponentSystem { [Inject] private HumanInfectionData humanData; @@ -48,6 +72,7 @@ public void Execute(int index) var human = humanData.Humans[i]; human.IsInfected = 1; humanData.Humans[i] = human; + } }