Esempio n. 1
0
    public bool CheckAccess(GameObject Player)
    {
        // If there isn't any restriction, grant access right away
        if ((int)restriction == 0)
        {
            return(true);
        }


        ItemStorage playerStorage = Player.GetComponent <ItemStorage>();

        //this isn't a player. It could be an npc. No NPC access logic at the moment
        if (playerStorage == null)
        {
            return(false);
        }


        //check if active hand or equipped id cards have access
        if (CheckAccessCard(playerStorage.GetNamedItemSlot(NamedSlot.id).ItemObject))
        {
            return(true);
        }

        return(CheckAccessCard(playerStorage.GetActiveHandSlot().ItemObject));
    }
Esempio n. 2
0
        private void TryAddMark()
        {
            ItemStorage playerStorage = caster.Script.ItemStorage;

            ItemSlot activeHand = playerStorage.GetActiveHandSlot();

            if (activeHand.IsOccupied)
            {
                AddMark(activeHand.Item);
            }

            ItemSlot leftHand = playerStorage.GetNamedItemSlot(NamedSlot.leftHand);

            if (leftHand != activeHand && leftHand.IsOccupied)
            {
                AddMark(leftHand.Item);
            }
            ItemSlot rightHand = playerStorage.GetNamedItemSlot(NamedSlot.rightHand);

            if (rightHand != activeHand && rightHand.IsOccupied)
            {
                AddMark(rightHand.Item);
            }

            Chat.AddExamineMsgFromServer(caster, "You aren't holding anything that can be marked for recall!");
        }
    public bool CheckAccess(GameObject Player)
    {
        IDCard      card;
        ItemStorage playerStorage = Player.GetComponent <ItemStorage>();

        //this isn't a player. It could be an npc:
        if (playerStorage == null)
        {
            if ((int)restriction == 0)
            {
                return(true);
            }
            return(false);
        }

        // Check for an ID card
        var idId   = playerStorage.GetNamedItemSlot(NamedSlot.id).ItemObject;
        var handId = playerStorage.GetActiveHandSlot().ItemObject;

        if (idId != null && idId.GetComponent <IDCard>() != null)
        {
            card = idId.GetComponent <IDCard>();
        }
        else if (handId != null &&
                 handId.GetComponent <IDCard>() != null)
        {
            card = handId.GetComponent <IDCard>();
        }
        else
        {
            // If there isn't one, see if we even need one
            if ((int)restriction == 0)
            {
                return(true);
            }
            // If there isn't one and we don't need one, we don't open the door
            return(false);
        }

        // If we have an ID, make sure we have access
        if ((int)restriction == 0)
        {
            return(true);
        }
        if (card.accessSyncList.Contains((int)restriction))
        {
            return(true);
        }
        return(false);
    }
Esempio n. 4
0
        /// <summary>
        /// Calculates the player's total resistance using a base humanoid resistance value,
        /// their health and the items the performer is wearing or holding.
        /// Assumes the player is a humanoid.
        /// </summary>
        /// <param name="voltage">The potential difference across the player</param>
        /// <returns>float resistance</returns>
        protected override float ApproximateElectricalResistance(float voltage)
        {
            // Assume the player is a humanoid
            float resistance = GetNakedHumanoidElectricalResistance(voltage);

            // Give the humanoid extra/less electrical resistance based on what they're holding/wearing
            resistance += Electrocution.GetItemElectricalResistance(itemStorage.GetNamedItemSlot(NamedSlot.hands).ItemObject);
            resistance += Electrocution.GetItemElectricalResistance(itemStorage.GetNamedItemSlot(NamedSlot.feet).ItemObject);
            // A solid grip on a conductive item will reduce resistance - assuming it is conductive.
            if (itemStorage.GetActiveHandSlot().Item != null)
            {
                resistance -= 300;
            }

            // Broken skin reduces electrical resistance - arbitrarily chosen at 4 to 1.
            resistance -= 4 * GetTotalBruteDamage();

            // Make sure the humanoid doesn't get ridiculous conductivity.
            if (resistance < 100)
            {
                resistance = 100;
            }
            return(resistance);
        }
    public void CmdRequestItemLabel(GameObject handLabeler, string label)
    {
        ItemStorage itemStorage = gameObject.GetComponent <ItemStorage>();
        Pickupable  handItem    = itemStorage.GetActiveHandSlot().Item;

        if (handItem == null)
        {
            return;
        }
        if (handItem.gameObject != handLabeler)
        {
            return;
        }

        Chat.AddExamineMsgFromServer(gameObject, "You set the " + handLabeler.Item().InitialName.ToLower() + "s text to '" + label + "'.");
        handLabeler.GetComponent <HandLabeler>().SetLabel(label);
    }
Esempio n. 6
0
        /// <summary>
        /// Checks to see if it can put it in any hand, if it cant it will do nothing meaning the item should just drop.
        /// </summary>
        /// <param name="player"></param>
        private void HandInsert(ItemStorage player)
        {
            ItemSlot activeHand = player.GetActiveHandSlot();

            if (Inventory.ServerAdd(InsertedContainer, activeHand))
            {
                return;
            }
            switch (activeHand.NamedSlot)
            {
            case NamedSlot.leftHand:
                ItemSlot rSlot = player.GetNamedItemSlot(NamedSlot.rightHand);
                Inventory.ServerAdd(InsertedContainer, rSlot);
                break;

            case NamedSlot.rightHand:
                ItemSlot lSlot = player.GetNamedItemSlot(NamedSlot.leftHand);
                Inventory.ServerAdd(InsertedContainer, lSlot);
                break;
            }
        }