Esempio n. 1
0
    public void AddHand(EntityUid uid, string handName, HandLocation handLocation, SharedHandsComponent?handsComp = null)
    {
        if (!Resolve(uid, ref handsComp, false))
        {
            return;
        }

        if (handsComp.Hands.ContainsKey(handName))
        {
            return;
        }

        var container = _containerSystem.EnsureContainer <ContainerSlot>(uid, handName);

        container.OccludesLight = false;

        var newHand = new Hand(handName, handLocation, container);

        handsComp.Hands.Add(handName, newHand);
        handsComp.SortedHands.Add(handName);

        if (handsComp.ActiveHand == null)
        {
            SetActiveHand(uid, newHand, handsComp);
        }

        RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
        Dirty(handsComp);
    }
Esempio n. 2
0
    void SetHandLocation(HandLocation loc)
    {
        if (loc != handLocation)
        {
            // if(handLocation == HandLocation.Far) ShowSphere();
            // if(loc == HandLocation.Far) HideSphere();
            //location has changed
            handLocation = loc;


            switch (handLocation)
            {
            case HandLocation.Far:
                line.Hide();
                HideSphere();
                break;

            case HandLocation.Close:
                ShowSphere();
                line.Show();
                break;

            default:
                break;
            }
        }
        else
        {
            return;
        }
    }
 public SharedHand(int index, string name, EntityUid?entityUid, HandLocation location)
 {
     Index     = index;
     Name      = name;
     EntityUid = entityUid;
     Location  = location;
 }
 public SharedHand(int index, string name, EntityUid?entityUid, HandLocation location, bool enabled)
 {
     Index     = index;
     Name      = name;
     EntityUid = entityUid;
     Location  = location;
     Enabled   = enabled;
 }
 static int Map(HandLocation loc)
 {
     return(loc switch
     {
         HandLocation.Left => 3,
         HandLocation.Middle => 2,
         HandLocation.Right => 1,
         _ => throw new ArgumentOutOfRangeException(nameof(loc), loc, null)
     });
Esempio n. 6
0
        private HandButton MakeHandButton(HandLocation buttonLocation)
        {
            var buttonTextureName = buttonLocation switch
            {
                HandLocation.Right => "hand_r.png",
                _ => "hand_l.png"
            };

            return(new HandButton(ClientInventorySystem.ButtonSize, buttonTextureName, StorageTexture, _gameHud, BlockedTexture, buttonLocation));
        }
Esempio n. 7
0
        public HandButton(Texture texture, Texture storageTexture, string textureName, Texture blockedTexture, HandLocation location) : base(texture, storageTexture, textureName)
        {
            Location = location;

            AddChild(Blocked = new TextureRect
            {
                Texture      = blockedTexture,
                TextureScale = (2, 2),
                MouseFilter  = MouseFilterMode.Stop,
                Visible      = false
            });
        private HandButton MakeHandButton(HandLocation buttonLocation)
        {
            var buttonTextureName = buttonLocation switch
            {
                HandLocation.Right => "hand_r.png",
                _ => "hand_l.png"
            };
            var buttonTexture = _gameHud.GetHudTexture(buttonTextureName);

            return(new HandButton(buttonTexture, StorageTexture, buttonTextureName, BlockedTexture, buttonLocation));
        }
Esempio n. 9
0
        /// <summary>
        ///     Adds a new hand to this control
        /// </summary>
        /// <param name="hand">The hand to add to this control</param>
        /// <param name="buttonLocation">
        ///     The actual location of the button. The right hand is drawn
        ///     on the LEFT of the screen.
        /// </param>
        private void AddHand(Hand hand, HandLocation buttonLocation)
        {
            var buttonTexture  = HandTexture(buttonLocation);
            var storageTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/back.png");
            var blockedTexture = _resourceCache.GetTexture("/Textures/Interface/Inventory/blocked.png");
            var button         = new HandButton(buttonTexture, storageTexture, blockedTexture, buttonLocation);
            var slot           = hand.Name;

            button.OnPressed        += args => HandKeyBindDown(args, slot);
            button.OnStoragePressed += args => _OnStoragePressed(args, slot);

            _handsContainer.AddChild(button);
            hand.Button = button;
        }
Esempio n. 10
0
        private Texture HandTexture(HandLocation location)
        {
            switch (location)
            {
            case HandLocation.Left:
                return(_leftHandTexture);

            case HandLocation.Middle:
                return(_middleHandTexture);

            case HandLocation.Right:
                return(_rightHandTexture);

            default:
                throw new ArgumentOutOfRangeException(nameof(location), location, null);
            }
        }
Esempio n. 11
0
 public SharedHand ToShared(int index, HandLocation location)
 {
     return(new SharedHand(index, Name, Entity?.Uid, location));
 }
Esempio n. 12
0
 public Hand(string name, HandLocation location, ContainerSlot?container = null)
 {
     Name      = name;
     Location  = location;
     Container = container;
 }
 public HandButton(Texture texture, Texture storageTexture, HandLocation location) : base(texture, storageTexture)
 {
     Location = location;
 }
 private string LocationToLayerKey(HandLocation location)
 {
     return(location.ToString());
 }