Esempio n. 1
0
        public UIInventorySlot(ClientInventory inventory, byte slotId, Action <UIEvent, byte> clickAction = null, Action <UIEvent, byte> enterAction = null, bool hotBarMode = false) : base(nameof(UIInventorySlot))
        {
            _inventory  = inventory;
            _slotId     = slotId;
            _hover      = false;
            _hotBarMode = hotBarMode;

            Color color = _hotBarMode ? Color.Black : Color.Silver;

            this.AspectRatio(1)
            .Background(new Color(0, 0, 0, 0.5f))
            .Border(3, color)
            .FontSize(0.5f);

            AddEvent("click", e =>
            {
                clickAction?.Invoke(e, slotId);
            });
            AddEvent("hover", e =>
            {
                RenderAttributes = DefaultAttributes.CascadeAttributes(new UIAttributes
                {
                    Background = new Color(0, 0, 0, 0.2f)
                });
            });
            AddEvent("mouseenter", e =>
            {
                enterAction?.Invoke(e, _slotId);
                _hover = true;
            });
            AddEvent("mouseleave", e => _hover = false);
        }
        public void ClearInstance()
        {
            GameReady = false;
            Client    = null;
            Entities.Clear();
            Entities  = null;
            World     = null;
            Inventory = null;

            _instance = null;
        }
        private ClientDataRegistry()
        {
            GameReady = false;
            World     = new WorldManager(new WorldOptions
            {
                ChunkSize        = 16,
                WorldChunkWidth  = 1,
                WorldChunkHeight = 1,
                WorldScale       = 30,
                WorldGenerator   = options => new RemoteWorld(options)
            });

            Entities  = new Dictionary <string, ClientEntity>();
            Inventory = new ClientInventory();
        }
 public static UIComponent InventorySlot(this UIComponent component, ClientInventory inventory, byte slotId, Action <UIEvent, byte> clickAction = null, Action <UIEvent, byte> enterAction = null, bool hotBarMode = false)
 {
     return(AddNode(component, new UIInventorySlot(inventory, slotId, clickAction, enterAction, hotBarMode), null));
 }