void HandleReport(BuildItemActionReport report) { var living = m_world.FindObject <LivingObject>(report.LivingObjectID); var item = m_world.FindObject <ItemObject>(report.ItemObjectID); if (report.Success) { Events.AddGameEvent(living, "{0} builds item {1}", living, item); } else { Events.AddGameEvent(living, "{0} fails to build item {1}: {2}", living, report.BuildableItemKey, report.FailReason); } }
ActionState ProcessAction(BuildItemAction action) { if (this.ActionTicksUsed == 1) { var workbench = this.World.FindObject<ItemObject>(action.WorkbenchID); if (workbench == null) throw new Exception(); var bi = Workbenches.GetWorkbenchInfo(workbench.ItemID); var buildableItem = bi.FindBuildableItem(action.BuildableItemKey); if (buildableItem == null) throw new Exception(); this.ActionTotalTicks = GetTicks(buildableItem.SkillID); } if (this.ActionTicksUsed < this.ActionTotalTicks) { return ActionState.Ok; } else { var workbench = this.World.FindObject<ItemObject>(action.WorkbenchID); var report = new BuildItemActionReport(this, action.BuildableItemKey); if (workbench == null) { SendFailReport(report, "cannot find building"); return ActionState.Fail; } /* if (this.ActionTicksLeft != 0) { var ok = building.VerifyBuildItem(this, action.SourceObjectIDs, action.DstItemID); if (!ok) SetActionError("build item request is invalid"); return ok; } */ var bi2 = Workbenches.GetWorkbenchInfo(workbench.ItemID); var bi = bi2.FindBuildableItem(action.BuildableItemKey); var item = PerformBuildItem(this, bi, action.SourceObjectIDs); if (item == null) { SendFailReport(report, "unable to build the item"); return ActionState.Fail; } report.ItemObjectID = item.ObjectID; SendReport(report); return ActionState.Done; } }
ActionState ProcessAction(BuildItemAction action) { if (this.ActionTicksUsed == 1) { var workbench = this.World.FindObject <ItemObject>(action.WorkbenchID); if (workbench == null) { throw new Exception(); } var bi = Workbenches.GetWorkbenchInfo(workbench.ItemID); var buildableItem = bi.FindBuildableItem(action.BuildableItemKey); if (buildableItem == null) { throw new Exception(); } this.ActionTotalTicks = GetTicks(buildableItem.SkillID); } if (this.ActionTicksUsed < this.ActionTotalTicks) { return(ActionState.Ok); } else { var workbench = this.World.FindObject <ItemObject>(action.WorkbenchID); var report = new BuildItemActionReport(this, action.BuildableItemKey); if (workbench == null) { SendFailReport(report, "cannot find building"); return(ActionState.Fail); } /* * if (this.ActionTicksLeft != 0) * { * var ok = building.VerifyBuildItem(this, action.SourceObjectIDs, action.DstItemID); * if (!ok) * SetActionError("build item request is invalid"); * return ok; * } */ var bi2 = Workbenches.GetWorkbenchInfo(workbench.ItemID); var bi = bi2.FindBuildableItem(action.BuildableItemKey); var item = PerformBuildItem(this, bi, action.SourceObjectIDs); if (item == null) { SendFailReport(report, "unable to build the item"); return(ActionState.Fail); } report.ItemObjectID = item.ObjectID; SendReport(report); return(ActionState.Done); } }
void HandleReport(BuildItemActionReport report) { var living = m_world.FindObject<LivingObject>(report.LivingObjectID); var item = m_world.FindObject<ItemObject>(report.ItemObjectID); if (report.Success) Events.AddGameEvent(living, "{0} builds item {1}", living, item); else Events.AddGameEvent(living, "{0} fails to build item {1}: {2}", living, report.BuildableItemKey, report.FailReason); }