Beispiel #1
0
        bool CanPlayerRecycle(BasePlayer player)
        {
            if (!permission.UserHasPermission(player.UserIDString, "recycle.use"))
            {
                SendReply(player, GetMsg("Denied: Permission", player));
                return(false);
            }

            if (!player.CanBuild())
            {
                SendReply(player, GetMsg("Denied: Privilege", player));
                return(false);
            }
            if (radiationMax > 0 && player.radiationLevel > radiationMax)
            {
                SendReply(player, GetMsg("Denied: Irradiated", player));
                return(false);
            }
            if (player.IsSwimming())
            {
                SendReply(player, GetMsg("Denied: Swimming", player));
                return(false);
            }
            if (!player.IsOnGround())
            {
                SendReply(player, GetMsg("Denied: Falling", player));
                return(false);
            }
            if (player.IsFlying)
            {
                SendReply(player, GetMsg("Denied: Falling", player));
                return(false);
            }
            if (player.IsWounded())
            {
                SendReply(player, GetMsg("Denied: Wounded", player));
                return(false);
            }

            var canRecycle = Interface.Call("CanRecycleCommand", player);

            if (canRecycle != null)
            {
                if (canRecycle is string)
                {
                    SendReply(player, Convert.ToString(canRecycle));
                }
                else
                {
                    SendReply(player, GetMsg("Denied: Generic", player));
                }
                return(false);
            }

            return(true);
        }
Beispiel #2
0
    public virtual bool PlayerIsOwner(BasePlayer player)
    {
        object obj = Interface.CallHook("CanUseMailbox", player, this);

        if (obj is bool)
        {
            return((bool)obj);
        }
        return(player.CanBuild());
    }
Beispiel #3
0
 void GrabCMD(BasePlayer player, string command, string[] args)
 {
     if (!permission.UserHasPermission(player.UserIDString, permissionName))
     {
         player.ChatMessage(msg("No Permission", player.UserIDString));
         return;
     }
     if (permission.UserHasPermission(player.UserIDString, permissionNameRESTRICTED))
     {
         if (!player.CanBuild())
         {
             player.ChatMessage(msg("Building Blocked", player.UserIDString));
             return;
         }
     }
     if (args.Length == 1)
     {
         if (args[0] == "undo")
         {
             if (!undoDic.ContainsKey(player.UserIDString))
             {
                 player.ChatMessage(msg("No Undo Found", player.UserIDString));
                 return;
             }
             if (!undoDic[player.UserIDString].entity.IsValid())
             {
                 return;
             }
             undoDic[player.UserIDString].entity.transform.position = undoDic[player.UserIDString].pos;
             undoDic[player.UserIDString].entity.transform.rotation = undoDic[player.UserIDString].rot;
             undoDic[player.UserIDString].entity.SendNetworkUpdate();
             player.ChatMessage(msg("Undo Success", player.UserIDString));
             undoDic.Remove(player.UserIDString);
             return;
         }
     }
     if (grabList.ContainsKey(player.UserIDString))
     {
         BaseEntity           ent  = grabList[player.UserIDString];
         TelekinesisComponent grab = ent.GetComponent <TelekinesisComponent>();
         if (grab)
         {
             grab.DestroyThis();
         }
         grabList.Remove(player.UserIDString);
         return;
     }
     if (GrabEntity(player) == false)
     {
         player.ChatMessage(msg("Invalid entity", player.UserIDString));
         return;
     }
     player.ChatMessage(msg("Grab tool start", player.UserIDString));
     return;
 }
