// displayed when player logging into the game and has a single vehicle in garage
 // or when the vehicle is despawned to garage
 private void ClientRemote_VehicleInGarage(IProtoVehicle protoVehicle)
 {
     NotificationSystem.ClientShowNotification(protoVehicle.Name,
                                               Notification_VehicleInGarage_Description,
                                               icon: protoVehicle.Icon)
     .HideAfterDelay(delaySeconds: 60);
 }
        private static void Update()
        {
            IDynamicWorldObject vehicle      = null;
            IProtoVehicle       protoVehicle = null;

            if (ClientHotbarSelectedItemManager.SelectedItem?.ProtoItem
                is IProtoItemVehicleRepairKit &&
                ClientCurrentCharacterHelper.PublicState.CurrentPublicActionState
                is not VehicleRepairActionState.PublicState)
            {
                vehicle      = VehicleRepairKitSystem.ClientGetObjectToRepairAtCurrentMousePosition();
                protoVehicle = vehicle?.ProtoGameObject as IProtoVehicle;
            }

            if (currentTooltipVehicle != vehicle)
            {
                tooltip?.Destroy();
                tooltip = null;
                currentTooltipVehicle = vehicle;
            }

            if (protoVehicle is null)
            {
                return;
            }

            tooltip ??= VehicleRepairKitTooltip.CreateAndAttach(vehicle);
        }
 public ViewModelGarageVehicleEntry(
     uint vehicleGameObjectId,
     IProtoVehicle protoVehicle,
     VehicleStatus status)
 {
     this.VehicleGameObjectId = vehicleGameObjectId;
     this.ProtoVehicle        = protoVehicle;
     this.Status = status;
 }
Exemple #4
0
        public string Execute(
            IProtoVehicle objTypeName,
            double x,
            double y)
        {
            var offset = Server.World.WorldBounds.Offset;

            return(SpawnObject(objTypeName,
                               (x + offset.X, y + offset.Y)));
        }
Exemple #5
0
 public ViewModelGarageVehicleEntry(
     uint vehicleGameObjectId,
     IProtoVehicle protoVehicle,
     VehicleStatus status)
 {
     VehicleGameObjectId = vehicleGameObjectId;
     ProtoVehicle        = protoVehicle;
     Status = status;
     UpdateName();
 }
Exemple #6
0
        public ViewModelVehicleSchematic(IProtoVehicle protoVehicle)
        {
            this.ProtoVehicle = protoVehicle;
            if (protoVehicle is null)
            {
                return;
            }

            this.UpdateIsCanBuild();
            this.SubscribeToContainersEvents();
        }
Exemple #7
0
        public ViewModelGarageVehicleEntry(
            uint vehicleGameObjectId,
            IProtoVehicle protoVehicle,
            VehicleStatus status)
        {
            this.VehicleGameObjectId = vehicleGameObjectId;
            this.ProtoVehicle        = protoVehicle;
            this.Status = status;

            VehicleNamesSystem.ClientVehicleNameChanged += this.VehicleNameChangedHandler;
        }
        public static void ClientShowNotificationNotEnoughEnergy(IProtoVehicle protoVehicle)
        {
            Client.Audio.PlayOneShot(SoundResourceNoEnergy, volume: 0.4f);

            NotificationSystem.ClientShowNotification(
                string.Format(VehicleSystem.Notification_CannotUseVehicle_TitleFormat, protoVehicle.Name),
                Notification_EnergyDepleted_Message,
                color: NotificationColor.Bad,
                icon: protoVehicle.Icon,
                playSound: false);
        }
