Beispiel #1
0
        protected override void ClientObserving(ClientObjectData data, bool isObserving)
        {
            base.ClientObserving(data, isObserving);

            if (!isObserving)
            {
                this.currentDisplayedTooltip.Destroy();
                this.currentDisplayedTooltip = null;
                return;
            }

            var worldObject = data.GameObject;
            var control     = new BrokenObjectLandClaimTooltip()
            {
                ObjectLandClaim            = worldObject,
                ObjectLandClaimPublicState = data.PublicState,
                VerticalAlignment          = VerticalAlignment.Bottom
            };

            this.currentDisplayedTooltip = Client.UI.AttachControl(
                worldObject,
                control,
                positionOffset: this.SharedGetObjectCenterWorldOffset(
                    worldObject)
                + (0, 0.55),
                isFocusable: false);
        }
Beispiel #2
0
        protected override void ClientObserving(ClientObjectData data, bool isObserving)
        {
            if (!isObserving)
            {
                this.currentDisplayedTooltip.Destroy();
                this.currentDisplayedTooltip = null;
                return;
            }

            var worldObject = data.GameObject;
            var control     = new FarmPlantTooltip
            {
                ObjectPlant       = worldObject,
                PlantPublicState  = data.PublicState,
                VerticalAlignment = VerticalAlignment.Bottom
            };

            this.currentDisplayedTooltip = Client.UI.AttachControl(
                worldObject,
                control,
                positionOffset: this.SharedGetObjectCenterWorldOffset(
                    worldObject)
                + (0, 1.12),
                isFocusable: false);
        }
Beispiel #3
0
        public static void ClientObserving(IStaticWorldObject worldObject, bool isObserving)
        {
            if (isObserving)
            {
                structureLandClaimIndicator = ControlsCache <StructureLandClaimIndicator> .Instance.Pop();

                structureLandClaimIndicator.Setup(
                    isClaimed: LandClaimSystem.SharedIsLandClaimedByAnyone(worldObject.Bounds));

                var offset = worldObject.ProtoStaticWorldObject.SharedGetObjectCenterWorldOffset(worldObject);
                componentStructureLandClaimIndicator = Api.Client.UI.AttachControl(
                    worldObject,
                    structureLandClaimIndicator,
                    positionOffset: offset + (0, 0.3),
                    isFocusable: false);
            }
            else
            {
                componentStructureLandClaimIndicator.Destroy();
                componentStructureLandClaimIndicator = null;
                ControlsCache <StructureLandClaimIndicator> .Instance.Push(structureLandClaimIndicator);

                structureLandClaimIndicator = null;
            }
        }
Beispiel #4
0
        private void Refresh()
        {
            var isBarVisible = this.CheckIsBarShouldBeVisible();

            if (!isBarVisible)
            {
                this.DestroyControl();
                return;
            }

            // health bar should be visible
            if (this.componentHealthbar is not null)
            {
                return;
            }

            // create control
            var protoVehicle       = (IProtoVehicle)this.vehicle.ProtoGameObject;
            var vehiclePublicState = this.vehicle.GetPublicState <VehiclePublicState>();

            var structurePointsBarControl = new VehicleArmorBarControl();

            structurePointsBarControl.Setup(
                new ObjectStructurePointsData(this.vehicle, protoVehicle.SharedGetStructurePointsMax(this.vehicle)),
                vehiclePublicState.StructurePointsCurrent);

            this.componentHealthbar = Api.Client.UI.AttachControl(
                this.vehicle,
                structurePointsBarControl,
                positionOffset: protoVehicle.SharedGetObjectCenterWorldOffset(
                    this.vehicle)
                + (0, 0.545),
                isFocusable: false);
        }
