private void RemoveAttachedControl() { if (this.componentAttachedUIElement == null) { return; } this.componentAttachedUIElement.Destroy(); this.componentAttachedUIElement = null; ControlsCache <StructurePointsBarControl> .Instance.Push(this.structurePointsBarControl); this.structurePointsBarControl = null; }
private void RefreshBarControl() { if (!this.isDamaged) { this.RemoveAttachedControl(); return; } var isBarVisible = this.CheckIsBarShouldBeVisible(); if (!isBarVisible) { this.RemoveAttachedControl(); return; } if (this.componentAttachedUIElement != null) { return; } var protoStaticWorldObject = this.data.ProtoStaticWorldObject; var structurePointsCurrent = this.data.State.StructurePointsCurrent; this.structurePointsBarControl = ControlsCache <StructurePointsBarControl> .Instance.Pop(); this.structurePointsBarControl.Setup(this.data, this.lastStructurePoints ?? structurePointsCurrent); var offset = protoStaticWorldObject.SharedGetObjectCenterWorldOffset( this.SceneObject.AttachedWorldObject); this.componentAttachedUIElement = Api.Client.UI.AttachControl( this.SceneObject, this.structurePointsBarControl, positionOffset: offset + (0, 0.55), isFocusable: false); }