Beispiel #4
0
    public void DoDeploy_Slot(Deployable deployable, Ray ray, uint entityID)
    {
        if (!base.HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = base.GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            return;
        }
        BaseEntity baseEntity = BaseNetworkable.serverEntities.Find(entityID) as BaseEntity;

        if (baseEntity == null)
        {
            return;
        }
        if (!baseEntity.HasSlot(deployable.slot))
        {
            return;
        }
        if (baseEntity.GetSlot(deployable.slot) != null)
        {
            return;
        }
        Item ownerItem = base.GetOwnerItem();
        ItemModDeployable modDeployable = this.GetModDeployable();
        GameManager       gameManager   = GameManager.server;
        string            str           = modDeployable.entityPrefab.resourcePath;
        Vector3           vector3       = new Vector3();
        Quaternion        quaternion    = new Quaternion();
        BaseEntity        baseEntity1   = gameManager.CreateEntity(str, vector3, quaternion, true);

        if (baseEntity1 != null)
        {
            baseEntity1.skinID = ownerItem.skin;
            baseEntity1.SetParent(baseEntity, baseEntity.GetSlotAnchorName(deployable.slot), false, false);
            baseEntity1.OwnerID = ownerPlayer.userID;
            baseEntity1.OnDeployed(baseEntity);
            baseEntity1.Spawn();
            baseEntity.SetSlot(deployable.slot, baseEntity1);
            if (deployable.placeEffect.isValid)
            {
                Effect.server.Run(deployable.placeEffect.resourcePath, baseEntity.transform.position, Vector3.up, null, false);
            }
        }
        modDeployable.OnDeployed(baseEntity1, ownerPlayer);
        Interface.CallHook("OnItemDeployed", this, baseEntity);
        base.UseItemAmount(1);
    }
        void OnLootEntity(BasePlayer player, BaseEntity entity)
        {
            if (permission.UserHasPermission(player.UserIDString, config.Permissions.BypassPermission))
            {
                return;
            }

            if (!player.CanBuild() && config.Settings.EntityList.Contains(entity.ShortPrefabName))
            {
                NextFrame(player.EndLooting);
                player.ChatMessage(Lang("CantLootEntity", player.UserIDString, entity.ShortPrefabName));
            }
        }
Beispiel #6
0
    public void SetBranchOffPower(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!(player == null) && player.CanBuild() && !(UnityEngine.Time.time < nextChangeTime))
        {
            nextChangeTime = UnityEngine.Time.time + 1f;
            int value = msg.read.Int32();
            value = (branchAmount = Mathf.Clamp(value, 2, 10000000));
            MarkDirtyForceUpdateOutputs();
            SendNetworkUpdate();
        }
    }
Beispiel #7
0
        //int GetValidAmount(Item item, ItemContainer container) {

        //    ItemLimit limit;

        //    int totalAmount = container.GetAmount(item.info.itemid, false) - item.amount;

        //    if(itemLimits.TryGetValue(item.info.shortname, out limit)) {
        //        if(!limit.enabled) {
        //            return 0;
        //        }

        //        if(totalAmount < limit.minimum) {
        //            return 0;
        //        }

        //        if(totalAmount == 0 && item.amount > limit.maximum) {
        //            return limit.maximum;
        //        }

        //        if(totalAmount > limit.maximum) {
        //            return totalAmount - limit.maximum;
        //        }

        //        if(totalAmount == limit.maximum) {
        //            return 0;
        //        }
        //    }

        //    return item.amount;
        //}

        bool CanPlayerBank(BasePlayer player)
        {
            if (!permission.UserHasPermission(player.UserIDString, "bank.use"))
            {
                SendReply(player, GetMsg("Denied: Permission", player));
                return(false);
            }

            if (!player.CanBuild())
            {
                SendReply(player, GetMsg("Denied: Privilege", player));
                return(false);
            }
            if (player.IsSwimming())
            {
                SendReply(player, GetMsg("Denied: Swimming", player));
                return(false);
            }
            if (!player.IsOnGround())
            {
                SendReply(player, GetMsg("Denied: Falling", player));
                return(false);
            }
            if (player.IsFlying())
            {
                SendReply(player, GetMsg("Denied: Falling", player));
                return(false);
            }
            if (player.IsWounded())
            {
                SendReply(player, GetMsg("Denied: Wounded", player));
                return(false);
            }

            var canTrade = Interface.Call("CanBank", player);

            if (canTrade != null)
            {
                if (canTrade is string)
                {
                    SendReply(player, Convert.ToString(canTrade));
                }
                else
                {
                    SendReply(player, GetMsg("Denied: Generic", player));
                }
                return(false);
            }

            return(true);
        }