Beispiel #5
0
        protected override void ClientUpdate(ClientUpdateData data)
        {
            base.ClientUpdate(data);

            if (this.currentDisplayedRepairTooltip != null)
            {
                var tooltipDisplayedForObject =
                    ((ConstructionOrRepairRequirementsTooltip)this.currentDisplayedRepairTooltip.Control).WorldObject;
                if (data.GameObject == tooltipDisplayedForObject &&
                    !this.IsConstructionOrRepairRequirementsTooltipShouldBeDisplayed(data.SyncPublicState))
                {
                    // destroy tooltip
                    this.currentDisplayedRepairTooltip?.Destroy();
                    this.currentDisplayedRepairTooltip = null;
                }
            }

            if (this.currentDisplayedRepairTooltip == null &&
                this.IsConstructionOrRepairRequirementsTooltipShouldBeDisplayed(data.SyncPublicState))
            {
                // display tooltip
                var worldObject = data.GameObject;
                this.currentDisplayedRepairTooltip =
                    ConstructionOrRepairRequirementsTooltip.CreateAndAttach(worldObject);
            }
        }
        private void RefreshBarControl()
        {
            var isBarVisible = this.CheckIsBarShouldBeVisible();

            if (!isBarVisible)
            {
                this.RemoveAttachedControl();
                return;
            }

            if (this.componentAttachedUIElement != null)
            {
                return;
            }

            var protoStaticWorldObject = this.data.ProtoStaticWorldObject;

            this.structurePointsBarControl = ControlsCache <ConstructionSiteStructurePointsBarControl> .Instance.Pop();

            this.structurePointsBarControl.StaticObjectStructurePointsData = this.data;

            var offset = protoStaticWorldObject.SharedGetObjectCenterWorldOffset(
                this.SceneObject.AttachedWorldObject);

            this.componentAttachedUIElement = Api.Client.UI.AttachControl(
                this.SceneObject,
                this.structurePointsBarControl,
                positionOffset: offset + (0, 0.55),
                isFocusable: false);
        }
        public sealed override void ClientDeinitialize(IStaticWorldObject gameObject)
        {
            StructureLandClaimIndicatorManager.ClientDeinitialize(gameObject);

            base.ClientDeinitialize(gameObject);

            if (currentDisplayedRepairTooltip != null)
            {
                var tooltipDisplayedForObject =
                    ((ConstructionOrRepairRequirementsTooltip)currentDisplayedRepairTooltip.Control).WorldObject;
                if (ReferenceEquals(gameObject, tooltipDisplayedForObject))
                {
                    // destroy tooltip
                    currentDisplayedRepairTooltip.Destroy();
                    currentDisplayedRepairTooltip = null;
                }
            }

            if (currentDisplayedRelocateTooltip != null)
            {
                var tooltipDisplayedForObject =
                    ((ConstructionRelocationTooltip)currentDisplayedRelocateTooltip.Control).WorldObject;
                if (ReferenceEquals(gameObject, tooltipDisplayedForObject))
                {
                    // destroy tooltip
                    currentDisplayedRelocateTooltip.Destroy();
                    currentDisplayedRelocateTooltip = null;
                }
            }

            this.ClientDeinitializeStructure(gameObject);
        }
        private static void Update()
        {
            IDynamicWorldObject vehicle      = null;
            IProtoVehicle       protoVehicle = null;

            if (ClientHotbarSelectedItemManager.SelectedItem?.ProtoItem
                is IProtoItemVehicleRepairKit &&
                ClientCurrentCharacterHelper.PublicState.CurrentPublicActionState
                is not VehicleRepairActionState.PublicState)
            {
                vehicle      = VehicleRepairKitSystem.ClientGetObjectToRepairAtCurrentMousePosition();
                protoVehicle = vehicle?.ProtoGameObject as IProtoVehicle;
            }

            if (currentTooltipVehicle != vehicle)
            {
                tooltip?.Destroy();
                tooltip = null;
                currentTooltipVehicle = vehicle;
            }

            if (protoVehicle is null)
            {
                return;
            }

            tooltip ??= VehicleRepairKitTooltip.CreateAndAttach(vehicle);
        }
