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; } } }
void ToolRemoved(PaintGunItem item) { if (LocalTool != null && LocalTool == item) { HandleTool_Holstered(); LocalToolHolstered?.Invoke(item); } }
void ToolSpawned(PaintGunItem item) { if (item.OwnerIsLocalPlayer) { LocalTool = item; LocalToolEquipped?.Invoke(item); } }
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); }
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); }
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); } } }
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(); }
void LocalToolHolstered(PaintGunItem item) { LocalBBCache.Clear(); LastAimedBlock = null; SetGUIVisible(false); }