private static void Room_AddObject(On.Room.orig_AddObject orig, Room self, UpdatableAndDeletable obj) { if (self.game == null) { return; } if (obj is WaterGate) { // Add electric gate if (self.abstractRoom.gate) { CustomWorldMod.Log("Water gate created, checking if it should be electric..."); foreach (KeyValuePair <string, string> regions in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[regions.Key].electricGates != null) { if (CustomWorldMod.installedPacks[regions.Key].electricGates.ContainsKey(self.abstractRoom.name)) { (obj as WaterGate).Destroy(); CustomWorldMod.Log($"Added electric gate [{self.abstractRoom.name}] from [{regions.Value}]"); self.regionGate = new ElectricGate(self); (self.regionGate as ElectricGate).meterHeight = CustomWorldMod.installedPacks[regions.Key].electricGates[self.abstractRoom.name]; obj = self.regionGate; break; } } } } } orig(self, obj); }
private static void Room_AddObject(On.Room.orig_AddObject orig, Room self, UpdatableAndDeletable obj) { orig(self, obj); if (obj is PhysicalObject pObj) // Inform clients of added object { PhysicalObjects[ServerMonkScript.GetNewID()] = pObj; } }