protected override void OnExecuteEvent(VEntity entity) { DeathEventComponent ecDeath = VEntityComponentSystemManager.GetVComponent <DeathEventComponent>(entity); VEntity dyingEntity = ecsManager.GetVEntityById(ecDeath.id); if (dyingEntity != null) { HealthComponent h = dyingEntity.GetVComponent <HealthComponent>(); if (h != null && h.currHealth > 0) { return; } ecsManager.MarkRemovalEntity(dyingEntity); // remove the entity from all relevant things UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>(); unitsList.unitIds.Remove(dyingEntity.id); PositionTrackSystem positionTrackSystem = ecsManager.GetSystem <PositionTrackSystem>(); positionTrackSystem.Untrack(dyingEntity.id); ecsManager.QueueAnimationEvent("DeathAnimation", component: new DeathAnimationEvent { deathTransform = dyingEntity.GetVComponent <PositionDisplayComponent>().mainTransform, dyingEntityId = dyingEntity.id }); } }
public VEntity GetPlayerUnitByClass(CardType type) { UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>(); string unitId = unitsList.unitIds.Find((id) => { CharacterClassComponent characterClassComponent = ecsManager.GetVComponent <CharacterClassComponent>(id); return(characterClassComponent != null && characterClassComponent.cardType == type); }); return(ecsManager.GetVEntityById(unitId)); }
public IEnumerable <VEntity> GetAllEnemyUnits() { UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>(); List <VEntity> list = new List <VEntity>(); foreach (string unitId in unitsList.unitIds) { if (ecsManager.GetVComponent <TeamComponent>(unitId).team == Team.ENEMY) { list.Add(ecsManager.GetVEntityById(unitId)); } } return(list); }
public IEnumerable <VEntity> GetAllPlayerUnits() { UnitsList unitsList = ecsManager.GetVSingletonComponent <UnitsList>(); List <VEntity> list = new List <VEntity>(); foreach (string unitId in unitsList.unitIds) { if (ecsManager.GetVComponent <CharacterClassComponent>(unitId) != null) { list.Add(ecsManager.GetVEntityById(unitId)); } } return(list); }