Пример #1
0
 public bool Update(EquippedToolAction other)
 {
     if (id != other.id || slot != other.slot)
     {
         return(false);
     }
     // The reason for these shenanigans: Keen's code sometimes uses page=0 in the parameter.
     if (page == 0 && other.page != 0)
     {
         page = other.page;
     }
     return(true);
 }
Пример #2
0
        private void ToolbarItemChanged(long entityId, string typeId, string subtypeId, int page, int slot)
        {
            try
            {
                if (Instance == null)
                {
                    // WTF
                    MyVisualScriptLogicProvider.ToolbarItemChanged -= ToolbarItemChanged;
                    return;
                }

                if (MyAPIGateway.Session.Player == null || !modOverrideEnabled)
                {
                    return;
                }

                MyDefinitionId handId;
                if (config.ModEnabled && IsToolbarCharacter() && MyAPIGateway.Gui.ActiveGamePlayScreen == "MyGuiScreenCubeBuilder" &&
                    typeId == "MyObjectBuilder_PhysicalGunObject" && MyDefinitionId.TryParse(typeId, subtypeId, out handId))
                {
                    EquippedToolAction newToolAction = new EquippedToolAction(handId, page, slot);
                    foreach (EquippedToolAction toolAction in equippedTools)
                    {
                        if (toolAction.Update(newToolAction))
                        {
                            return;
                        }
                    }
                    equippedTools.Add(newToolAction);
                }
            }
            catch (Exception e)
            {
                MyLog.Default.WriteLineAndConsole("ERROR in ToolbarItemChanged(): " + e);
            }
        }