public static bool Prefix(SubFire __instance, SubFire.RoomFire startInRoom, out bool __state) { __state = NitroxServiceLocator.LocateService <SimulationOwnership>().HasAnyLockType(NitroxIdentifier.GetId(__instance.subRoot.gameObject)); // Block any new fires if this player is not the owner return(__state); }
/// <summary> /// Triggered when <see cref="SubFire.CreateFire(SubFire.RoomFire)"/> is executed. To create a new fire manually, /// call <see cref="Create(string, Optional{string}, Optional{CyclopsRooms}, Optional{int})"/> /// </summary> public void OnCreate(Fire fire, SubFire.RoomFire room, int nodeIndex) { string subRootGuid = GuidHelper.GetGuid(fire.fireSubRoot.gameObject); CyclopsFireCreated packet = new CyclopsFireCreated(GuidHelper.GetGuid(fire.gameObject), subRootGuid, room.roomLinks.room, nodeIndex); packetSender.Send(packet); }
/// <summary> /// Triggered when <see cref="SubFire.CreateFire(SubFire.RoomFire)"/> is executed. To create a new fire manually, /// call <see cref="Create(string, Optional{string}, Optional{CyclopsRooms}, Optional{int})"/> /// </summary> public void OnCreate(Fire fire, SubFire.RoomFire room, int nodeIndex) { NitroxId subRootId = NitroxEntity.GetId(fire.fireSubRoot.gameObject); CyclopsFireCreated packet = new CyclopsFireCreated(NitroxEntity.GetId(fire.gameObject), subRootId, room.roomLinks.room, nodeIndex); packetSender.Send(packet); }
public static void Postfix(SubFire __instance, SubFire.RoomFire startInRoom, bool __state) { // Spent way too much time trying to get around a bug in dnspy that doesn't allow me to propery edit this method, so I'm going with the hacky solution. // Every time a Fire is created, the whole list of SubFire.availableNodes is cleared, then populated with any transforms that have 0 childCount. // Next, it chooses a random index, then spawns a fire in that node. // We can easily find where it is because it'll be the only Transform in SubFire.availableNodes with a childCount > 0 if (__state) { Fires fires = NitroxServiceLocator.LocateService <Fires>(); foreach (Transform transform in __instance.availableNodes) { if (transform.childCount > 0) { int nodeIndex = Array.IndexOf(__instance.roomFires[startInRoom.roomLinks.room].spawnNodes, transform); Fire fire = transform.GetComponentInChildren <Fire>(); fires.OnCreate(fire, startInRoom, nodeIndex); return; } } } }