Skip to content

Commit

Permalink
Zombies kill humans
Browse files Browse the repository at this point in the history
  • Loading branch information
jweimann committed Apr 19, 2018
1 parent 9397630 commit 2079ebf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Assets/GameCode/HumanInfectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@
using Unity.Transforms2D;
using UnityEngine;

class HumanToZombieSystem : ComponentSystem
{
struct HumansToConvertData
{
public int Length;
public ComponentDataArray<Human> 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;
Expand Down Expand Up @@ -48,6 +72,7 @@ public void Execute(int index)
var human = humanData.Humans[i];
human.IsInfected = 1;
humanData.Humans[i] = human;

}

}
Expand Down

0 comments on commit 2079ebf

Please sign in to comment.