/// <summary> /// Execute action on the selected target /// </summary> /// <param name="target">Selected target</param> public override void Execute(ITargetable target) { switch (SpawnableDef) { case BuildingDef buildingDef: using (ConstructingBuildingFactory factory = new ConstructingBuildingFactory(factionController)) { ConstructingBuildingController building = factory.CreateConstructingBuildingControllerOf(buildingDef); SpawnBuilding(building, target); } break; case UnitDef unitDef: using (UnitFactory factory = new UnitFactory(factionController, gameController)) { UnitController unit = factory.CreateNewUnit(unitDef); SpawnUnit(unit, target); } break; default: throw new NotImplementedException(); } }
/// <summary> /// Spawns a building at a target location /// </summary> /// <param name="building">building to be spawned</param> /// <param name="spawntarget">The target</param> private void SpawnBuilding(IStructure <IStructureDef> building, ITargetable spawntarget) { ConstructingBuildingController constructingBuilding = ConstructingBuildingFactory.CreateNewBUCAt(building.Def, (Coords)spawntarget.FloatCoords, factionController); gameController.Spawner.SpawnStructure((Coords)spawntarget.FloatCoords, constructingBuilding); }