Beispiel #8
0
        void OnPlayerTick(BasePlayer player)
        {
            if (player.net?.connection?.authLevel > 0)
            {
                return;
            }
            if (DisableNoclipOnNoBuild)
            {
                if (_restricted.ContainsKey(player.userID))
                {
                    return;
                }

                if (player.CanBuild())
                {
                    return;
                }
                if (!player.CanBuild())
                {
                    if (!player.IsFlying)
                    {
                        return;
                    }
                    if (isAllowed(player, "fauxadmin.bypass"))
                    {
                        return;
                    }
                    if (player.IsFlying && isAllowed(player, "fauxadmin.allowed"))
                    {
                        player.violationLevel = 0;
                        var newPos = player.transform.position;
                        DeactivateNoClip(player, newPos);
                        return;
                    }
                }
            }
            return;
        }
Beispiel #9
0
    public void DoDeploy_Regular(Deployable deployable, Ray ray)
    {
        RaycastHit raycastHit;

        if (!base.HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = base.GetOwnerPlayer();

        if (!ownerPlayer)
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            ownerPlayer.ChatMessage("Building is blocked!");
            return;
        }
        if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack(1f, Single.PositiveInfinity))
        {
            ownerPlayer.ChatMessage("AntiHack!");
            return;
        }
        if (!this.CheckPlacement(deployable, ray, 8f))
        {
            return;
        }
        if (!UnityEngine.Physics.Raycast(ray, out raycastHit, 8f, 1235288065))
        {
            return;
        }
        Quaternion        deployedRotation = this.GetDeployedRotation(raycastHit.normal, ray.direction);
        Item              ownerItem        = base.GetOwnerItem();
        ItemModDeployable modDeployable    = this.GetModDeployable();
        BaseEntity        baseEntity       = GameManager.server.CreateEntity(modDeployable.entityPrefab.resourcePath, raycastHit.point, deployedRotation, true);

        if (!baseEntity)
        {
            Debug.LogWarning(string.Concat("Couldn't create prefab:", modDeployable.entityPrefab.resourcePath));
            return;
        }
        baseEntity.skinID = ownerItem.skin;
        baseEntity.SendMessage("SetDeployedBy", ownerPlayer, SendMessageOptions.DontRequireReceiver);
        baseEntity.OwnerID = ownerPlayer.userID;
        baseEntity.Spawn();
        modDeployable.OnDeployed(baseEntity, ownerPlayer);
        Interface.CallHook("OnItemDeployed", this, baseEntity);
        base.UseItemAmount(1);
    }
Beispiel #10
0
    public void SetBranchOffPower(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (Object.op_Equality((Object)player, (Object)null) || !player.CanBuild() || (double)Time.get_time() < (double)this.nextChangeTime)
        {
            return;
        }
        this.nextChangeTime = Time.get_time() + 1f;
        this.branchAmount   = Mathf.Clamp(msg.read.Int32(), 2, 10000000);
        Debug.Log((object)("new branch power : " + (object)this.branchAmount));
        this.MarkDirtyForceUpdateOutputs();
        this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }
Beispiel #11
0
        void sil(BasePlayer player, string command, string[] args)
        {
            if (args.Length == 0)
            {
                player.ChatMessage(Syntax);
                return;
            }

            float cd;

            if (CoolDowns.TryGetValue(player, out cd) && cd > Time.realtimeSinceStartup && !HasPerm(player, "sil_cd"))
            {
                player.ChatMessage(String.Format(CooldownMsg, ToReadableString(cd - Time.realtimeSinceStartup)));
                return;
            }

            RaycastHit hit;
            Signage    sign = null;

            if (Physics.Raycast(player.eyes.HeadRay(), out hit, MaxDist))
            {
                sign = hit.transform.GetComponentInParent <Signage>();
            }

            if (sign == null)
            {
                player.ChatMessage(NoSignFound);
                return;
            }

            if (!(player.CanBuild() || HasPerm(player, "sil_owner")))
            {
                player.ChatMessage(NotYourSign);
                return;
            }

            if (HasPerm(player, "sil_url"))
            {
                UWeb.Add(args[0], player, sign);
                player.ChatMessage(AddedToQueue);
                if (UrlCooldown > 0)
                {
                    CoolDowns[player] = Time.realtimeSinceStartup + UrlCooldown;
                }
            }
            else
            {
                player.ChatMessage(NoPerm);
            }
        }
