public void TravelTo(TourCartStation station, FreightTrackJunction start) { if (station != null && station.JunctionDirection != -1 && station.ClosestJunction != null) { string mobtype = this.GetSpawnedCartType(); if (string.IsNullOrEmpty(mobtype)) { return; } FreightCartMob tourcart = MobManager.instance.SpawnMob(MobType.Mod, mobtype, this.mSegment, this.mnX, this.mnY + (long)this.mForwards.y + 1L, this.mnZ, new Vector3(0.0f, 0.0f, 0.0f), this.mForwards) as FreightCartMob; ManagerSync.TourCart = tourcart; tourcart.DestinationJunction = station.ClosestJunction; tourcart.DestinationDirection = station.JunctionDirection; tourcart.JunctionRoute = station.TrackNetwork.RouteFind(start, station.ClosestJunction); tourcart.NextJunction = start; } }
private void Start() { //this.gameObject.AddComponent<Rideable>(); GameObjectWrapper gameObjectWrapper = this.GetComponent <SpawnableObjectScript>().wrapper; if (gameObjectWrapper == null) { return; } this.gameObject.name = this.gameObject.name + ".ID : " + FreightCartUnity.MinecartNumber; ++FreightCartUnity.MinecartNumber; this.mHoverLight = this.transform.Find("HoverLight").GetComponent <Light>(); if (this.mHoverLight == null) { Debug.LogError("Error, Minecart had no hover light?"); } this.mob = gameObjectWrapper.mPayload as FreightCartMob; this.Body = Extensions.Search(this.transform, "Minecart GFX").gameObject; this.mnHealth = -999999; this.mRenderer = this.GetComponentsInChildren <Renderer>(); this.mbRenderer = true; this.mbDoorRenderer = true; this.LoadParticles = Extensions.Search(this.transform, "Loading Particles").GetComponent <ParticleSystem>(); this.LoadParticlesDust = Extensions.Search(this.transform, "Loading Particles Dust").GetComponent <ParticleSystem>(); this.Door_L = Extensions.Search(this.transform, "Minecart Door L").gameObject; this.Door_R = Extensions.Search(this.transform, "Minecart Door R").gameObject; if (DateTime.Now.Month != 4 || DateTime.Now.Day > 1) { Extensions.Search(this.transform, "AprilFool").gameObject.SetActive(false); } this.mAudio = this.GetComponent <AudioSource>(); Material material = (Material)null; if (this.mob.mObjectType == SpawnableObjectEnum.Minecart_T1) { if ((UnityEngine.Object)Minecart_Unity.T1_Mat == (UnityEngine.Object)null) { Minecart_Unity.T1_Mat = Resources.Load("DynamicTextures/Minecart_dif") as Material; } material = Minecart_Unity.T1_Mat; } if (this.mob.mObjectType == SpawnableObjectEnum.Minecart_T2) { if ((UnityEngine.Object)Minecart_Unity.T2_Mat == (UnityEngine.Object)null) { Minecart_Unity.T2_Mat = Resources.Load("DynamicTextures/Minecart_dif T2") as Material; } material = Minecart_Unity.T2_Mat; } if (this.mob.mObjectType == SpawnableObjectEnum.Minecart_T3) { if ((UnityEngine.Object)Minecart_Unity.T3_Mat == (UnityEngine.Object)null) { Minecart_Unity.T3_Mat = Resources.Load("DynamicTextures/Minecart_dif T3") as Material; } material = Minecart_Unity.T3_Mat; } if (this.mob.mObjectType == SpawnableObjectEnum.Minecart_T4) { if ((UnityEngine.Object)Minecart_Unity.T4_Mat == (UnityEngine.Object)null) { Minecart_Unity.T4_Mat = Resources.Load("DynamicTextures/Minecart_dif T4") as Material; } material = Minecart_Unity.T4_Mat; } if (material != null) { this.Door_L.GetComponent <Renderer>().material = material; this.Door_R.GetComponent <Renderer>().material = material; this.Body.GetComponent <Renderer>().material = material; } this.mCurrentPos = this.transform.position; this.mMPB = new MaterialPropertyBlock(); if (this.mHoverLight != null && this.mob.IsOreFreighter) { this.mMPB.SetColor("_GlowColor", Color.blue); } }
private void SpawnTrackNetworks() { this.manager.SetTitle("Track Systems"); this.manager.AddButton("allnetworks", "Global Inventory", buttonx2, 0); this.manager.AddButton("selnetwork", "Select Network", buttonx3, 0); this.manager.AddButton("tracknetworks", "Network Status", buttonx4, 0); this.manager.AddButton("viewinventory", "View Inventory", buttonx5, 0); int ycursor = 65; int trackiconx = globalxoffset + 175; int trackxoffset = trackiconx + 65; int tracklabel = trackxoffset + 250; int stationxicon = trackiconx + 50; int stationlabel = stationxicon + 65; int cartxicon = stationxicon + 50; int cartlabel = cartxicon + 65; int invxicon = cartxicon + 50; int invlabel = invxicon + 65; int networkcount = FreightCartManager.instance.GlobalTrackNetworks.Count; if (networkcount == 0) { this.manager.AddBigLabel("notracknetworks", "No track networks found...", Color.red, 225, 150); } else { string trackicon = "Track Straight"; string stationicon = "Minecart Load"; for (int n = 0; n < networkcount; n++) { FreightTrackNetwork network = FreightCartManager.instance.GlobalTrackNetworks[n]; if (network == null) { continue; } int junctioncount = network.TrackJunctions.Count; int networkID = network.NetworkID; int assignedcarts; int availcarts; network.GetNetworkStats(out assignedcarts, out availcarts); this.manager.AddIcon("trackicon" + n, trackicon, Color.white, trackiconx, ycursor); this.manager.AddBigLabel("trackjunctions" + n, "ID: " + network.NetworkID.ToString() + " " + junctioncount.ToString() + " Junctions Carts: ", Color.white, trackxoffset, ycursor); this.manager.AddBigLabel("trackcarts" + n, availcarts.ToString() + " / " + assignedcarts.ToString(), availcarts > assignedcarts ? Color.green : availcarts == assignedcarts ? Color.white : Color.red, tracklabel, ycursor); ycursor += 60; if (this.TrackNetworkDisplay == n) { List <FreightCartStation> stations = network.GetNetworkStations(); stations = stations.OrderBy(x => x.StationName).ToList(); int stationcount = stations.Count; Debug.LogWarning("FSM Station Count: " + stationcount.ToString()); for (int m = 0; m < stationcount; m++) { FreightCartStation station = stations[m]; int stationavail = station.AvailableCarts; int stationassigned = station.AssignedCarts; this.manager.AddIcon("stationicon" + m, stationicon, Color.white, stationxicon, ycursor); this.manager.AddBigLabel("stationnetwork" + m, (!string.IsNullOrEmpty(station.StationName) ? station.StationName : "UNNAMED") + " - " + station.NetworkID, station.StationFull <= 0 ? Color.white : Color.red, stationlabel, ycursor); this.manager.AddBigLabel("stationcarts" + m, "Carts: " + stationavail.ToString() + " / " + stationassigned.ToString(), stationavail > stationassigned ? Color.green : stationavail == stationassigned ? Color.white : Color.red, stationlabel + 350, ycursor); ycursor += 60; if (this.StationDisplay == m) { this.manager.AddButton("addcart", "Add Cart", stationlabel + 475, ycursor - 60); this.manager.AddButton("removecart", "Remove Cart", stationlabel + 475, ycursor - 10); this.CurrentStation = station; List <FreightRegistry> LocalDeficits = new List <FreightRegistry>(); List <FreightRegistry> LocalSurplus = new List <FreightRegistry>(); if (station.massStorageCrate != null) { LocalDeficits = FreightCartManager.instance.GetLocalDeficit(station.NetworkID, station.massStorageCrate); LocalSurplus = FreightCartManager.instance.GetLocalSurplus(station.NetworkID, station.massStorageCrate); } else if (station.HopperInterface != null) { LocalDeficits = this.FreightListingConversion(station.HopperInterface.FreightRequests.OrderByDescending(x => x.Quantity).Take(3).ToList()); LocalSurplus = this.FreightListingConversion(station.HopperInterface.FreightOfferings.OrderByDescending(x => x.Quantity).Take(3).ToList()); } else if (station.AttachedInterface != null) { LocalDeficits = this.FreightListingConversion(station.AttachedInterface.FreightRequests.OrderByDescending(x => x.Quantity).Take(3).ToList()); LocalSurplus = this.FreightListingConversion(station.AttachedInterface.FreightOfferings.OrderByDescending(x => x.Quantity).Take(3).ToList()); } ycursor -= 20; string str = ""; int shifter = 1; int ind2 = 0; if (LocalDeficits.Count <= 0) { this.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, "localdef", "This storage is fully stocked!", Color.white, false, stationlabel, ycursor); } else { this.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, "localdef", "Top requests for this storage:", Color.white, false, stationlabel, ycursor); } ycursor += 20; for (int index = 0; index < LocalDeficits.Count; index++) { if (LocalDeficits[index].Deficit != 0) { str = (index + 1).ToString() + ") " + LocalDeficits[index].Deficit.ToString("N0") + "x " + ItemManager.GetItemName(LocalDeficits[index].FreightItem) + "\n"; this.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, "localdef" + index, str, Color.white, false, stationlabel, ycursor); ycursor += 20; } shifter++; } ycursor -= 20 * shifter; if (LocalSurplus.Count <= 0) { this.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, "localsur", "This storage has nothing to offer!", Color.white, false, stationlabel + 250, ycursor); } else { this.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, "localsur", "Top offerings for this storage:", Color.white, false, stationlabel + 250, ycursor); } ycursor += 20; for (int index = 0; index < LocalSurplus.Count; index++) { if (LocalSurplus[index].Surplus != 0) { str = (index + 1).ToString() + ") " + LocalSurplus[index].Surplus.ToString("N0") + "x " + ItemManager.GetItemName(LocalSurplus[index].FreightItem) + "\n"; this.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, "localsur" + index, str, Color.white, false, stationlabel + 250, ycursor); ycursor += 20; } ind2 = index; } if (ind2 > (shifter - 2)) { ycursor += 20; } else { ycursor += (shifter - 1 - ind2) * 20 + 20; } int cartcount = station.CartList.Count; for (int p = 0; p < cartcount; p++) { FreightCartMob cart = station.CartList[p]; int itemID = ItemEntries.MineCartT1; if (cart.meType == FreightCartMob.eMinecartType.FreightCartMK1) { itemID = ModManager.mModMappings.ItemsByKey["steveman0.FreightCartMK1"].ItemId; } else if (cart.meType == FreightCartMob.eMinecartType.FreightCart_T1 || cart.meType == FreightCartMob.eMinecartType.OreFreighter_T1) { itemID = ItemEntries.MineCartT1; } else if (cart.meType == FreightCartMob.eMinecartType.FreightCart_T2 || cart.meType == FreightCartMob.eMinecartType.OreFreighter_T2) { itemID = ItemEntries.MineCartT2; } else if (cart.meType == FreightCartMob.eMinecartType.FreightCart_T3 || cart.meType == FreightCartMob.eMinecartType.OreFreighter_T3) { itemID = ItemEntries.MineCartT3; } else if (cart.meType == FreightCartMob.eMinecartType.FreightCart_T4 || cart.meType == FreightCartMob.eMinecartType.OreFreighter_T4) { itemID = ItemEntries.MineCartT4; } else if (cart.meType == FreightCartMob.eMinecartType.FreightCartTour) { itemID = ItemEntries.TourCart; } string carticon = ItemManager.GetItemIcon(itemID); this.manager.AddIcon("carticon" + p, carticon, Color.white, cartxicon, ycursor); this.manager.AddBigLabel("cartlabel" + p, "Inventory: " + cart.mnUsedStorage.ToString() + "/" + cart.mnMaxStorage.ToString(), Color.white, cartlabel, ycursor); ycursor += 60; if (p == CartDisplay) { MachineInventory inv = null; if (!string.IsNullOrEmpty(station.NetworkID) && cart.LocalInventory.ContainsKey(station.NetworkID)) { inv = cart.LocalInventory[station.NetworkID]; } if (inv == null || inv.ItemCount() == 0) { this.manager.AddBigLabel("invlabelempty", "No goods from this station", Color.white, invxicon + 15, ycursor); ycursor += 60; } else { int invcount = inv.Inventory.Count; for (int q = 0; q < invcount; q++) { ItemBase item = inv.Inventory[q]; string invicon = ItemManager.GetItemIcon(item); this.manager.AddIcon("invicon" + q, invicon, Color.white, invxicon, ycursor); this.manager.AddBigLabel("invlabel" + q, item.ToString(), Color.white, invlabel, ycursor); ycursor += 60; } } } } } } //Insert Tour cart staion listing here } } } }
public CartStats(FreightCartMob mob) { CartType = mob.meType; UsedStorage = mob.mnUsedStorage; MaxStorage = mob.mnMaxStorage; }
public TrackNetworksWrapper(int tracknetwork, int station, int cart) { // This shouldn't happen but just in case... if (FreightCartManager.instance == null) { return; } // Track Networks this.NetworkCount = FreightCartManager.instance.GlobalTrackNetworks.Count; this.NetworkStats = new List <TrackNetworkStats>(this.NetworkCount); for (int n = 0; n < this.NetworkCount; n++) { this.NetworkStats.Add(new TrackNetworkStats(n)); } // Freight Cart Stations if (tracknetwork != -1 && tracknetwork < this.NetworkCount) { List <FreightCartStation> stations = FreightCartManager.instance.GlobalTrackNetworks[tracknetwork].GetNetworkStations(); stations = stations.OrderBy(x => x.StationName).ToList(); this.StationCount = stations.Count; this.Stations = new List <StationStats>(this.StationCount); foreach (FreightCartStation sta in stations) { this.Stations.Add(new StationStats(sta)); } if (station != -1 && station < this.StationCount) { FreightCartStation Station = stations[station]; // Station details this.GetStationGoods(Station); // Carts this.CartCount = Station.CartList.Count; this.Carts = new List <CartStats>(this.CartCount); foreach (FreightCartMob mob in Station.CartList) { this.Carts.Add(new CartStats(mob)); } // Displayed Cart if (cart != -1 && cart < this.CartCount) { FreightCartMob Cart = Station.CartList[cart]; if (!string.IsNullOrEmpty(Station.NetworkID) && Cart.LocalInventory.ContainsKey(Station.NetworkID)) { CartInventory = Cart.LocalInventory[Station.NetworkID].Inventory; } } } else { this.CartCount = 0; } } else { this.StationCount = 0; this.CartCount = 0; } }