예제 #1
0
        private void RemoveAttachedControl()
        {
            if (this.componentAttachedUIElement == null)
            {
                return;
            }

            this.componentAttachedUIElement.Destroy();
            this.componentAttachedUIElement = null;
            ControlsCache <StructurePointsBarControl> .Instance.Push(this.structurePointsBarControl);

            this.structurePointsBarControl = null;
        }
예제 #2
0
        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);
        }