// Door.RPC_CloseDoor()/RPC_OpenDoor() public static void DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open) { DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open); OnDoorUse.OnNext(due); BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock; if (baseLock != null && !due.IgnoreLock) { bool TryCloseOpen = open ? !baseLock.OnTryToOpen(rpc.player) : !baseLock.OnTryToClose(rpc.player); if (TryCloseOpen) return; } door.SetFlag(BaseEntity.Flags.Open, due.Open); door.Invoke("UpdateLayer", 0f); door.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); if (due.DenyReason != "") rpc.player.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), due.DenyReason)); }
// Door.RPC_CloseDoor()/RPC_OpenDoor() public static void On_DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open) { if ((open && door.IsOpen()) || (!open && !door.IsOpen())) return; DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open); OnNext("On_DoorUse", due); if (!due.Allow) { if (due.DenyReason != "") rpc.player.SendConsoleCommand("chat.add", 0, String.Format("{0}: {1}", Server.server_message_name.ColorText("fa5"), due.DenyReason)); return; } bool doaction = true; BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock; if (!due.IgnoreLock && baseLock != null) { doaction = open ? baseLock.OnTryToOpen(rpc.player) : baseLock.OnTryToClose(rpc.player); if (doaction && open && (baseLock.IsLocked() && Time.realtimeSinceStartup - (float)door.GetFieldValue("decayResetTimeLast") > 60)) { Decay.RadialDecayTouch (door.transform.position, 40, 270532608); door.SetFieldValue("decayResetTimeLast", Time.realtimeSinceStartup); } } if (doaction) { door.SetFlag(BaseEntity.Flags.Open, open); door.SendNetworkUpdateImmediate (false); door.CallMethod("UpdateDoorAnimationParameters", false); } }