Beispiel #12
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);
    }
    public void RPC_Rotate(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (basePlayer.CanBuild() && basePlayer.GetHeldEntity() && basePlayer.GetHeldEntity().GetComponent <Hammer>() != null)
        {
            base.transform.rotation = Quaternion.LookRotation(-base.transform.forward, base.transform.up);
            base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            Deployable component = base.GetComponent <Deployable>();
            if (component != null)
            {
                Effect.server.Run(component.placeEffect.resourcePath, base.transform.position, Vector3.up, null, false);
            }
        }
    }
Beispiel #14
0
 object OnOvenToggle(BaseOven oven, BasePlayer player)
 {
     if (oven is BaseFuelLightSource || (oven.needsBuildingPrivilegeToUse && !player.CanBuild()))
     {
         return(null);
     }
     if (!oven.HasFlag(BaseEntity.Flags.On))
     {
         StartCooking(oven);
     }
     else
     {
         StopCooking(oven);
     }
     return(false);
 }
Beispiel #15
0
    public void DoDeploy_Regular(Deployable deployable, Ray ray)
    {
        if (!this.HasItemAmount())
        {
            return;
        }
        BasePlayer ownerPlayer = this.GetOwnerPlayer();

        if (!Object.op_Implicit((Object)ownerPlayer))
        {
            return;
        }
        if (!ownerPlayer.CanBuild())
        {
            ownerPlayer.ChatMessage("Building is blocked!");
        }
        else if (ConVar.AntiHack.objectplacement && ownerPlayer.TriggeredAntiHack(1f, float.PositiveInfinity))
        {
            ownerPlayer.ChatMessage("AntiHack!");
        }
        else
        {
            RaycastHit raycastHit;
            if (!this.CheckPlacement(deployable, ray, 8f) || !Physics.Raycast(ray, ref raycastHit, 8f, 1235288065))
            {
                return;
            }
            Quaternion        deployedRotation = this.GetDeployedRotation(((RaycastHit) ref raycastHit).get_normal(), ((Ray) ref ray).get_direction());
            Item              ownerItem        = this.GetOwnerItem();
            ItemModDeployable modDeployable    = this.GetModDeployable();
            BaseEntity        entity           = GameManager.server.CreateEntity(modDeployable.entityPrefab.resourcePath, ((RaycastHit) ref raycastHit).get_point(), deployedRotation, true);
            if (!Object.op_Implicit((Object)entity))
            {
                Debug.LogWarning((object)("Couldn't create prefab:" + modDeployable.entityPrefab.resourcePath));
            }
            else
            {
                entity.skinID = ownerItem.skin;
                ((Component)entity).SendMessage("SetDeployedBy", (object)ownerPlayer, (SendMessageOptions)1);
                entity.OwnerID = ownerPlayer.userID;
                entity.Spawn();
                modDeployable.OnDeployed(entity, ownerPlayer);
                Interface.CallHook("OnItemDeployed", (object)this, (object)entity);
                this.UseItemAmount(1);
            }
        }
    }
Beispiel #16
0
        void Repair(BaseCombatEntity entity, BasePlayer player)
        {
            if (player.CanBuild())
            {
                if (_allowHandyManFixMessage)
                {
                    SendChatMessage(player, msg("Fix", player.UserIDString));
                    _allowHandyManFixMessage = false;
                }

                RepairAOE(entity, player);
            }
            else
            {
                SendChatMessage(player, msg("NotAllowed", player.UserIDString));
            }
        }
