public static Color GetBackColor(MachineLiquidID id) { switch (id) { case MachineLiquidID.Water: return(new Color() { PackedValue = 0xffbf3d09 }); case MachineLiquidID.Saltwater: return(new Color() { PackedValue = 0xff8e9107 }); case MachineLiquidID.Lava: return(new Color() { PackedValue = 0xff0320fd }); case MachineLiquidID.Honey: return(new Color() { PackedValue = 0xff0c9cff }); default: throw new Exception("Invalid Liquid ID requested: " + id.ToString()); } }
public override void Load(TagCompound tag) { if (tag.GetString("gas") is string gasName) { gasType = (MachineGasID)Enum.Parse(typeof(MachineGasID), gasName); } else { gasType = MachineGasID.None; } if (tag.GetString("liquid") is string liquidName) { liquidType = (MachineLiquidID)Enum.Parse(typeof(MachineLiquidID), liquidName); } else { liquidType = MachineLiquidID.None; } StoredFluid = tag.GetFloat("stored"); if (tag.GetList <Point16>("pumpPositions") is List <Point16> dirPos && tag.GetList <short>("pumpDirs") is List <short> dirDirs) { if (dirPos.Count == dirDirs.Count) { for (int i = 0; i < dirPos.Count; i++) { Framing.GetTileSafely(dirPos[i]).frameX = (short)(dirDirs[i] * 18); } } else { TechMod.Instance.Logger.Error("Network data was modified by an external program (entries: \"pumpPositions\", \"pumpDirs\")"); } } pumpTimers = new Dictionary <Point16, Timer>(); if (tag.GetList <Point16>("pumpTimerLocations") is List <Point16> pumpKeys && tag.GetList <byte>("pumpTimerValues") is List <byte> pumpValues) { if (pumpKeys.Count == pumpValues.Count) { for (int i = 0; i < pumpKeys.Count; i++) { pumpTimers.Add(pumpKeys[i], new Timer() { value = pumpValues[i] }); } } else { TechMod.Instance.Logger.Error("Network data was modified by an external program (entries: \"pumpTimerLocations\", \"pumpTimerValues\")"); } } RefreshConnections(NetworkCollection.ignoreCheckLocation); }
public override void LoadCombinedData(TagCompound up, TagCompound left, TagCompound right, TagCompound down) { if (up?.GetString("gas") is string upGas) { gasType = (MachineGasID)Enum.Parse(typeof(MachineGasID), upGas); } else if (left?.GetString("gas") is string leftGas) { gasType = (MachineGasID)Enum.Parse(typeof(MachineGasID), leftGas); } else if (right?.GetString("gas") is string rightGas) { gasType = (MachineGasID)Enum.Parse(typeof(MachineGasID), rightGas); } else if (down?.GetString("gas") is string downGas) { gasType = (MachineGasID)Enum.Parse(typeof(MachineGasID), downGas); } if (up?.GetString("liquid") is string upLiquid) { liquidType = (MachineLiquidID)Enum.Parse(typeof(MachineLiquidID), upLiquid); } else if (left?.GetString("liquid") is string leftLiquid) { liquidType = (MachineLiquidID)Enum.Parse(typeof(MachineLiquidID), leftLiquid); } else if (right?.GetString("liquid") is string rightLiquid) { liquidType = (MachineLiquidID)Enum.Parse(typeof(MachineLiquidID), rightLiquid); } else if (down?.GetString("liquid") is string downLiquid) { liquidType = (MachineLiquidID)Enum.Parse(typeof(MachineLiquidID), downLiquid); } StoredFluid = (up?.GetFloat("stored") ?? 0) + (left?.GetFloat("stored") ?? 0) + (right?.GetFloat("stored") ?? 0) + (down?.GetFloat("stored") ?? 0); }
public void Load(TagCompound tag) { current = tag.GetFloat("cur"); id = (MachineLiquidID)tag.GetInt("id"); }