private void HandlePlayerAttached(PlayerAttachSysMessage msg) { if (msg.AttachedEntity == null) { _gameHud.CraftingButtonVisible = false; return; } if (_constructionMenu == null) { _constructionMenu = new ConstructionMenu(); _constructionMenu.OnClose += () => _gameHud.CraftingButtonDown = false; } _gameHud.CraftingButtonVisible = true; _gameHud.CraftingButtonToggled = b => { if (b) { _constructionMenu.Open(); } else { _constructionMenu.Close(); } }; }
void Awake() { if (Instance != null) { if (Instance != this) Destroy(this); return; } Instance = this; }
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null) { base.HandleMessage(message, netChannel, component); switch (message) { case PlayerAttachedMsg _: if (ConstructionMenu == null) { ConstructionMenu = new ConstructionMenu { Owner = this }; ConstructionMenu.OnClose += () => _gameHud.CraftingButtonDown = false; } _gameHud.CraftingButtonVisible = true; _gameHud.CraftingButtonToggled = b => { if (b) { ConstructionMenu.Open(); } else { ConstructionMenu.Close(); } }; break; case PlayerDetachedMsg _: _gameHud.CraftingButtonVisible = false; break; case AckStructureConstructionMessage ackMsg: ClearGhost(ackMsg.Ack); break; } }
public override void HandleMessage(ComponentMessage message, IComponent component) { base.HandleMessage(message, component); switch (message) { case PlayerAttachedMsg _: if (ConstructionMenu == null) { ConstructionMenu = new ConstructionMenu { Owner = this }; ConstructionMenu.OnClose += () => _gameHud.CraftingButtonDown = false; } _gameHud.CraftingButtonVisible = true; _gameHud.CraftingButtonToggled = b => { if (b) { ConstructionMenu.Open(); } else { ConstructionMenu.Close(); } }; break; case PlayerDetachedMsg _: _gameHud.CraftingButtonVisible = false; break; default: break; } }
public void SetupEverything() { construction = GetComponentInParent <ConstructionMenu>(); correspodingSpawnable = GameObject.FindObjectOfType <GameManager>().GetBlueprint(type, id); createdPopup = construction.GetPopup(); }