using Events; using Unity.Entities; namespace DefaultNamespace { public class PlayerQuickActionsSystem : ComponentSystem { protected override void OnUpdate() { Entities.WithAllReadOnly() .ForEach( (Entity entity, ref PlayerInput input) => { var inv = EntityManager.GetBuffer(entity); if (input.Heal && inv.Begin().Any(s => s.Type == SlotType.Health) && !EntityManager.HasComponent(entity)) { PostUpdateCommands.AddComponent( entity, new ItemUseEventData { Inventory = entity, Slot = inv.Begin().IndexOf(e => e.Type == SlotType.Health) }); } }); } } }