Beispiel #17
0
    public void RPC_Rotate(BaseEntity.RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!player.CanBuild() || !Object.op_Implicit((Object)player.GetHeldEntity()) || !Object.op_Inequality((Object)((Component)player.GetHeldEntity()).GetComponent <Hammer>(), (Object)null))
        {
            return;
        }
        ((Component)this).get_transform().set_rotation(Quaternion.LookRotation(Vector3.op_UnaryNegation(((Component)this).get_transform().get_forward()), ((Component)this).get_transform().get_up()));
        this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        Deployable component = (Deployable)((Component)this).GetComponent <Deployable>();

        if (!((PrefabAttribute)component != (PrefabAttribute)null))
        {
            return;
        }
        Effect.server.Run(component.placeEffect.resourcePath, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, false);
    }
Beispiel #18
0
        private void playerTraps(BasePlayer player, int trap)
        {
            var box = findBox(player);

            if (box != null)
            {
                if (currentTraps.ContainsKey(box.net.ID))
                {
                    SendReply(player, lang.GetMessage("title", this, player.UserIDString) + lang.GetMessage("alreadyTrapped", this, player.UserIDString));
                    return;
                }
                var name = convertToName(trap.ToString());
                if (canBoobyTrapAdmin(player))
                {
                    addTrap(player, box, trap);
                    return;
                }
                if (useOwners)
                {
                    var owner = box.OwnerID;
                    if (owner == 0 || owner == player.userID)
                    {
                        chargeTraps(player, box, trap);
                        return;
                    }
                    if (owner != player.userID)
                    {
                        SendReply(player, lang.GetMessage("title", this, player.UserIDString) + lang.GetMessage("notYourBox", this, player.UserIDString));
                        return;
                    }
                }
                if (buildingPriv)
                {
                    if (!player.CanBuild())
                    {
                        SendReply(player, lang.GetMessage("title", this, player.UserIDString) + lang.GetMessage("noPrivs", this, player.UserIDString));
                        return;
                    }
                }
                chargeTraps(player, box, trap);
                return;
            }
            SendReply(player, lang.GetMessage("title", this, player.UserIDString) + lang.GetMessage("noBox", this, player.UserIDString));
        }
            private bool CanOpenCodeLock(CodeLock door, BasePlayer player)
            {
                bool canUse    = false;
                var  whitelist = door.whitelistPlayers;

                canUse = whitelist.Contains(player.userID);

                if (!canUse)
                {
                    canUse = (player.CanBuild() && checker.IsPlayerAuthorized());
                    if (canUse && handler.ClansAvailable())
                    {
                        canUse = handler.IsInClan(player);
                    }
                }

                PlaySound(canUse, door, player);
                return(canUse);
            }
Beispiel #20
0
    public void UpdatePassthroughAmount()
    {
        if (this.isClient)
        {
            return;
        }
        int detectedPlayers = this.detectedPlayers;

        this.detectedPlayers = 0;
        if (this.myTrigger.entityContents != null)
        {
            foreach (BaseEntity entityContent in this.myTrigger.entityContents)
            {
                if (!Object.op_Equality((Object)entityContent, (Object)null) && entityContent.IsVisible(Vector3.op_Addition(((Component)this).get_transform().get_position(), Vector3.op_Multiply(((Component)this).get_transform().get_forward(), 0.1f)), 10f))
                {
                    BasePlayer component = (BasePlayer)((Component)entityContent).GetComponent <BasePlayer>();
                    bool       flag      = component.CanBuild();
                    if ((!flag || this.ShouldIncludeAuthorized()) && (flag || this.ShouldIncludeOthers()) && (Object.op_Inequality((Object)component, (Object)null) && component.IsAlive() && (!component.IsSleeping() && component.isServer)))
                    {
                        ++this.detectedPlayers;
                    }
                }
            }
        }
        if (detectedPlayers == this.detectedPlayers || !this.IsPowered())
        {
            return;
        }
        this.MarkDirty();
        if (this.detectedPlayers > detectedPlayers)
        {
            Effect.server.Run(this.detectUp.resourcePath, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, false);
        }
        else
        {
            if (this.detectedPlayers >= detectedPlayers)
            {
                return;
            }
            Effect.server.Run(this.detectDown.resourcePath, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, false);
        }
    }
