public override void Refresh() { if (ObjectToDisplay == null) { return; } foreach (var display in ActiveAbilityDisplays) { AbilityDisplayPool.Despawn(display); } ActiveAbilityDisplays.Clear(); var unitOwner = UnitPossessionCanon.GetOwnerOfPossession(ObjectToDisplay); foreach (var ability in ObjectToDisplay.Abilities) { if (!TechCanon.IsAbilityResearchedForCiv(ability, unitOwner) || !AbilityExecuter.CanExecuteAbilityOnUnit(ability, ObjectToDisplay) ) { continue; } var cachedAbility = ability; var newDisplay = AbilityDisplayPool.Spawn(); newDisplay.transform.SetParent(transform, false); newDisplay.UnitToInvokeOn = ObjectToDisplay; newDisplay.AbilityToDisplay = cachedAbility; newDisplay.Refresh(); newDisplay.ExecuteButton.onClick.AddListener(() => this.Refresh()); ActiveAbilityDisplays.Add(newDisplay); } RangedAttackButton.gameObject.SetActive( ObjectToDisplay.CanAttack && ObjectToDisplay.CurrentMovement > 0 && ObjectToDisplay.IsReadyForRangedAttack && ObjectToDisplay.RangedAttackStrength > 0 ); }