void HandleReport(FellTreeActionReport report) { var living = m_world.FindObject <LivingObject>(report.LivingObjectID); if (report.Success) { Events.AddGameEvent(living, "{0} fells {1} {2}", living, report.MaterialID, report.TileID); } else { Events.AddGameEvent(living, "{0} fails to fell tree: {1}", living, report.FailReason); } }
ActionState ProcessAction(FellTreeAction action) { if (this.ActionTicksUsed == 1) { this.ActionTotalTicks = GetTicks(SkillID.WoodCutting); } if (this.ActionTicksUsed < this.ActionTotalTicks) { return(ActionState.Ok); } IntVector3 p = this.Location + action.Direction; var td = this.Environment.GetTileData(p); var report = new FellTreeActionReport(this, action.Direction); if (td.HasTree == false) { SendFailReport(report, "not a tree"); return(ActionState.Fail); } report.TileID = td.ID; report.MaterialID = td.MaterialID; var grassMaterials = Materials.GetMaterials(MaterialCategory.Grass).ToArray(); this.Environment.SetTileData(p, new TileData() { ID = TileID.Grass, MaterialID = grassMaterials[this.World.Random.Next(grassMaterials.Length)].ID, }); if (td.HasFellableTree) { var builder = new ItemObjectBuilder(ItemID.Log, td.MaterialID) { Name = "Log", Color = GameColor.SaddleBrown, }; var log = builder.Create(this.World); log.MoveToMustSucceed(this.Environment, p); } SendReport(report); return(ActionState.Done); }
ActionState ProcessAction(FellTreeAction action) { if (this.ActionTicksUsed == 1) this.ActionTotalTicks = GetTicks(SkillID.WoodCutting); if (this.ActionTicksUsed < this.ActionTotalTicks) return ActionState.Ok; IntPoint3 p = this.Location + new IntVector3(action.Direction); var td = this.Environment.GetTileData(p); var id = td.InteriorID; var report = new FellTreeActionReport(this, action.Direction); if (id.IsTree() == false) { SendFailReport(report, "not a tree"); return ActionState.Fail; } var material = td.InteriorMaterialID; report.InteriorID = id; report.MaterialID = material; var grassMaterials = Materials.GetMaterials(MaterialCategory.Grass).ToArray(); td.InteriorID = InteriorID.Grass; td.InteriorMaterialID = grassMaterials[this.World.Random.Next(grassMaterials.Length)].ID; this.Environment.SetTileData(p, td); if (id.IsFellableTree()) { var builder = new ItemObjectBuilder(ItemID.Log, material) { Name = "Log", Color = GameColor.SaddleBrown, }; var log = builder.Create(this.World); var ok = log.MoveTo(this.Environment, p); Debug.Assert(ok); } SendReport(report); return ActionState.Done; }
ActionState ProcessAction(FellTreeAction action) { if (this.ActionTicksUsed == 1) this.ActionTotalTicks = GetTicks(SkillID.WoodCutting); if (this.ActionTicksUsed < this.ActionTotalTicks) return ActionState.Ok; IntVector3 p = this.Location + action.Direction; var td = this.Environment.GetTileData(p); var report = new FellTreeActionReport(this, action.Direction); if (td.HasTree == false) { SendFailReport(report, "not a tree"); return ActionState.Fail; } report.TileID = td.ID; report.MaterialID = td.MaterialID; var grassMaterials = Materials.GetMaterials(MaterialCategory.Grass).ToArray(); this.Environment.SetTileData(p, new TileData() { ID = TileID.Grass, MaterialID = grassMaterials[this.World.Random.Next(grassMaterials.Length)].ID, }); if (td.HasFellableTree) { var builder = new ItemObjectBuilder(ItemID.Log, td.MaterialID) { Name = "Log", Color = GameColor.SaddleBrown, }; var log = builder.Create(this.World); log.MoveToMustSucceed(this.Environment, p); } SendReport(report); return ActionState.Done; }
void HandleReport(FellTreeActionReport report) { var living = m_world.FindObject<LivingObject>(report.LivingObjectID); if (report.Success) Events.AddGameEvent(living, "{0} fells {1} {2}", living, report.MaterialID, report.InteriorID); else Events.AddGameEvent(living, "{0} fails to fell tree: {1}", living, report.FailReason); }