private TaskState Consume(Dwarf d, float dt) { if (d.GetHoldingWorldObject() == null) throw new Exception("Dwarf does not carry any tool"); if (d.GetHoldingWorldObject().GetType().IsSubclassOf(typeof(Tool)) == false) throw new Exception("Dwarf tried to consume something that was not tool"); Tool tool = (Tool)d.RemoveHoldingWorldObject(); d.ConsumeTool(tool); return TaskState.PersonalSuccess; }
private TaskState Eat(Dwarf d, float dt) { if (d.GetHoldingWorldObject() == null) throw new Exception("Dwarf does not carry any food"); if (d.GetHoldingWorldObject().GetType().IsSubclassOf(typeof(Food)) == false) throw new Exception("Dwarf tried to eat something that was not food"); Food food = (Food)d.RemoveHoldingWorldObject(); d.EatFood(food); if (d.Stats.Hunger < 100) return TaskState.PersonalFailTryTaskAgain; else return TaskState.PersonalSuccess; }