Exemple #1
0
        protected override void UpdateAfterSim(int tick)
        {
            if (spawnedRifles.Count > 0)
            {
                for (int i = spawnedRifles.Count - 1; i >= 0; --i)
                {
                    IMyAutomaticRifleGun rifle = spawnedRifles[i];

                    if (!rifle.MarkedForClose && rifle.Owner != null)
                    {
                        AddTool(rifle);
                    }
                }

                spawnedRifles.Clear();

                if (Tools.Count == 0)
                {
                    SetUpdateMethods(UPDATE_METHODS, false);
                }
            }

            for (int i = Tools.Count - 1; i >= 0; --i)
            {
                PaintGunItem item = Tools[i];

                if (!item.UpdateSimulation())
                {
                    RemoveTool(item, i);
                    continue;
                }
            }
        }
Exemple #2
0
 void ToolRemoved(PaintGunItem item)
 {
     if (LocalTool != null && LocalTool == item)
     {
         HandleTool_Holstered();
         LocalToolHolstered?.Invoke(item);
     }
 }
Exemple #3
0
 void ToolSpawned(PaintGunItem item)
 {
     if (item.OwnerIsLocalPlayer)
     {
         LocalTool = item;
         LocalToolEquipped?.Invoke(item);
     }
 }
Exemple #4
0
        public PaintGunItem GetToolHeldBy(ulong steamId)
        {
            for (int i = Tools.Count - 1; i >= 0; --i)
            {
                PaintGunItem tool = Tools[i];

                if (tool.OwnerSteamId == steamId)
                {
                    return(tool);
                }
            }

            return(null);
        }
Exemple #5
0
        void AddTool(IMyAutomaticRifleGun rifle)
        {
            PaintGunItem item = itemPool.Get();

            if (!item.Init(rifle))
            {
                itemPool.Return(item);
                return;
            }

            Tools.Add(item);
            ToolSpawned?.Invoke(item);

            SetUpdateMethods(UPDATE_METHODS, true);
        }
Exemple #6
0
        void RemoveTool(PaintGunItem item, int index)
        {
            ToolRemoved?.Invoke(item);

            Tools.RemoveAtFast(index);
            itemPool.Return(item);

            if (Tools.Count == 0)
            {
                SetUpdateMethods(UpdateFlags.UPDATE_DRAW, false);

                if (spawnedRifles.Count == 0)
                {
                    SetUpdateMethods(UpdateFlags.UPDATE_AFTER_SIM, false);
                }
            }
        }
Exemple #7
0
        void HandleTool_Holstered()
        {
            if (Main.Palette.ColorPickMode)
            {
                Main.Palette.ColorPickMode = false;
                Main.Notifications.Show(0, "Color picking cancelled.", MyFontEnum.Debug, 2000);
                Main.HUDSounds.PlayUnable();
            }

            if (Main.Palette.ReplaceMode)
            {
                Main.Palette.ReplaceMode = false;
                Main.Notifications.Show(0, "Replace color mode turned off.", MyFontEnum.Debug, 2000);
            }

            LocalTool = null;
            SymmetryInputAvailable = false;
            AimedBlock             = null;
            AimedPlayer            = null;
            AimedState             = SelectionState.Invalid;
        }
 void LocalToolEquipped(PaintGunItem item)
 {
     Refresh();
 }
Exemple #9
0
 void LocalToolHolstered(PaintGunItem item)
 {
     LocalBBCache.Clear();
     LastAimedBlock = null;
     SetGUIVisible(false);
 }