Beispiel #9
0
 static ClientWorldObjectClaimTooltipManager()
 {
     SceneObjectCurrentTagInfo =
         Api.Client.Scene.CreateSceneObject(nameof(ClientWorldObjectClaimTooltipManager));
     controlCurrentObjectDescription   = new WorldObjectClaimTooltip();
     componentCurrentObjectDescription = Api.Client.UI.AttachControl(
         SceneObjectCurrentTagInfo,
         controlCurrentObjectDescription,
         positionOffset: default,
Beispiel #10
0
        private void DestroyControl()
        {
            if (this.componentHealthbar is null)
            {
                return;
            }

            this.componentHealthbar.Destroy();
            this.componentHealthbar = null;
        }
        private void RefreshAttachedComponent()
        {
            this.componentAttachedUIElement?.Destroy();
            this.componentAttachedUIElement = null;

            var actionState = this.privateState.CurrentActionState;

            if (actionState is null ||
                !actionState.IsDisplayingProgress)
            {
                return;
            }

            var targetWorldObject = actionState.TargetWorldObject;

            if (targetWorldObject is null)
            {
                // display over the character
                targetWorldObject = (IWorldObject)this.privateState.GameObject;
            }

            Vector2D offset = (0, 1.13);

            if (targetWorldObject == ClientCurrentCharacterHelper.Character &&
                GeneralOptionDisplayHealthbarAboveCurrentCharacter.IsDisplay)
            {
                // adjust the offset so the circle will not overlap with the current character's name and healthbar
                offset += (0, 0.2);
            }

            switch (targetWorldObject.ProtoWorldObject)
            {
            case IProtoStaticWorldObject protoStaticWorldObject:
                offset += protoStaticWorldObject.SharedGetObjectCenterWorldOffset(targetWorldObject);
                break;

            case IProtoCharacter protoCharacter:
                offset += protoCharacter.SharedGetObjectCenterWorldOffset(targetWorldObject);
                break;
            }

            this.componentAttachedUIElement = Client.UI.AttachControl(
                targetWorldObject,
                new ActionProgressControl()
            {
                ActionState = actionState
            },
                positionOffset: offset,
                isFocusable: false);

            CannotInteractMessageDisplay.Hide();
            InteractionTooltip.Hide();
        }
        static ClientObjectDepositTooltipHelper()
        {
            SceneObject           = Api.Client.Scene.CreateSceneObject(nameof(ClientObjectDepositTooltipHelper));
            DepositTooltipControl = new DepositTooltipControl();

            ComponentAttachedUIElement = Api.Client.UI.AttachControl(
                SceneObject,
                DepositTooltipControl,
                positionOffset: (0, 0),
                isFocusable: false);

            ComponentAttachedUIElement.IsEnabled = false;
        }
Beispiel #13
0
        private void RemoveAttachedControl()
        {
            if (this.componentAttachedUIElement == null)
            {
                return;
            }

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

            this.structurePointsBarControl = null;
        }
        protected override void ClientUpdate(ClientUpdateData data)
        {
            base.ClientUpdate(data);

            var worldObject = data.GameObject;

            if (currentDisplayedRepairTooltip is null)
            {
                if (this.ClientIsConstructionOrRepairRequirementsTooltipShouldBeDisplayed(data.PublicState))
                {
                    // display build/repair tooltip
                    currentDisplayedRepairTooltip =
                        ConstructionOrRepairRequirementsTooltip.CreateAndAttach(worldObject);
                }
            }
            else
            {
                var tooltipDisplayedForObject =
                    ((ConstructionOrRepairRequirementsTooltip)currentDisplayedRepairTooltip.Control).WorldObject;
                if (ReferenceEquals(worldObject, tooltipDisplayedForObject) &&
                    !this.ClientIsConstructionOrRepairRequirementsTooltipShouldBeDisplayed(data.PublicState))
                {
                    // destroy tooltip
                    currentDisplayedRepairTooltip?.Destroy();
                    currentDisplayedRepairTooltip = null;
                }
            }

            if (currentDisplayedRelocateTooltip is null)
            {
                if (ClientCanRelocateStructure(worldObject))
                {
                    currentDisplayedRelocateTooltip =
                        ConstructionRelocationTooltip.CreateAndAttach(worldObject);
                }
            }
            else
            {
                var tooltipDisplayedForObject =
                    ((ConstructionRelocationTooltip)currentDisplayedRelocateTooltip.Control).WorldObject;
                if (ReferenceEquals(worldObject, tooltipDisplayedForObject) &&
                    !ClientCanRelocateStructure(worldObject))
                {
                    // destroy tooltip
                    currentDisplayedRelocateTooltip?.Destroy();
                    currentDisplayedRelocateTooltip = null;
                }
            }
        }
Beispiel #15
0
        private void RefreshAttachedComponent()
        {
            this.componentAttachedUIElement?.Destroy();
            this.componentAttachedUIElement = null;

            var actionState = this.privateState.CurrentActionState;

            if (actionState is null ||
                !actionState.IsDisplayingProgress)
            {
                return;
            }

            var targetWorldObject = actionState.TargetWorldObject;

            if (targetWorldObject is null)
            {
                // display over the character
                targetWorldObject = (IWorldObject)this.privateState.GameObject;
            }

            Vector2D offset = (0, 1.01);

            switch (targetWorldObject.ProtoWorldObject)
            {
            case IProtoStaticWorldObject protoStaticWorldObject:
                offset += protoStaticWorldObject.SharedGetObjectCenterWorldOffset(targetWorldObject);
                break;

            case IProtoCharacter protoCharacter:
                offset += protoCharacter.SharedGetObjectCenterWorldOffset(targetWorldObject);
                break;
            }

            this.componentAttachedUIElement = Client.UI.AttachControl(
                targetWorldObject,
                new ActionProgressControl()
            {
                ActionState = actionState
            },
                positionOffset: offset,
                isFocusable: false);

            CannotInteractMessageDisplay.Hide();
            InteractionTooltip.Hide();
        }
Beispiel #16
0
        public sealed override void ClientDeinitialize(IStaticWorldObject gameObject)
        {
            base.ClientDeinitialize(gameObject);

            if (this.currentDisplayedRepairTooltip != null)
            {
                var tooltipDisplayedForObject =
                    ((ConstructionOrRepairRequirementsTooltip)this.currentDisplayedRepairTooltip.Control).WorldObject;
                if (gameObject == tooltipDisplayedForObject)
                {
                    // destroy tooltip
                    this.currentDisplayedRepairTooltip?.Destroy();
                    this.currentDisplayedRepairTooltip = null;
                }
            }

            this.ClientDeinitializeStructure(gameObject);
        }
        private void ClientInitializeOtherCharacter(ClientInitializeData data)
        {
            IComponentAttachedControl nicknameDisplay = null;

            var publicState = data.SyncPublicState;

            publicState.ClientSubscribe(
                _ => _.IsOnline,
                _ => Refresh(),
                data.ClientState);

            publicState.ClientSubscribe(
                _ => _.IsDead,
                _ => Refresh(),
                data.ClientState);

            Refresh();

            void Refresh()
            {
                nicknameDisplay?.Destroy();
                nicknameDisplay = null;
                if (publicState.IsDead)
                {
                    return;
                }

                // setup nickname display
                var character = data.GameObject;
                var nicknameDisplayControl = new NicknameDisplay();

                nicknameDisplayControl.Setup(character.Name, publicState.IsOnline);
                nicknameDisplay = Client.UI.AttachControl(
                    character,
                    nicknameDisplayControl,
                    positionOffset: (0, this.CharacterWorldHeight + 0.05),
                    isFocusable: false);
            }
        }
Beispiel #18
0
 // This method is currently used only for doors and walls to display an indicator
 public static void ClientObserving(IStaticWorldObject worldObject, bool isObserving)
 {
     if (isObserving)
     {
         // do not display the green indicator as it may be misleading to some players
         //var isLandClaimed = LandClaimSystem.SharedIsObjectInsideAnyArea(worldObject);
         //if (isLandClaimed)
         //{
         //    // display only the green indicator when hover (as the red indicator is always displayed)
         //    lastHoverIndicator = SetupFor(worldObject, isClaimed: true);
         //}
     }
     else if (lastHoverIndicator != null)
     {
         // was hovering over that world object, destroy the indicator
         var control = (StructureLandClaimIndicator)lastHoverIndicator.Control;
         lastHoverIndicator.Destroy();
         lastHoverIndicator          = null;
         control.AttachedToComponent = null;
         ControlsCache <StructureLandClaimIndicator> .Instance.Push(control);
     }
 }
        private void RefreshBarControl()
        {
            if (!this.isDamaged)
            {
                this.RemoveAttachedControl();
                return;
            }

            var isBarVisible = this.CheckIsBarShouldBeVisible();

            if (!isBarVisible)
            {
                this.RemoveAttachedControl();
                return;
            }

            if (this.componentAttachedUIElement is not null)
            {
                return;
            }

            var protoWorldObject       = this.data.ProtoWorldObject;
            var structurePointsCurrent = this.data.State.StructurePointsCurrent;

            this.structurePointsBarControl = ControlsCache <StructurePointsBarControl> .Instance.Pop();

            this.structurePointsBarControl.Setup(this.data,
                                                 this.lastStructurePoints ?? structurePointsCurrent);

            var offset = protoWorldObject.SharedGetObjectCenterWorldOffset(
                this.SceneObject.AttachedWorldObject);

            this.componentAttachedUIElement = Api.Client.UI.AttachControl(
                this.SceneObject,
                this.structurePointsBarControl,
                positionOffset: offset + (0, 0.85),
                isFocusable: false);
        }
        private static void Update()
        {
            if (LoadingSplashScreenManager.Instance.CurrentState
                != LoadingSplashScreenState.Hidden)
            {
                return;
            }

            IStaticWorldObject    worldObject    = null;
            IProtoObjectStructure protoStructure = null;

            var selectedProtoItem = ClientHotbarSelectedItemManager.SelectedItem?.ProtoItem;

            if (selectedProtoItem is IProtoItemToolToolbox ||
                selectedProtoItem is IProtoItemToolCrowbar)
            {
                worldObject    = ClientComponentObjectInteractionHelper.MouseOverObject as IStaticWorldObject;
                protoStructure = worldObject?.ProtoGameObject as IProtoObjectStructure;
            }

            if (currentTooltipsWorldObject != worldObject)
            {
                tooltipBuildOrRepair?.Destroy();
                tooltipBuildOrRepair = null;

                tooltipRelocate?.Destroy();
                tooltipRelocate = null;

                tooltipDeconstruct?.Destroy();
                tooltipDeconstruct = null;

                currentTooltipsWorldObject = worldObject;
            }

            if (protoStructure is null)
            {
                return;
            }

            // process structure repair tooltip
            var isBuildTooltipRequired
                = selectedProtoItem is IProtoItemToolToolbox &&
                  protoStructure.ClientIsConstructionOrRepairRequirementsTooltipShouldBeDisplayed(worldObject);

            if (tooltipBuildOrRepair is null)
            {
                if (isBuildTooltipRequired)
                {
                    tooltipBuildOrRepair = ConstructionOrRepairRequirementsTooltip.CreateAndAttach(worldObject);
                }
            }
            else if (!isBuildTooltipRequired)
            {
                tooltipBuildOrRepair.Destroy();
                tooltipBuildOrRepair = null;
            }

            // process structure relocation tooltip
            var canRelocate = selectedProtoItem is IProtoItemToolToolbox &&
                              !ConstructionRelocationSystem.IsInObjectPlacementMode &&
                              ConstructionRelocationSystem.SharedIsRelocatable(worldObject);

            if (tooltipRelocate is null)
            {
                if (canRelocate)
                {
                    tooltipRelocate = ConstructionRelocationTooltip.CreateAndAttach(worldObject);
                }
            }
            else if (!canRelocate)
            {
                tooltipRelocate.Destroy();
                tooltipRelocate = null;
            }

            // process structure deconstruction tooltip
            var canDeconstruct = selectedProtoItem is IProtoItemToolCrowbar &&
                                 DeconstructionSystem.SharedIsDeconstructable(protoStructure);

            if (tooltipDeconstruct is null)
            {
                if (canDeconstruct)
                {
                    tooltipDeconstruct = ConstructionDeconstructTooltip.CreateAndAttach(worldObject);
                }
            }
            else if (!canDeconstruct)
            {
                tooltipDeconstruct.Destroy();
                tooltipDeconstruct = null;
            }
        }