Beispiel #21
0
    public void SetBranchOffPower(BaseEntity.RPCMessage msg)
    {
        BasePlayer basePlayer = msg.player;

        if (basePlayer == null || !basePlayer.CanBuild())
        {
            return;
        }
        if (UnityEngine.Time.time < this.nextChangeTime)
        {
            return;
        }
        this.nextChangeTime = UnityEngine.Time.time + 1f;
        int num = msg.read.Int32();

        this.branchAmount = Mathf.Clamp(num, 2, 10000000);
        Debug.Log(string.Concat("new branch power : ", this.branchAmount));
        base.MarkDirtyForceUpdateOutputs();
        base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }
Beispiel #22
0
    public void UpdatePassthroughAmount()
    {
        if (base.isClient)
        {
            return;
        }
        int num = detectedPlayers;

        detectedPlayers = 0;
        if (myTrigger.entityContents != null)
        {
            foreach (BaseEntity entityContent in myTrigger.entityContents)
            {
                if (entityContent == null || !entityContent.IsVisible(base.transform.position + base.transform.forward * 0.1f, 10f))
                {
                    continue;
                }
                BasePlayer component = entityContent.GetComponent <BasePlayer>();
                if (Interface.CallHook("OnSensorDetect", this, component) == null)
                {
                    bool flag = component.CanBuild();
                    if ((!flag || ShouldIncludeAuthorized()) && (flag || ShouldIncludeOthers()) && component != null && component.IsAlive() && !component.IsSleeping() && component.isServer)
                    {
                        detectedPlayers++;
                    }
                }
            }
        }
        if (num != detectedPlayers && IsPowered())
        {
            MarkDirty();
            if (detectedPlayers > num)
            {
                Effect.server.Run(detectUp.resourcePath, base.transform.position, Vector3.up);
            }
            else if (detectedPlayers < num)
            {
                Effect.server.Run(detectDown.resourcePath, base.transform.position, Vector3.up);
            }
        }
    }
Beispiel #23
0
    public void RPC_Rotate(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (player.CanBuild() && (bool)player.GetHeldEntity() && player.GetHeldEntity().GetComponent <Hammer>() != null && (GetSlot(Slot.Lock) == null || !GetSlot(Slot.Lock).IsLocked()))
        {
            base.transform.rotation = Quaternion.LookRotation(-base.transform.forward, base.transform.up);
            SendNetworkUpdate();
            Deployable component = GetComponent <Deployable>();
            if (component != null && component.placeEffect.isValid)
            {
                Effect.server.Run(component.placeEffect.resourcePath, base.transform.position, Vector3.up);
            }
        }
        BaseEntity slot = GetSlot(Slot.Lock);

        if (slot != null)
        {
            slot.SendNetworkUpdate();
        }
    }
Beispiel #24
0
        private bool CanPickup(BaseEntity entity, BasePlayer player)
        {
            if (entity.OwnerID == 0 || !player.CanBuild())
            {
                return(false);
            }

            var name = entity.ShortPrefabName;

            if (config.blocked.Contains(name))
            {
                return(false);
            }

            if (entity.HasAnySlot())
            {
                return(false);
            }

            var container = entity.GetComponent <StorageContainer>();

            if (container != null && container?.inventory.itemList.Count > 0)
            {
                return(false);
            }

            var combat = entity.GetComponent <BaseCombatEntity>();

            if (combat != null && combat.SecondsSinceAttacked < 30f)
            {
                return(false);
            }

            if (entities.ContainsKey(entity.net.ID))
            {
                return(Passed(entities[entity.net.ID]) < config.pickupTime);
            }

            return(config.pickupTime == 0);
        }
