private void MakingOrders(GameTime gt, LocalUnits lh, SectorMap smap) { for (int o = 0; o < lh.N.Count; o++) { LocalUnit h = lh.N[o]; if (h.CurrentOrder is DestroyOrder && IsNear(h.Pos, h.CurrentOrder.dest)) { smap.At(h.CurrentOrder.dest.X, h.CurrentOrder.dest.Y, h.CurrentOrder.dest.Z).Health -= (float)(10 * gt.TotalGameTime.TotalSeconds); if ( smap.At(h.CurrentOrder.dest.X, h.CurrentOrder.dest.Y, h.CurrentOrder.dest.Z).Health <= 0) { Main.smap.KillBlock((int)h.CurrentOrder.dest.X, (int)h.CurrentOrder.dest.Y, (int)h.CurrentOrder.dest.Z); h.CurrentOrder.complete = true; h.CurrentOrder = new NothingOrder(); } } if (h.CurrentOrder is CollectOrder && IsNear(h.Pos, h.CurrentOrder.dest)) { //var temp = Main.localitems.GetNearItem(h.pos); if ((h.CurrentOrder as CollectOrder).tocollect.id != 0 && h.Carry.id == 0) { //if (Main.localitems.n.Contains((h.current_order as CollectOrder).tocollect)) //{ h.Carry.id = (h.CurrentOrder as CollectOrder).tocollect.id; h.Carry.count = (h.CurrentOrder as CollectOrder).tocollect.count; Main.localitems.n.Remove((h.CurrentOrder as CollectOrder).tocollect); h.CurrentOrder.complete = true; if (Main.globalstorage.n.Count > 0) { Vector3 st = Main.globalstorage.GetFreeStorage(); if (st != new Vector3(-1)) { h.CurrentOrder = new ToStoreOrder { dest = st }; Main.AddToLog("ToStoreOrder patch find for " + h.Pos + " " + h.Patch.Count); h.Patch = Main.smap.FindPatch(h.Pos, st); (h.CurrentOrder as ToStoreOrder).storagepos = st; } } //} } } //if (h.current_order is ToStoreOrder && IsNear(h.pos, h.current_order.dest)) //{ // if (h.carry.id != 0) // { // Vector3 st = (h.current_order as ToStoreOrder).storagepos; // LocalItems tempstor = Main.mmap.n[(int)st.X, (int)st.Y, (int)st.Z].tags["storage"] as LocalItems; // if (tempstor.n.Count < tempstor.carp) // { // tempstor.n.Add(new LocalItem() { count = h.carry.count, id = h.carry.id }); // h.carry = new LocalItem(); // h.current_order = new NothingOrder(); // } // else // { // Main.localitems.n.Add(new LocalItem() { count = h.carry.count, id = h.carry.id }); // h.carry = new LocalItem(); // h.current_order = new NothingOrder(); // } // } //} if (h.CurrentOrder is BuildOrder && IsNear(h.Pos, h.CurrentOrder.dest)) { bool allow = true; foreach (LocalUnit he in lh.N) { if ((int)he.Pos.X == (int)h.CurrentOrder.dest.X && (int)he.Pos.Z == (int)h.CurrentOrder.dest.Z && (int)he.Pos.Z == (int)h.CurrentOrder.dest.Z) { allow = false; } } if (Main.smap.At(h.CurrentOrder.dest).BlockID == 0 && allow && Main.iss.n[(h.CurrentOrder as BuildOrder).blockID].count >= 1) { Main.smap.SetBlock(h.CurrentOrder.dest, (h.CurrentOrder as BuildOrder).blockID); Main.iss.n[(h.CurrentOrder as BuildOrder).blockID].count--; h.CurrentOrder.complete = true; h.CurrentOrder = new NothingOrder(); } } if (h.IddleTime >= TimeSpan.FromSeconds(10)) { h.CurrentOrder.taken = false; h.CurrentOrder.sleep = true; h.CurrentOrder = new NothingOrder(); } } }