public EntityDefinition CreateEntityDefinition(FlightGroupDefinition flightGroup) { if (HasFlightGroup(flightGroup)) { EntityDefinition entity = GameDatabase.ActiveInstance.CreateAsset <EntityDefinition>(); flightGroup.AddEntity(entity); onChange?.Invoke(entity.id); return(entity); } else { throw new ArgumentException("Flight group not part of any faction in mission"); } }
public void SetEntityFlightGroup(EntityDefinition entity, FlightGroupDefinition flightGroup, int index) { Debug.Assert(HasFlightGroup(flightGroup), $"Flight group {flightGroup.name} not part of any faction in mission"); if (entity.flightGroupId == flightGroup.id) { if (index == -1) { index = 0; } flightGroup.entities.MoveToIndex(entity, index); } else { FlightGroupDefinition currentFlightGroup = GetFlightGroup(entity.flightGroupId); currentFlightGroup?.RemoveEntity(entity); flightGroup.AddEntity(entity, index); } onChange?.Invoke(entity.id); }