Beispiel #25
0
    public void UpdatePassthroughAmount()
    {
        if (base.isClient)
        {
            return;
        }
        int num = this.detectedPlayers;

        this.detectedPlayers = 0;
        if (this.myTrigger.entityContents != null)
        {
            foreach (BaseEntity entityContent in this.myTrigger.entityContents)
            {
                if (entityContent == null || !entityContent.IsVisible(base.transform.position + (base.transform.forward * 0.1f), 10f))
                {
                    continue;
                }
                BasePlayer component = entityContent.GetComponent <BasePlayer>();
                bool       flag      = component.CanBuild();
                if (flag && !this.ShouldIncludeAuthorized() || !flag && !this.ShouldIncludeOthers() || !(component != null) || !component.IsAlive() || component.IsSleeping() || !component.isServer)
                {
                    continue;
                }
                this.detectedPlayers++;
            }
        }
        if (num != this.detectedPlayers && this.IsPowered())
        {
            this.MarkDirty();
            if (this.detectedPlayers > num)
            {
                Effect.server.Run(this.detectUp.resourcePath, base.transform.position, Vector3.up, null, false);
                return;
            }
            if (this.detectedPlayers < num)
            {
                Effect.server.Run(this.detectDown.resourcePath, base.transform.position, Vector3.up, null, false);
            }
        }
    }
    public virtual bool CanPickup(BasePlayer player)
    {
        object obj = Interface.CallHook("CanPickupEntity", player, this);

        if (obj is bool)
        {
            return((bool)obj);
        }
        if (pickup.enabled)
        {
            if (!pickup.requireBuildingPrivilege || player.CanBuild())
            {
                if (pickup.requireHammer)
                {
                    return(player.IsHoldingEntity <Hammer>());
                }
                return(true);
            }
            return(false);
        }
        return(false);
    }
Beispiel #27
0
            private bool canOpenCodeLock(CodeLock door, BasePlayer player)
            {
                bool canUse = false;
                //Have to do this due to Facepunch not overriding their own method called HasLockPermission()
                var whitelist = (List <ulong>)whiteListField.GetValue(door);

                if (whitelist.Contains(player.userID))
                {
                    canUse = true;
                }
                else
                {
                    canUse = (player.CanBuild() && checker.isPlayerAuthorized());
                    if (canUse && handler.clansAvailable())
                    {
                        canUse = handler.isInClan(player);
                    }
                }

                playSound(canUse, door, player);
                return(canUse);
            }
Beispiel #28
0
 public void Server_SetDir(RPCMessage msg)
 {
     if (!IsStatic())
     {
         BasePlayer player = msg.player;
         if (player.CanBuild() && player.IsBuildingAuthed() && Interface.CallHook("OnCCTVDirectionChange", this, player) == null)
         {
             Vector3 direction = Vector3Ex.Direction(player.eyes.position, yaw.transform.position);
             direction = base.transform.InverseTransformDirection(direction);
             Vector3 vector = BaseMountable.ConvertVector(Quaternion.LookRotation(direction).eulerAngles);
             pitchAmount = vector.x;
             yawAmount   = vector.y;
             pitchAmount = Mathf.Clamp(pitchAmount, pitchClamp.x, pitchClamp.y);
             yawAmount   = Mathf.Clamp(yawAmount, yawClamp.x, yawClamp.y);
             Quaternion localRotation  = Quaternion.Euler(pitchAmount, 0f, 0f);
             Quaternion localRotation2 = Quaternion.Euler(0f, yawAmount, 0f);
             pitch.transform.localRotation = localRotation;
             yaw.transform.localRotation   = localRotation2;
             SendNetworkUpdate();
         }
     }
 }
Beispiel #29
0
    public virtual bool CanUpdateSign(BasePlayer player)
    {
        object obj = Interface.CallHook("CanUpdateSign", player, this);

        if (obj as bool)
        {
            return((bool)obj);
        }
        if (player.IsAdmin || player.IsDeveloper)
        {
            return(true);
        }
        if (!player.CanBuild())
        {
            return(false);
        }
        if (!base.IsLocked())
        {
            return(true);
        }
        return(player.userID == base.OwnerID);
    }
