protected override GameAction PrepareNextActionOverride(out JobStatus progress) { var v = m_location - this.Worker.Location; if (!this.Worker.Location.IsAdjacentTo(m_location, DirectionSet.Planar)) { progress = JobStatus.Fail; return null; } var action = new FellTreeAction(v.ToDirection()); progress = JobStatus.Ok; return action; }
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); }
protected override GameAction PrepareNextActionOverride(out JobStatus progress) { var v = m_location - this.Worker.Location; if (!this.Worker.Location.IsAdjacentTo(m_location, DirectionSet.Planar)) { progress = JobStatus.Fail; return(null); } var action = new FellTreeAction(v.ToDirection()); progress = JobStatus.Ok; return(action); }
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; }