Exemple #9
0
        public static IDynamicWorldObject ClientGetObjectToRepairAtCurrentMousePosition(
            bool showErrorIfNoCompatibleVehicle)
        {
            var worldObjects = ClientGetObjectsAtCurrentMousePosition();
            IDynamicWorldObject vehicleToRepair          = null;
            IProtoVehicle       protoVehicleIncompatible = null;

            // find first damaged vehicle there
            foreach (var worldObject in worldObjects)
            {
                if (worldObject.ProtoGameObject is not IProtoVehicle protoVehicle)
                {
                    continue;
                }

                if (!protoVehicle.IsRepairable)
                {
                    protoVehicleIncompatible = protoVehicle;
                    continue;
                }

                var vehicle = (IDynamicWorldObject)worldObject;
                var maxStructurePointsMax  = protoVehicle.SharedGetStructurePointsMax(vehicle);
                var structurePointsCurrent = worldObject.GetPublicState <VehiclePublicState>()
                                             .StructurePointsCurrent;
                if (structurePointsCurrent < maxStructurePointsMax)
                {
                    vehicleToRepair = vehicle;
                    break;
                }
            }

            if (vehicleToRepair is null &&
                protoVehicleIncompatible is not null &&
                showErrorIfNoCompatibleVehicle)
            {
                NotificationSystem.ClientShowNotification(NotificationErrorCannotRepairThisVehicle,
                                                          color: NotificationColor.Bad,
                                                          icon: protoVehicleIncompatible.Icon);
            }

            return(vehicleToRepair);
        }
Exemple #10
0
        private static string SpawnObject(
            IProtoVehicle objTypeName,
            Vector2D position)
        {
            var result = Server.World.CreateDynamicWorldObject(objTypeName, position);

            if (result is null)
            {
                return("<cannot spawn there>");
            }

            var protoVehicle = (IProtoVehicle)result.ProtoGameObject;
            var byCharacter  = ServerRemoteContext.IsRemoteCall
                                  ? ServerRemoteContext.Character
                                  : null;

            if (byCharacter is not null)
            {
                protoVehicle.ServerOnBuilt(result, byCharacter);
            }

            return(result.ToString());
        }
Exemple #11
0
 public ProtoVehicleViewModel([NotNull] IProtoVehicle vehicle) : base(vehicle)
 {
     Description = vehicle.Description;
 }
 public GarageVehicleEntry(IWorldObject vehicle, VehicleStatus status)
 {
     this.Id           = vehicle.Id;
     this.ProtoVehicle = (IProtoVehicle)vehicle.ProtoGameObject;
     this.Status       = status;
 }
 public TechNodeEffectVehicleUnlock(IProtoVehicle vehicle)
 {
     this.Vehicle = vehicle ?? throw new ArgumentNullException();
 }
        /// <summary>
        /// Constructor for vehicle creation recipe.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="vehicleViewModel">View Model of IProtoVehicle.</param>
        /// <param name="vehicle"></param>
        public VehicleBuildRecipeViewModel([NotNull] ProtoVehicleViewModel vehicleViewModel, IProtoVehicle vehicle)
            : base(vehicleViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictionaryCreated)
            {
                throw new Exception("CNEI: Build constructor used before all entity VMs sets.");
            }

            InputItemsList = vehicle.BuildRequiredItems
                             .Select(item => EntityViewModelsManager.GetEntityViewModel(item.ProtoItem))
                             .ToList();

            InputItemsVMList = vehicle.BuildRequiredItems
                               .Select(item => new ViewModelEntityWithCount(EntityViewModelsManager.GetEntityViewModel(item.ProtoItem),
                                                                            item.Count))
                               .ToList().AsReadOnly();

            BuildRequiredElectricityAmount = vehicle.BuildRequiredElectricityAmount;

            OutputItemsList.Add(vehicleViewModel);

            VehicleVM = vehicleViewModel;

            StationsList = EntityViewModelsManager.GetAllEntityViewModelsByType <IProtoVehicleAssemblyBay>()
                           .AsReadOnly();
            ListedInTechNodes = vehicleViewModel.ListedInTechNodes;
        }
 public static void ServerNotifyClientNotEnoughEnergy(ICharacter character, IProtoVehicle protoVehicle)
 {
     Instance.CallClient(character,
                         _ => _.ClientRemote_OnNotEnoughEnergy(protoVehicle));
 }
Exemple #16
0
 public string Execute(
     IProtoVehicle protoDynamicWorldObject,
     [CurrentCharacterIfNull] ICharacter character)
 {
     return(SpawnObject(protoDynamicWorldObject, character.TilePosition.ToVector2D()));
 }
 private void ClientRemote_OnNotEnoughEnergy(IProtoVehicle protoVehicle)
 {
     ClientShowNotificationNotEnoughEnergy(protoVehicle);
 }