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));
            }
        }
    private bool CanAdministrate(BasePlayer player)
    {
        BaseLock slot = base.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (slot == null)
        {
            return(true);
        }
        return(slot.OnTryToOpen(player));
    }
Example #3
0
    public bool CanAdministrate(BasePlayer player)
    {
        BaseLock baseLock = GetSlot(Slot.Lock) as BaseLock;

        if (baseLock == null)
        {
            return(true);
        }
        return(baseLock.OnTryToOpen(player));
    }
    private bool CanAdministrate(BasePlayer player)
    {
        BaseLock slot = this.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (Object.op_Equality((Object)slot, (Object)null))
        {
            return(true);
        }
        return(slot.OnTryToOpen(player));
    }
Example #5
0
    private void RPC_OpenDoor(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract())
        {
            return;
        }
        if (!this.canHandOpen)
        {
            return;
        }
        if (base.IsOpen())
        {
            return;
        }
        if (base.IsBusy())
        {
            return;
        }
        if (base.IsLocked())
        {
            return;
        }
        BaseLock slot = base.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (slot != null)
        {
            if (!slot.OnTryToOpen(rpc.player))
            {
                return;
            }
            if (slot.IsLocked() && UnityEngine.Time.realtimeSinceStartup - this.decayResetTimeLast > 60f)
            {
                BuildingBlock buildingBlock = base.FindLinkedEntity <BuildingBlock>();
                if (!buildingBlock)
                {
                    Decay.RadialDecayTouch(base.transform.position, 40f, 2097408);
                }
                else
                {
                    Decay.BuildingDecayTouch(buildingBlock);
                }
                this.decayResetTimeLast = UnityEngine.Time.realtimeSinceStartup;
            }
        }
        base.SetFlag(BaseEntity.Flags.Open, true, false, true);
        base.SendNetworkUpdateImmediate(false);
        if (this.isSecurityDoor && this.NavMeshLink != null)
        {
            this.SetNavMeshLinkEnabled(true);
        }
        Interface.CallHook("OnDoorOpened", this, rpc.player);
    }
Example #6
0
    private void RPC_ToggleHatch(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract() || !this.hasHatch)
        {
            return;
        }
        BaseLock slot = this.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (Object.op_Implicit((Object)slot) && !slot.OnTryToOpen(rpc.player))
        {
            return;
        }
        this.SetFlag(BaseEntity.Flags.Reserved3, !this.HasFlag(BaseEntity.Flags.Reserved3), false, true);
    }
Example #7
0
    public virtual bool CanOpenLootPanel(BasePlayer player, string panelName = "")
    {
        if (this.needsBuildingPrivilegeToUse && !player.CanBuild())
        {
            return(false);
        }
        BaseLock slot = base.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (!(slot != null) || slot.OnTryToOpen(player))
        {
            return(true);
        }
        player.ChatMessage("It is locked...");
        return(false);
    }
Example #8
0
    private void RPC_ToggleHatch(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract())
        {
            return;
        }
        if (!this.hasHatch)
        {
            return;
        }
        BaseLock slot = base.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (!slot || slot.OnTryToOpen(rpc.player))
        {
            base.SetFlag(BaseEntity.Flags.Reserved3, !base.HasFlag(BaseEntity.Flags.Reserved3), false, true);
        }
    }
Example #9
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 #10
0
    private void RPC_OpenDoor(BaseEntity.RPCMessage rpc)
    {
        if (!rpc.player.CanInteract() || !this.canHandOpen || (this.IsOpen() || this.IsBusy()) || this.IsLocked())
        {
            return;
        }
        BaseLock slot = this.GetSlot(BaseEntity.Slot.Lock) as BaseLock;

        if (Object.op_Inequality((Object)slot, (Object)null))
        {
            if (!slot.OnTryToOpen(rpc.player))
            {
                return;
            }
            if (slot.IsLocked() && (double)Time.get_realtimeSinceStartup() - (double)this.decayResetTimeLast > 60.0)
            {
                BuildingBlock linkedEntity = this.FindLinkedEntity <BuildingBlock>();
                if (Object.op_Implicit((Object)linkedEntity))
                {
                    Decay.BuildingDecayTouch(linkedEntity);
                }
                else
                {
                    Decay.RadialDecayTouch(((Component)this).get_transform().get_position(), 40f, 2097408);
                }
                this.decayResetTimeLast = Time.get_realtimeSinceStartup();
            }
        }
        this.SetFlag(BaseEntity.Flags.Open, true, false, true);
        this.SendNetworkUpdateImmediate(false);
        if (this.isSecurityDoor && Object.op_Inequality((Object)this.NavMeshLink, (Object)null))
        {
            this.SetNavMeshLinkEnabled(true);
        }
        Interface.CallHook("OnDoorOpened", (object)this, (object)rpc.player);
    }