示例#1
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);
        }
示例#2
0
        private void ClientSetupHealthbar(ClientInitializeData data)
        {
            var objectDrone = data.GameObject;
            var publicState = data.PublicState;

            var structurePointsBarControl = new VehicleArmorBarControl();

            structurePointsBarControl.Setup(
                new ObjectStructurePointsData(objectDrone, this.SharedGetStructurePointsMax(objectDrone)),
                publicState.StructurePointsCurrent);

            Api.Client.UI.AttachControl(
                objectDrone,
                structurePointsBarControl,
                positionOffset: this.SharedGetObjectCenterWorldOffset(objectDrone) + (0, 0.55),
                isFocusable: false);
        }