Skip to content

Instantly share code, notes, and snippets.

@raveneer
Created January 4, 2018 13:55
Show Gist options
  • Save raveneer/918e3a7109d7baae1fe66599a4b21c2a to your computer and use it in GitHub Desktop.
Save raveneer/918e3a7109d7baae1fe66599a4b21c2a to your computer and use it in GitHub Desktop.
simple Entitas damage system
using Entitas;
using UnityEngine;
public class FireDamageSystem : IExecuteSystem
{
readonly IGroup<GameEntity> _haveFireEntities;
public FireDamageSystem(Contexts contexts)
{
_haveFireEntities = contexts.game.GetGroup(GameMatcher.Fire);
}
public void Execute()
{
foreach (GameEntity haveFireEntity in _haveFireEntities.GetEntities())
{
haveFireEntity.ReplaceHealth(haveFireEntity.health.Value - haveFireEntity.fire.Strength);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment