public void Run() { WorldComponent world = _world.Components1[0]; foreach (int i in _stoppedGhosts) { int ghostEntity = _stoppedGhosts.Entities[i]; _ecsWorld .AddComponent <ChangeDirectionComponent>(ghostEntity) .NewDirection = Random.NextEnum <Directions>(); } foreach (int i in _ghosts) { Vector2Int currentPosition = _ghosts.Components1[i].Position; foreach (int entity in world.WorldField[currentPosition.x][currentPosition.y]) { var player = _ecsWorld.GetComponent <PlayerComponent>(entity); var isDead = _ecsWorld.GetComponent <PlayerIsDeadEvent>(entity); if (player != null && isDead == null) { _ecsWorld.AddComponent <PlayerIsDeadEvent>(entity); } } } }
public void Run() { foreach (int i in _stoppedGhosts) { EcsEntity ghostEntity = _stoppedGhosts.Entities[i]; ghostEntity.Set <ChangeDirectionComponent>().NewDirection = _random.NextEnum <Directions>(); } foreach (int i in _ghosts) { Vector2Int currentPosition = _ghosts.Get1[i].Position; foreach (EcsEntity entity in _worldService.WorldField[currentPosition.x][currentPosition.y]) { var player = entity.Get <PlayerComponent>(); var isDead = entity.Get <PlayerIsDeadEvent>(); if (player != null && isDead == null) { entity.Set <PlayerIsDeadEvent>(); } } } }