예제 #1
0
        public ViewModelWindowObjectVehicle(
            IDynamicWorldObject vehicle,
            FrameworkElement vehicleExtraControl,
            IViewModelWithActiveState vehicleExtraControlViewModel)
        {
            this.vehicle                      = vehicle;
            this.VehicleExtraControl          = vehicleExtraControl;
            this.VehicleExtraControlViewModel = vehicleExtraControlViewModel;
            if (vehicleExtraControl is not null)
            {
                vehicleExtraControl.DataContext = vehicleExtraControlViewModel;
            }

            var currentCharacter = Api.Client.Characters.CurrentPlayerCharacter;

            this.ContainerPlayerInventory = (IClientItemsContainer)currentCharacter.SharedGetPlayerContainerInventory();

            this.ProtoVehicle        = (IProtoVehicle)vehicle.ProtoGameObject;
            this.vehiclePublicState  = vehicle.GetPublicState <VehiclePublicState>();
            this.vehiclePrivateState = vehicle.GetPrivateState <VehiclePrivateState>();

            this.vehiclePublicState.ClientSubscribe(
                _ => _.ClanTag,
                _ =>
            {
                this.NotifyPropertyChanged(nameof(this.IsOwnedByFaction));
                this.NotifyPropertyChanged(nameof(this.FactionClanTag));
                this.NotifyPropertyChanged(nameof(this.FactionEmblem));
                this.RefreshAccessEditor();
            },
                this);

            var structurePointsMax = this.ProtoVehicle.SharedGetStructurePointsMax(vehicle);

            this.ViewModelStructurePoints = new ViewModelStructurePointsBarControl()
            {
                ObjectStructurePointsData = new ObjectStructurePointsData(vehicle, structurePointsMax)
            };

            this.ViewModelVehicleEnergy = new ViewModelVehicleEnergy(vehicle);

            this.cargoItemsContainer             = this.vehiclePrivateState.CargoItemsContainer as IClientItemsContainer;
            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(this.cargoItemsContainer)
            {
                IsContainerTitleVisible = false,
                IsActive = false
            };

            this.RefreshAccessEditor();
            this.RefreshCanRepair();

            this.IsVehicleTabActive = true;
            this.ViewModelItemsContainerExchange.IsActive = true;

            if (this.cargoItemsContainer is not null)
            {
                this.cargoItemsContainer.ItemAdded        += this.CargoItemsContainerItemAddedHandler;
                this.cargoItemsContainer.ItemCountChanged += this.CargoItemsContainerItemCountChangedHandler;
            }
        }
예제 #2
0
        public ViewModelVehicleEnergy(IDynamicWorldObject vehicle)
        {
            this.vehicle             = vehicle;
            this.vehiclePrivateState = vehicle.GetPrivateState <VehiclePrivateState>();
            this.vehiclePrivateState.ClientSubscribe(_ => _.CurrentEnergyMax,
                                                     _ => this.NotifyPropertyChanged(nameof(this.EnergyMax)),
                                                     this);

            this.RefreshEnergy();
        }
예제 #3
0
        public static void ServerResetLastVehicleMapMark(VehiclePrivateState vehiclePrivateState)
        {
            if (vehiclePrivateState.ServerLastPilotCharacter is null)
            {
                return;
            }

            var characterPrivateState = PlayerCharacter.GetPrivateState(vehiclePrivateState.ServerLastPilotCharacter);

            characterPrivateState.LastDismountedVehicleMapMark = default;
            vehiclePrivateState.ServerLastPilotCharacter       = null;
        }
        public ViewModelWindowObjectVehicle(
            IDynamicWorldObject vehicle,
            FrameworkElement vehicleExtraControl,
            IViewModelWithActiveState vehicleExtraControlViewModel)
        {
            this.VehicleExtraControl          = vehicleExtraControl;
            this.VehicleExtraControlViewModel = vehicleExtraControlViewModel;
            if (vehicleExtraControl != null)
            {
                vehicleExtraControl.DataContext = vehicleExtraControlViewModel;
            }

            var currentCharacter = Api.Client.Characters.CurrentPlayerCharacter;

            this.ContainerPlayerInventory = (IClientItemsContainer)currentCharacter.SharedGetPlayerContainerInventory();

            this.ProtoVehicle        = (IProtoVehicle)vehicle.ProtoGameObject;
            this.vehiclePublicState  = vehicle.GetPublicState <VehiclePublicState>();
            this.vehiclePrivateState = vehicle.GetPrivateState <VehiclePrivateState>();

            var structurePointsMax = this.ProtoVehicle.SharedGetStructurePointsMax(vehicle);

            this.ViewModelStructurePoints = new ViewModelStructurePointsBarControl()
            {
                ObjectStructurePointsData = new ObjectStructurePointsData(vehicle, structurePointsMax)
            };

            this.ViewModelVehicleEnergy = new ViewModelVehicleEnergy(vehicle);

            this.cargoItemsContainer             = this.vehiclePrivateState.CargoItemsContainer as IClientItemsContainer;
            this.ViewModelItemsContainerExchange = new ViewModelItemsContainerExchange(this.cargoItemsContainer,
                                                                                       callbackTakeAllItemsSuccess:
                                                                                       null)
            {
                IsContainerTitleVisible = false
            };

            this.ViewModelItemsContainerExchange.IsActive = false;

            var isOwner = WorldObjectOwnersSystem.SharedIsOwner(
                ClientCurrentCharacterHelper.Character,
                vehicle);

            this.ViewModelOwnersEditor =
                new ViewModelWorldObjectOwnersEditor(this.vehiclePrivateState.Owners,
                                                     canEditOwners: isOwner ||
                                                     CreativeModeSystem.ClientIsInCreativeMode(),
                                                     callbackServerSetOwnersList:
                                                     ownersList => WorldObjectOwnersSystem.ClientSetOwners(
                                                         vehicle,
                                                         ownersList),
                                                     title: CoreStrings.ObjectOwnersList_Title2);

            this.RefreshCanRepair();

            this.IsVehicleTabActive = true;
            this.ViewModelItemsContainerExchange.IsActive = true;

            if (this.cargoItemsContainer != null)
            {
                this.cargoItemsContainer.ItemAdded        += this.CargoItemsContainerItemAddedHandler;
                this.cargoItemsContainer.ItemCountChanged += this.CargoItemsContainerItemCountChangedHandler;
            }
        }