Пример #1
0
        static void OnChangeSlotItemRequest(ref PlayerToolbarChangeSlotMsg msg, MyNetworkClient sender)
        {
            var playerId = new PlayerId(sender.SteamUserId, msg.PlayerSerialId);

            if (!MySession.Static.Toolbars.ContainsToolbar(playerId))
            {
                return;
            }

            MyDefinitionBase def;

            MyDefinitionManager.Static.TryGetDefinition(msg.DefId, out def);
            if (def == null)
            {
                return;
            }

            var ob      = MyToolbarItemFactory.ObjectBuilderFromDefinition(def);
            var tItem   = MyToolbarItemFactory.CreateToolbarItem(ob);
            var toolbar = MySession.Static.Toolbars.TryGetPlayerToolbar(playerId);

            if (toolbar == null)
            {
                return;
            }
            toolbar.SetItemAtIndex(msg.Index, tItem);
        }
Пример #2
0
        static void OnChangeSlotItemRequest(int playerSerialId, int index, DefinitionIdBlit defId)
        {
            ulong senderId = GetSenderIdSafe();
            var   playerId = new PlayerId(senderId, playerSerialId);

            if (!MySession.Static.Toolbars.ContainsToolbar(playerId))
            {
                return;
            }

            MyDefinitionBase def;

            MyDefinitionManager.Static.TryGetDefinition(defId, out def);
            if (def == null)
            {
                return;
            }

            var ob      = MyToolbarItemFactory.ObjectBuilderFromDefinition(def);
            var tItem   = MyToolbarItemFactory.CreateToolbarItem(ob);
            var toolbar = MySession.Static.Toolbars.TryGetPlayerToolbar(playerId);

            if (toolbar == null)
            {
                return;
            }
            toolbar.SetItemAtIndex(index, tItem);
        }