Example #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;
            }
        }
Example #2
0
        public VehicleRepairActionState(
            ICharacter character,
            IDynamicWorldObject vehicle,
            IItem itemVehicleRepairKit)
            : base(character)
        {
            this.Vehicle = vehicle;
            this.ItemVehicleRepairKit      = itemVehicleRepairKit;
            this.ProtoItemVehicleRepairKit = (IProtoItemVehicleRepairKit)itemVehicleRepairKit.ProtoGameObject;
            var protoVehicle = (IProtoVehicle)vehicle.ProtoWorldObject;

            this.currentStageTimeRemainsSeconds = this.currentStageDurationSeconds =
                this.CalculateStageDurationSeconds(character, isFirstStage: true);
            this.VehiclePublicState = vehicle.GetPublicState <VehiclePublicState>();

            this.structurePointsMax     = protoVehicle.SharedGetStructurePointsMax(vehicle);
            this.stageStructureAddValue = this.structurePointsMax / protoVehicle.RepairStagesCount;
        }
        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;
            }
        }