Пример #1
0
        private void Start()
        {
            init = true;

            if (IsServer)
            {
                MyVisualScriptLogicProvider.PlayerDropped  += ItemDropped;
                MyVisualScriptLogicProvider.PlayerPickedUp += ItemPickedUp;
                MyVisualScriptLogicProvider.PlayerSpawned  += PlayerSpawned;
            }
            else
            {
                MyAPIGateway.Multiplayer.RegisterSecureMessageHandler(EventPacket.PacketId, EventPacket.Received);
            }

            if (IsClient)
            {
                config = ToolGroups.Load();
                MyVisualScriptLogicProvider.ToolbarItemChanged += ToolbarItemChanged;
                if (!MyAPIGateway.Session.CreativeMode)
                {
                    equipAll = true;
                }
            }
        }
Пример #2
0
 public ToolMenu(HudAPIv2.MenuCategoryBase category, Tool tool, ToolGroups config)
 {
     this.tool    = tool;
     this.config  = config;
     toolCategory = new HudAPIv2.MenuSubCategory("", category, tool.Name);
     SetCategoryText();
     keyInput   = new HudAPIv2.MenuKeybindInput("Key - " + ToolSwitcherSession.GetKeyName(tool.Keybind), toolCategory, "Press any key.", OnKeySubmit);
     slotInput  = new HudAPIv2.MenuTextInput("Slot - " + (tool.Slot + 1), toolCategory, "Enter a slot number 1-9.", OnSlotSubmit);
     pageInput  = new HudAPIv2.MenuTextInput("Page - " + (tool.Page + 1), toolCategory, "Enter a page number 1-9.", OnPageSubmit);
     btnEnabled = new HudAPIv2.MenuItem("Enabled - " + tool.Enabled, toolCategory, OnEnabledSubmit);
 }
        /// <summary>
        /// Clean up all child objects here, unlink all events and dispose
        /// </summary>
        protected override void DisposeChildObjects()
        {
            base.DisposeChildObjects();

            if (Tools != null)
            {
                foreach (PlugInTool pTool in Tools)
                {
                    pTool.ShutDown();
                    pTool.Dispose();
                }
                Tools.Clear();
                Tools = null;
            }

            if (ToolGroups != null)
            {
                foreach (PlugInToolGroup pToolGroup in ToolGroups)
                {
                    pToolGroup.ShutDown();
                    pToolGroup.Dispose();
                }
                ToolGroups.Clear();
                ToolGroups = null;
            }

            if (_tempFiles != null)
            {
                foreach (string tempFileName in _tempFiles)
                {
                    File.Delete(tempFileName);
                }
                _tempFiles.Clear();
                _tempFiles = null;
            }

            UI?.Dispose();
        }
Пример #4
0
            public void Do(ToolGroups config)
            {
                Tool      t;
                ToolGroup tg;
                int       index;

                if (config.ModEnabled && config.TryGetTool(id, out t, out index, out tg) && t.Enabled)
                {
                    if (tg.IsSlot(page, slot))
                    {
                        if (MyAPIGateway.Session.CreativeMode)
                        {
                            t.EquipIndex = index;
                        }

                        t.Equip();
                    }
                    else
                    {
                        if (MyAPIGateway.Session.CreativeMode)
                        {
                            t.EquipIndex = index;
                        }

                        t.ClearSlot();
                        t.Page = page;
                        t.Slot = slot;
                        if (t.Menu != null)
                        {
                            t.Menu.SlotUpdated();
                        }
                        config.ToolEdited(t, true);
                        config.Save();
                    }
                }
            }