Beispiel #30
0
    public virtual bool CanUpdateSign(BasePlayer player)
    {
        object obj = Interface.CallHook(nameof(CanUpdateSign), (object)player, (object)this);

        if (obj is bool)
        {
            return((bool)obj);
        }
        if (player.IsAdmin || player.IsDeveloper)
        {
            return(true);
        }
        if (!player.CanBuild())
        {
            return(false);
        }
        if (this.IsLocked())
        {
            return((long)player.userID == (long)this.OwnerID);
        }
        return(true);
    }
        void OnStructureRepair(BaseCombatEntity entity, BasePlayer player)
        {
            BuildingBlock block = entity as BuildingBlock;

            if (PlayerHasFlag(player.userID, PlayerFlags.PLUGIN_DISABLED) || block == null)
                return;

            if (playersInfo[player.userID].upgradeInfo == BuildingGrade.Enum.Count
                || playersInfo[player.userID].upgradeInfo <= block.currentGrade.gradeBase.type
                || !player.CanBuild())
            {
                if (playersInfo[player.userID].upgradeInfo != BuildingGrade.Enum.Count && playersInfo[player.userID].upgradeInfo <= block.currentGrade.gradeBase.type)
                {
                    if(!PlayerHasFlag(player.userID, PlayerFlags.MESSAGES_DISABLED))
                        SendReply(player, pluginPrefix + "You are now in REPAIR mode.");
                    playersInfo[player.userID].upgradeInfo = BuildingGrade.Enum.Count;
                    RenderMode(player, true);
                }
                else if (!player.CanBuild())
                {
                    SendReply(player, pluginPrefix + "Building is blocked!");
                }
            }
            else
            {
                BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
                MethodInfo dynMethod = block.GetType().GetMethod("CanChangeToGrade", flags);
                bool canChangeGrade = (bool)dynMethod.Invoke(block, new object[] { playersInfo[player.userID].upgradeInfo, player });

                if (!canChangeGrade)
                {
                    SendReply(player, pluginPrefix + "You can't upgrade it, something is blocking it's way.");
                    return;
                }

                if (block.name.ToLower().Contains("wall.external"))
                {
                    SendReply(player, pluginPrefix + "Can't upgrade walls! Switching to REPAIR mode.");
                    playersInfo[player.userID].upgradeInfo = BuildingGrade.Enum.Count;
                    return;
                }
                float currentHealth = block.health;
                var currentGradeType = block.currentGrade.gradeBase.type;
                block.SetGrade(playersInfo[player.userID].upgradeInfo);
                var TwigsDecay = plugins.Find("TwigsDecay");
                TwigsDecay?.Call("OnStructureUpgrade", block, player, playersInfo[player.userID].upgradeInfo);
				block.UpdateSkin(false);
                var cost = block.currentGrade.gradeBase.baseCost;
                int hasEnough = 0;
                foreach (var itemCost in cost)
                {
                    int itemCostAmount = Convert.ToInt32((float)itemCost.amount*block.blockDefinition.costMultiplier);
                    var foundItems = player.inventory.FindItemIDs(itemCost.itemid);
                    var amountFound = foundItems?.Sum(item => item.amount) ?? 0;
                    if (amountFound >= itemCostAmount)
                        hasEnough++;
                }
                if (hasEnough >= cost.Count)
                {
                    foreach (var itemCost in cost)
                    {
                        int itemCostAmount = Convert.ToInt32((float)itemCost.amount * block.blockDefinition.costMultiplier);
                        var foundItems = player.inventory.FindItemIDs(itemCost.itemid);
                        player.inventory.Take(foundItems, itemCost.itemid, itemCostAmount);
                    }
                    block.SetHealthToMax();
                    block.SetFlag(BaseEntity.Flags.Reserved1, true); // refresh rotation
                    block.Invoke("StopBeingRotatable", 600f);
                    Effect.server.Run("assets/bundled/prefabs/fx/build/promote_" + playersInfo[player.userID].upgradeInfo.ToString().ToLower() + ".prefab", block, 0u, Vector3.zero, Vector3.zero, null, false);
                }
                else
                {
                    block.SetGrade(currentGradeType);
                    TwigsDecay?.Call("OnStructureUpgrade", block, player, currentGradeType);
                    block.UpdateSkin(false);
                    block.health = currentHealth;
                    SendReply(player, pluginPrefix + "Can't afford to upgrade!");
                }
            }

            RefreshTimer(player);
        }