コード例 #1
0
        private void ServerRemote_OnActionCompletedInternal(IItem itemVehicleRemote, ICharacter character, Vector2D mousePosition)
        {
            if (!(itemVehicleRemote.ProtoItem is IProtoItemVehicleRemoteControl protoRemote))
            {
                return;
            }

            if (!CharacterEnergySystem.SharedHasEnergyCharge(character, protoRemote.EngeryUse))
            {
                return;
            }

            List <GarageVehicleEntry> list = VehicleGarageSystem.ServerGetCharacterVehicles(character, false);

            TakeVehicleResult result = TakeVehicleResult.Unknown;

            if (list.Count > 0)
            {
                var privateState = itemVehicleRemote.GetPrivateState <ItemVehicleRemoteControlPrivateState>();
                result = this.ServerTakeVehicle(privateState, character, mousePosition);
            }

            if (result == TakeVehicleResult.Success)
            {
                CharacterEnergySystem.ServerDeductEnergyCharge(character, protoRemote.EngeryUse);

                ItemDurabilitySystem.ServerModifyDurability(itemVehicleRemote, delta: -1);
            }
        }
コード例 #2
0
        public override bool SharedCanFire(ICharacter character, WeaponState weaponState)
        {
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(character,
                this.EnergyUsePerShot);
            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return true;
            }

            if (IsClient && weaponState.SharedGetInputIsFiring())
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
                // stop using weapon item!
                weaponState.ProtoWeapon.ClientItemUseFinish(weaponState.ItemWeapon);
            }

            return false;
        }
コード例 #3
0
        public override bool SharedCanSelect(IItem item, ICharacter character)
        {
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                character,
                this.EnergyUsePerShot + this.EnergyUsePerHit);

            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return(true);
            }

            if (IsClient)
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
            }

            return(false);
        }
コード例 #4
0
        protected override void ClientItemUseStart(ClientItemData data)
        {
            if (data.PrivateState.VehicleID == 0)
            {
                WindowVehicleRemoteControl.Open(data.Item);
            }
            else
            {
                var character = Api.Client.Characters.CurrentPlayerCharacter;
                if (!CharacterEnergySystem.SharedHasEnergyCharge(character, this.EngeryUse))
                {
                    CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
                    return;
                }

                VehicleRemoteSystem.Instance.ClientTryStartAction();
            }
        }
コード例 #5
0
        public override bool SharedCanFire(ICharacter character, WeaponState weaponState)
        {
            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                character,
                this.EnergyUsePerShot + this.EnergyUsePerHit);

            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return(true);
            }

            if (IsClient && weaponState.SharedGetInputIsFiring())
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
                weaponState.ProtoWeapon.ClientItemUseFinish(weaponState.ItemWeapon);
                ClientHotbarSelectedItemManager.SelectedSlotId = null;
            }

            return(false);
        }
コード例 #6
0
        public override bool SharedCanSelect(IItem item, ICharacter character, bool isAlreadySelected, bool isByPlayer)
        {
            if (!base.SharedCanSelect(item, character, isAlreadySelected, isByPlayer))
            {
                return(false);
            }

            var requiredEnergyAmount = SkillWeaponsEnergy.SharedGetRequiredEnergyAmount(
                character,
                this.EnergyUsePerShot + this.EnergyUsePerHit);

            if (CharacterEnergySystem.SharedHasEnergyCharge(character, requiredEnergyAmount))
            {
                return(true);
            }

            // cannot select
            if (IsClient && isByPlayer)
            {
                CharacterEnergySystem.ClientShowNotificationNotEnoughEnergyCharge(this);
            }

            return(false);
        }