示例#1
0
        public override void SharedUpdate(double deltaTime)
        {
            if (this.CharacterPublicState.SelectedItem != this.ItemVehicleRepairKit)
            {
                this.AbortAction();
                return;
            }

            if (!VehicleRepairKitSystem.SharedCheckCanInteract(
                    this.Character,
                    this.Vehicle,
                    writeToLog: true))
            {
                this.AbortAction();
                return;
            }

            this.currentStageTimeRemainsSeconds -= deltaTime;
            if (this.currentStageTimeRemainsSeconds <= 0)
            {
                this.SharedOnStageCompleted();
            }
            else if (Api.IsClient)
            {
                if (this.VehiclePublicState.StructurePointsCurrent >= this.structurePointsMax)
                {
                    // apparently the repair finished before the client simulation was complete
                    this.AbortAction();
                }
            }

            this.UpdateProgress();
        }
示例#2
0
        private void SharedOnStageCompleted()
        {
            if (Api.IsServer)
            {
                // notify tool was used
                ServerItemUseObserver.NotifyItemUsed(this.Character, this.ItemVehicleRepairKit);

                // reduce tool durability
                ItemDurabilitySystem.ServerModifyDurability(this.ItemVehicleRepairKit, delta: -1);
            }
            else // if client
            {
                Api.Client.Audio.PlayOneShot(VehicleSystem.SoundResourceVehicleRepair);
            }

            this.currentStageDurationSeconds     = this.CalculateStageDurationSeconds(this.Character, isFirstStage: false);
            this.currentStageTimeRemainsSeconds += this.currentStageDurationSeconds;

            var currentStructurePoints = this.VehiclePublicState.StructurePointsCurrent;
            var newStructurePoints     = currentStructurePoints
                                         + this.stageStructureAddValue;

            if (Api.IsServer)
            {
                ((IProtoVehicle)this.Vehicle.ProtoGameObject)
                .ServerOnRepair(this.Vehicle, this.Character);
            }

            if (currentStructurePoints < this.structurePointsMax)
            {
                // repairing is still possible - more stages are available
                this.UpdateProgress();

                if (Api.IsServer &&
                    this.ItemVehicleRepairKit.IsDestroyed)
                {
                    // tool was destroyed (durability 0)
                    this.AbortAction();
                    return;
                }

                return;
            }

            // repairing is absolutely completed
            if (Api.IsServer)
            {
                // TODO: add skill experience for repair
                // this.CharacterPrivateState.Skills.ServerAddSkillExperience<SkillVehicles>(
                //     SkillVehicles.ExperienceAddWhenRepairFinished);
            }

            this.SetCompleted(isCancelled: false);
            VehicleRepairKitSystem.SharedActionCompleted(this.Character, this);
        }
示例#3
0
 protected override void AbortAction()
 {
     VehicleRepairKitSystem.SharedAbortAction(
         this.Character,
         this.Vehicle);
 }