Example #1
0
        // Door.RPC_CloseDoor()/RPC_OpenDoor()
        public static void DoorUse(Door door, BaseEntity.RPCMessage rpc, bool open)
        {
            BaseLock baseLock = door.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

            if (baseLock != null)
            {
                bool TryCloseOpen = open ? !baseLock.OnTryToOpen(rpc.player) : !baseLock.OnTryToClose(rpc.player);
                if (TryCloseOpen)
                {
                    return;
                }
            }

            DoorUseEvent due = new DoorUseEvent(new Entity(door), Server.GetPlayer(rpc.player), open);

            OnDoorUse.OnNext(due);

            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));
            }
        }
Example #2
0
        // 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);
            }
        }
Example #3
0
 public void On_DoorUse(DoorUseEvent due)
 {
     SetHookWorking("On_DoorUse");
     Broadcast(due.Player.Name + " used a door");
 }
Example #4
0
 public void OnDoorUse(DoorUseEvent due)
 {
     this.Invoke("On_DoorUse", due);
 }