public Faction() { Threats = new List<Creature>(); Minions = new List<CreatureAI>(); SelectedMinions = new List<CreatureAI>(); TaskManager = new TaskManager(this); Stockpiles = new List<Stockpile>(); DigDesignations = new List<BuildOrder>(); GuardDesignations = new List<BuildOrder>(); ChopDesignations = new List<Body>(); AttackDesignations = new List<Body>(); ShipDesignations = new List<ShipOrder>(); GatherDesignations = new List<Body>(); RoomBuilder = new RoomBuilder(this); WallBuilder = new PutDesignator(this, TextureManager.GetTexture(ContentPaths.Terrain.terrain_tiles)); CraftBuilder = new CraftBuilder(this); }
public virtual void OnCancelled(TaskManager Manager, WorldManager World) { }
public override void OnVoxelsSelected(List <Voxel> voxels, InputManager.MouseButton button) { List <CreatureAI> minions = PlayState.Master.SelectedMinions.Where(minion => minion.Stats.CurrentClass.HasAction(GameMaster.ToolMode.Farm)).ToList(); List <Task> goals = new List <Task>(); switch (Mode) { case FarmMode.Tilling: foreach (Voxel voxel in voxels) { if (button == InputManager.MouseButton.Left) { if (!voxel.Type.IsSoil) { PlayState.GUI.ToolTipManager.Popup("Can only till soil!"); continue; } if (voxel.TypeName == "TilledSoil") { PlayState.GUI.ToolTipManager.Popup("Soil already tilled!"); continue; } if (!HasTile(voxel)) { FarmTile tile = new FarmTile() { Vox = voxel }; goals.Add(new FarmTask(tile) { Mode = FarmAct.FarmMode.Till, Plant = PlantType }); FarmTiles.Add(tile); } else { goals.Add(new FarmTask(FarmTiles.Find(tile => tile.Vox.Equals(voxel))) { Mode = FarmAct.FarmMode.Till, Plant = PlantType }); } } else { if (HasTile(voxel) && !HasPlant(voxel)) { FarmTiles.RemoveAll(tile => tile.Vox.Equals(voxel)); } } } TaskManager.AssignTasksGreedy(goals, minions, 1); foreach (CreatureAI creature in minions) { creature.Creature.NoiseMaker.MakeNoise("Ok", creature.Position); } break; case FarmMode.Planting: int currentAmount = Player.Faction.ListResources() .Sum(resource => resource.Key == PlantType && resource.Value.NumResources > 0 ? resource.Value.NumResources : 0); foreach (Voxel voxel in voxels) { if (currentAmount == 0) { PlayState.GUI.ToolTipManager.Popup("Not enough " + PlantType + " in stocks!"); break; } if (voxel.TypeName != "TilledSoil") { PlayState.GUI.ToolTipManager.Popup("Can only plant on tilled soil!"); continue; } if (ResourceLibrary.Resources[PlantType].Tags.Contains(Resource.ResourceTags.AboveGroundPlant)) { if (voxel.SunColor == 0) { PlayState.GUI.ToolTipManager.Popup("Can only plant " + PlantType + " above ground."); continue; } } else if ( ResourceLibrary.Resources[PlantType].Tags.Contains( Resource.ResourceTags.BelowGroundPlant)) { if (voxel.SunColor > 0) { PlayState.GUI.ToolTipManager.Popup("Can only plant " + PlantType + " below ground."); continue; } } if (!HasPlant(voxel)) { FarmTile tile = new FarmTile() { Vox = voxel }; goals.Add(new FarmTask(tile) { Mode = FarmAct.FarmMode.Plant, Plant = PlantType, RequiredResources = RequiredResources }); FarmTiles.Add(tile); currentAmount--; } else { PlayState.GUI.ToolTipManager.Popup("Something is already planted here!"); continue; } } TaskManager.AssignTasksGreedy(goals, minions, 1); OnConfirm(minions); break; } }