Esempio n. 1
0
        /// <summary>
        /// Creates or replaces the SirenController of the given vehicle.
        /// </summary>
        /// <param name="aVehicle">The vehicle.</param>
        /// <param name="aSiren">The Siren.</param>
        /// <param name="someNetIDs">Already existing siren entities.</param>
        /// <returns>The newly created SirenController.</returns>
        private SirenController CreateSirenController(BaseVehicle aVehicle, Siren aSiren, IEnumerable <uint> someNetIDs = null)
        {
            SirenController theController = aVehicle.GetComponent <SirenController>();

            if (theController)
            {
                UnityEngine.Object.DestroyImmediate(theController);
            }
            theController        = aVehicle.gameObject.AddComponent <SirenController>();
            theController.Config = config;
            theController.Siren  = aSiren;
            if (someNetIDs != null)
            {
                theController.NetIDs.UnionWith(someNetIDs);
            }
            return(theController);
        }
Esempio n. 2
0
        private BaseVehicle RaycastVehicle(IPlayer aPlayer)
        {
            RaycastHit theHit;

            if (!Physics.Raycast((aPlayer.Object as BasePlayer).eyes.HeadRay(), out theHit, 5f))
            {
                return(null);
            }

            BaseVehicle theVehicle = theHit.GetEntity()?.GetComponentInParent <BaseVehicle>();

            if (!theVehicle)
            {
                Message(aPlayer, I18N_NOT_A_VEHICLE);
            }
            return(theVehicle);
        }
Esempio n. 3
0
    public virtual bool HasValidDismountPosition(BasePlayer player)
    {
        BaseVehicle baseVehicle = this.VehicleParent();

        if (Object.op_Inequality((Object)baseVehicle, (Object)null))
        {
            return(baseVehicle.HasValidDismountPosition(player));
        }
        foreach (Component dismountPosition in this.dismountPositions)
        {
            if (this.ValidDismountPosition(dismountPosition.get_transform().get_position()))
            {
                return(true);
            }
        }
        return(false);
    }
Esempio n. 4
0
        private void AttachCarSirens(IPlayer aPlayer, string aCommand, string[] someArgs)
        {
            if (aPlayer.IsServer)
            {
                Message(aPlayer, I18N_PLAYERS_ONLY, aCommand);
                return;
            }

            BaseVehicle theVehicle = RaycastVehicle(aPlayer);

            if (theVehicle)
            {
                Siren theSiren = someArgs.Length > 0 ? FindSirenForName(someArgs[0], aPlayer) : SirenDictionary.Values.First();
                AttachSirens(theVehicle, theSiren, config.DefaultState, aPlayer);
                Message(aPlayer, I18N_ATTACHED, theSiren.Name);
            }
        }
Esempio n. 5
0
        protected override void OnInitialized(EventArgs e)
        {
            RakNet = Services.GetService <IRakNet>();
            RakNet.SetLogging(false, false, false, false, true, true);
            RakNet.IncomingRpc     += (sender, args) => OnIncomingRpc(args);
            RakNet.OutcomingRpc    += (sender, args) => OnOutcomingRpc(args);
            RakNet.IncomingPacket  += (sender, args) => OnIncomingPacket(args);
            RakNet.OutcomingPacket += (sender, args) => OnOutcomingPacket(args);

            BaseVehicle.Create((VehicleModelType)429, new Vector3(5, 0, 5), 0, 0, 0);
            BaseVehicle.Create((VehicleModelType)461, new Vector3(10, 0, 5), 0, 0, 0);
            BaseVehicle.Create((VehicleModelType)488, new Vector3(15, 0, 5), 0, 0, 0);

            BaseVehicle.Create((VehicleModelType)403, new Vector3(25, 0, 5), 0, 0, 0);
            BaseVehicle.Create((VehicleModelType)435, new Vector3(30, 0, 5), 0, 0, 0);
            base.OnInitialized(e);
        }
        internal bool OnUnoccupiedVehicleUpdate(int vehicleid, int playerid, int passengerSeat, float newX,
                                                float newY, float newZ, float velX, float velY, float velZ)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            var args = new UnoccupiedVehicleEventArgs(BasePlayer.FindOrCreate(playerid), passengerSeat,
                                                      new Vector3(newX, newY, newZ), new Vector3(velX, velY, velZ));

            OnUnoccupiedVehicleUpdated(vehicle, args);

            return(!args.PreventPropagation);
        }
Esempio n. 7
0
        /// <summary>
        /// Detaches the siren from a vehicle and removes all corresponding entities.
        /// </summary>
        /// <param name="aVehicle"> The vehicle.</param>
        /// <returns>True, if a siren was removed.</returns>
        private bool DetachSirens(BaseVehicle aVehicle)
        {
            SirenController theController = aVehicle.GetComponent <SirenController>();

            if (theController)
            {
                foreach (BaseEntity eachEntity in aVehicle.GetComponentsInChildren <BaseEntity>())
                {
                    if (theController.NetIDs.Contains(eachEntity.net.ID))
                    {
                        Destroy(eachEntity);
                    }
                }
                UnityEngine.Object.DestroyImmediate(theController);
                return(true);
            }
            return(false);
        }
Esempio n. 8
0
        public async Task <IHttpActionResult> Post(BaseVehicleInputModel newBaseVehicle)
        {
            BaseVehicle baseVehicle = new BaseVehicle()
            {
                MakeId  = newBaseVehicle.MakeId,
                ModelId = newBaseVehicle.ModelId,
                YearId  = newBaseVehicle.YearId
            };
            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = newBaseVehicle.Comment
            };
            var attachments = SetUpAttachmentsModels(newBaseVehicle.Attachments);

            var changeRequestId = await _baseVehicleApplicationService.AddAsync(baseVehicle, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
Esempio n. 9
0
    public virtual bool HasValidDismountPosition(BasePlayer player)
    {
        BaseVehicle baseVehicle = this.VehicleParent();

        if (baseVehicle != null)
        {
            return(baseVehicle.HasValidDismountPosition(player));
        }
        Transform[] transformArrays = this.dismountPositions;
        for (int i = 0; i < (int)transformArrays.Length; i++)
        {
            if (this.ValidDismountPosition(transformArrays[i].transform.position))
            {
                return(true);
            }
        }
        return(false);
    }
Esempio n. 10
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            Console.WriteLine("The game mode has loaded.");
            AddPlayerClass(0, Vector3.Zero, 0);

            var sampleVehicle = BaseVehicle.Create(VehicleModelType.Alpha, Vector3.One * 10, 0, -1, -1);

            Console.WriteLine("Spawned sample vehicle " + sampleVehicle.Model);

            var cfg = new ServerConfig(Path.Combine(Client.ServerPath, "server.cfg"));

            foreach (var kv in cfg)
            {
                Console.WriteLine(kv.Key + " " + kv.Value);
            }
        }
Esempio n. 11
0
        bool?CanWearItem(PlayerInventory inventory, Item item)
        {
            BasePlayer  player        = inventory.containerWear.playerOwner;
            BaseVehicle mountedEntity = player.GetMountedVehicle();

            if (mountedEntity != null)
            {
                List <Item> newWearables = new List <Item>(player.inventory.containerWear.itemList);
                newWearables.Add(item);
                if (CheckAnyRestrictionsMatched(newWearables, player, mountedEntity, true))
                {
                    return(false);
                }
                return(null);
            }

            return(null);
        }
Esempio n. 12
0
        private object OnButtonPress(PressButton aButton, BasePlayer aPlayer)
        {
            BaseVehicle theVehicle = aButton.GetComponentInParent <BaseVehicle>()?.VehicleParent();

            theVehicle = theVehicle ? theVehicle : aButton.GetComponentInParent <BaseVehicle>();
            if (theVehicle)
            {
                SirenController theController = theVehicle.GetComponent <SirenController>();
                if (theController)
                {
                    if ((config.MountNeeded && aPlayer.GetMountedVehicle() != theVehicle) || !theController.NetIDs.Contains(aButton.net.ID))
                    {
                        return(false);
                    }
                    theController.ChangeState();
                }
            }
            return(null);
        }
    internal override void OnEntityEnter(BaseEntity ent)
    {
        base.OnEntityEnter(ent);
        if (ent == null)
        {
            return;
        }
        BasePlayer component = ent.GetComponent <BasePlayer>();

        if (component == null || !component.IsAlive() || component.IsSleeping() || component.IsNpc)
        {
            return;
        }
        if (this.triggeredPlayers.Contains(component.userID))
        {
            return;
        }
        if (!string.IsNullOrEmpty(this.requiredVehicleName))
        {
            BaseVehicle mountedVehicle = component.GetMountedVehicle();
            if (mountedVehicle == null)
            {
                return;
            }
            if (!mountedVehicle.ShortPrefabName.Contains(this.requiredVehicleName))
            {
                return;
            }
        }
        if (this.serverSide)
        {
            if (!string.IsNullOrEmpty(this.achievementOnEnter))
            {
                component.GiveAchievement(this.achievementOnEnter);
            }
            if (!string.IsNullOrEmpty(this.statToIncrease))
            {
                component.stats.Add(this.statToIncrease, 1, Stats.Steam);
                component.stats.Save();
            }
            this.triggeredPlayers.Add(component.userID);
        }
    }
 void OnPlayerInput(BasePlayer player, InputState input)
 {
     if (!config.addSearchLight || player == null || input == null)
     {
         return;
     }
     if (player.isMounted)
     {
         BaseVehicle vehicle = player.GetMountedVehicle();
         if (vehicle != null && vehicle is MiniCopter && input.WasJustPressed(BUTTON.USE))
         {
             ToggleMiniLights(vehicle as MiniCopter);
         }
     }
     else if (input.WasJustPressed(BUTTON.RELOAD) && player.GetActiveItem() == null && !player.isMounted)
     {
         GetTargetEntity(player);
     }
 }
Esempio n. 15
0
        private async Task UpdateVehicleToBodyStyleConfigDocuments(BaseVehicle updatedBaseVehicle)
        {
            bool isEndReached = false;
            int  pageNumber   = 1;

            do
            {
                var vehicleToBodyStyleConfigSearchResult =
                    await
                    _vehicleToBodyStyleConfigSearchService.SearchAsync(null,
                                                                       $"baseVehicleId eq {updatedBaseVehicle.Id}", new SearchOptions()
                {
                    RecordCount = 1000, PageNumber = pageNumber
                });

                var existingVehicleToBodyStyleConfigDocuments = vehicleToBodyStyleConfigSearchResult.Documents;

                if (existingVehicleToBodyStyleConfigDocuments != null &&
                    existingVehicleToBodyStyleConfigDocuments.Any())
                {
                    foreach (
                        var existingVehicleToBodyStyleConfigDocument in
                        existingVehicleToBodyStyleConfigDocuments)
                    {
                        existingVehicleToBodyStyleConfigDocument.MakeId    = updatedBaseVehicle.MakeId;
                        existingVehicleToBodyStyleConfigDocument.MakeName  = updatedBaseVehicle.Make.Name;
                        existingVehicleToBodyStyleConfigDocument.ModelId   = updatedBaseVehicle.ModelId;
                        existingVehicleToBodyStyleConfigDocument.ModelName = updatedBaseVehicle.Model.Name;
                        existingVehicleToBodyStyleConfigDocument.YearId    = updatedBaseVehicle.YearId;
                    }

                    await
                    this._vehicleToBodyStyleConfigIndexingService.UploadDocumentsAsync(
                        existingVehicleToBodyStyleConfigDocuments.ToList());

                    pageNumber++;
                }
                else
                {
                    isEndReached = true;
                }
            } while (!isEndReached);
        }
Esempio n. 16
0
        private static void CloneCarCommand(BasePlayer player)
        {
            if (clone == null)
            {
                player.SendClientMessage("You don't have a clone! Type /clone to spawn it.");
                return;
            }

            if (clone.IsAiming)
            {
                clone.StopAim();
            }

            player.SendClientMessage("Your clone will now enter a car.");

            var pos = GetPositionInFront(clone.Position, clone.Angle - 90, 5f);
            var v   = BaseVehicle.Create(VehicleModelType.Rancher, pos, clone.Angle, 0, 0);

            clone.EnterVehicle(v, 0, MoveType.Walk);
        }
Esempio n. 17
0
        private void ToggleSirens(IPlayer aPlayer, string aCommand, string[] someArgs)
        {
            if (aPlayer.IsServer)
            {
                Message(aPlayer, I18N_PLAYERS_ONLY, aCommand);
                return;
            }

            BasePlayer  thePlayer  = aPlayer.Object as BasePlayer;
            BaseVehicle theVehicle = thePlayer?.GetMountedVehicle();

            if (theVehicle)
            {
                theVehicle.GetComponent <SirenController>()?.ChangeState();
            }
            else if (!config.MountNeeded)
            {
                RaycastVehicle(aPlayer)?.GetComponent <SirenController>()?.ChangeState();;
            }
        }
Esempio n. 18
0
        public async Task <IHttpActionResult> Put(int id, BaseVehicleInputModel changeBaseVehicle)
        {
            BaseVehicle baseVehicle = new BaseVehicle()
            {
                Id           = changeBaseVehicle.Id,
                MakeId       = changeBaseVehicle.MakeId,
                ModelId      = changeBaseVehicle.ModelId,
                YearId       = changeBaseVehicle.YearId,
                VehicleCount = changeBaseVehicle.VehicleCount,
            };
            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = changeBaseVehicle.Comment
            };
            var attachments = SetUpAttachmentsModels(changeBaseVehicle.Attachments);

            var changeRequestId = await _baseVehicleApplicationService.UpdateAsync(baseVehicle, baseVehicle.Id, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
Esempio n. 19
0
    public virtual bool HasValidDismountPosition(BasePlayer player)
    {
        BaseVehicle baseVehicle = VehicleParent();

        if (baseVehicle != null)
        {
            return(baseVehicle.HasValidDismountPosition(player));
        }
        Vector3 visualCheckOrigin = player.TriggerPoint();

        Transform[] array = dismountPositions;
        foreach (Transform transform in array)
        {
            if (ValidDismountPosition(transform.transform.position, visualCheckOrigin))
            {
                return(true);
            }
        }
        return(false);
    }
Esempio n. 20
0
    public virtual Vector3 GetDismountPosition(BasePlayer player)
    {
        BaseVehicle baseVehicle = this.VehicleParent();

        if (Object.op_Inequality((Object)baseVehicle, (Object)null))
        {
            return(baseVehicle.GetDismountPosition(player));
        }
        int num = 0;

        foreach (Transform dismountPosition in this.dismountPositions)
        {
            if (this.ValidDismountPosition(((Component)dismountPosition).get_transform().get_position()))
            {
                return(((Component)dismountPosition).get_transform().get_position());
            }
            ++num;
        }
        Debug.LogWarning((object)("Failed to find dismount position for player :" + player.displayName + " / " + (object)player.userID + " on obj : " + ((Object)((Component)this).get_gameObject()).get_name()));
        return(BaseMountable.DISMOUNT_POS_INVALID);
    }
        private static void AdjustFuel(BaseVehicle vehicle, int desiredFuelAmount)
        {
            var fuelSystem = vehicle.GetFuelSystem();

            if (fuelSystem == null)
            {
                return;
            }

            var fuelAmount = desiredFuelAmount < 0
                ? fuelSystem.GetFuelContainer().allowedItem.stackable
                : desiredFuelAmount;

            var fuelItem = fuelSystem.GetFuelItem();

            if (fuelItem != null && fuelItem.amount != fuelAmount)
            {
                fuelItem.amount = fuelAmount;
                fuelItem.MarkDirty();
            }
        }
Esempio n. 22
0
        void OnEntitySpawned(BaseNetworkable entity)
        {
            _instance = this;
            if (entity == null || !(entity is MiniCopter || entity is RidableHorse))
            {
                return;
            }
            BaseVehicle vehicle = entity as BaseVehicle;

            seats = vehicle.mountPoints.Count; // default

            if (entity is MiniCopter && entity.ShortPrefabName.Equals("minicopter.entity"))
            {
                if (_instance.config.EnableMiniSideSeats)
                {
                    seats += 2;
                }
                if (_instance.config.EnableMiniBackSeat)
                {
                    seats += 1;
                }

                if (vehicle.mountPoints.Count < seats)
                {
                    vehicle?.gameObject.AddComponent <Seating>();
                }
            }
            if (entity is RidableHorse)
            {
                if (_instance.config.EnableExtraHorseSeat)
                {
                    seats += 1;
                }
                if (vehicle.mountPoints.Count < seats)
                {
                    vehicle?.gameObject.AddComponent <Seating>();
                }
            }
        }
Esempio n. 23
0
        public RaceCreator(Player _player)
        {
            player = _player;
            player.KeyStateChanged     += Player_KeyStateChanged;
            player.EnterCheckpoint     += Player_EnterCheckpoint;
            player.EnterRaceCheckpoint += Player_EnterRaceCheckpoint;

            if (!player.InAnyVehicle)
            {
                BaseVehicle veh = BaseVehicle.Create(VehicleModelType.Infernus, player.Position + new Vector3(0.0, 5.0, 0.0), 0.0f, 1, 1);
                player.PutInVehicle(veh);
            }

            hud = new HUD(_player);

            editingRace     = null;
            isEditing       = false;
            editingMode     = EditingMode.Checkpoints;
            checkpointIndex = 0;

            spawnVehicles = new BaseVehicle[Race.MAX_PLAYERS_IN_RACE];
        }
Esempio n. 24
0
        public DynamicTextLabel(string text, Color color, Vector3 position, float drawdistance, float streamdistance,
                                BasePlayer attachedPlayer = null, BaseVehicle attachedVehicle = null, bool testLOS = false,
                                int[] worlds = null, int[] interiors = null, BasePlayer[] players = null, DynamicArea[] areas = null,
                                int priority = 0)
        {
            if (worlds == null)
            {
                worlds = new[] { -1 }
            }
            ;
            if (interiors == null)
            {
                interiors = new[] { -1 }
            }
            ;
            var pl = players?.Select(p => p.Id).ToArray() ?? new[] { -1 };
            var ar = areas?.Select(a => a.Id).ToArray() ?? new[] { -1 };

            Id = Internal.CreateDynamic3DTextLabelEx(text, color, position.X, position.Y, position.Z, drawdistance,
                                                     attachedPlayer?.Id ?? BasePlayer.InvalidId, attachedVehicle?.Id ?? BaseVehicle.InvalidId, testLOS,
                                                     streamdistance, worlds, interiors, pl, ar, priority, worlds.Length, interiors.Length, pl.Length,
                                                     ar.Length);
        }
Esempio n. 25
0
        public StaticVehicleStats(BaseVehicle vehicleStock, ListVehicleProfile[] topSuspensionEngineProfiles)
        {
            var profile = topSuspensionEngineProfiles.First();

            int[] profileIDs = profile.profile_id.Split('-').Select(i => Convert.ToInt32(i)).ToArray();
            EngineID     = profileIDs.First(i => vehicleStock.engines.Contains(i));
            SuspensionID = profileIDs.First(i => i != EngineID && vehicleStock.suspensions.Contains(i));
            var engine = API.ENGINES[EngineID];
            var tracks = API.SUSPENSIONS[SuspensionID];

            BaseWeight   = profile.hull_weight + engine.weight + tracks.weight;
            StockWeight  = vehicleStock.default_profile.weight;
            BaseHP       = vehicleStock.default_profile.hull_hp;
            BaseTraverse = tracks.traverse_speed;

            HorsePower    = engine.power;
            BaseTraverse  = tracks.traverse_speed * ((double)engine.power / vehicleStock.default_profile.engine.power);
            SpeedForward  = profile.speed_forward;
            SpeedBackward = profile.speed_backward;

            Info        = new VehicleInfo(vehicleStock);
            SignalRange = profile.signal_range;
            HullArmor   = new ArmorStats(profile.armor.hull);
            FireChance  = engine.fire_chance;
            LoadLimit   = tracks.load_limit;

            GunArcLeft  = vehicleStock.default_profile.turret.traverse_left_arc;
            GunArcRight = vehicleStock.default_profile.turret.traverse_right_arc;

            Name     = vehicleStock.name;
            Tier     = vehicleStock.tier;
            ID       = vehicleStock.tank_id;
            Guns     = vehicleStock.guns;
            Turrets  = vehicleStock.turrets;
            Profiles = topSuspensionEngineProfiles.Select(p => new DynamicVehicleStats(p, this)).ToArray();
        }
Esempio n. 26
0
        /// <summary>
        ///     Gets the value for the occurance of this parameter type at the start of the commandText. The processed text will be
        ///     removed from the commandText.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="output">The output.</param>
        /// <param name="isNullable">A value indicating whether the result is allowed to be null when an entity referenced by the argument could not be found.</param>
        /// <returns>
        ///     true if parsed successfully; false otherwise.
        /// </returns>
        public bool Parse(ref string commandText, out object output, bool isNullable)
        {
            var text = commandText.TrimStart();

            output = null;

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            var word = text.Split(' ').First();

            // find a vehicle with a matching id.
            if (!int.TryParse(word, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id))
            {
                return(false);
            }

            var vehicle = BaseVehicle.Find(id);

            if (vehicle != null || isNullable)
            {
                commandText = word.Length == commandText.Length
                    ? string.Empty
                    : commandText.Substring(word.Length).TrimStart(' ');
            }

            if (vehicle == null)
            {
                return(isNullable);
            }

            output = vehicle;
            return(true);
        }
Esempio n. 27
0
        public static async void RearCommand(BasePlayer player)
        {
            var labels = new List <TextLabel>();

            foreach (var vehicle in BaseVehicle.All)
            {
                var model = vehicle.Model;

                var size   = BaseVehicle.GetModelInfo(model, VehicleModelInfoType.Size);
                var bumper = BaseVehicle.GetModelInfo(model, VehicleModelInfoType.RearBumperZ);
                var offset = new Vector3(0, -size.Y / 2, bumper.Z);

                var rotation = vehicle.GetRotationQuat();

                //rotation = new Quaternion(-rotation.X, -rotation.Y, -rotation.Z, rotation.W);

                var mRotation = rotation.LengthSquared > 10000 // Unoccupied vehicle updates corrupt the internal vehicle world matrix
                    ? Matrix.CreateRotationZ(MathHelper.ToRadians(vehicle.Angle))
                    : Matrix.CreateFromQuaternion(rotation);

                var matrix = Matrix.CreateTranslation(offset) *
                             mRotation *
                             Matrix.CreateTranslation(vehicle.Position);

                var point = matrix.Translation;

                labels.Add(new TextLabel("[x]", Color.Blue, point, 100, 0, false));
            }

            await Task.Delay(10000);

            foreach (var l in labels)
            {
                l.Dispose();
            }
        }
Esempio n. 28
0
        public static void OnPortVehicleCommand(Player sender, BaseVehicle vehicle)
        {
            if (sender.Account.Jailed != 0)
            {
                sender.SendClientMessage(Color.Red, Messages.CommandOnlyIfNotJailed);
                return;
            }

            if (sender.Account.Wanted != 0)
            {
                sender.SendClientMessage(Color.Red, Messages.MustBeInnocent);
                return;
            }

            if (vehicle == null)
            {
                sender.SendClientMessage(Color.Red, Messages.VehicleIsNotValid);
                return;
            }

            sender.Position = vehicle.Position + new Vector3(0, 0, 5);
            sender.SendClientMessage(Color.GreenYellow,
                                     $"You have been ported to location: {vehicle.Position.X} {vehicle.Position.Y} {vehicle.Position.Z + 5.0f}");
        }
Esempio n. 29
0
        public static void swapseats(Arg arg)
        {
            int        targetSeat = 0;
            BasePlayer basePlayer = ArgEx.Player(arg);

            if (basePlayer == null || basePlayer.SwapSeatCooldown())
            {
                return;
            }
            BaseMountable mounted = basePlayer.GetMounted();

            if (!(mounted == null))
            {
                BaseVehicle baseVehicle = mounted.GetComponent <BaseVehicle>();
                if (baseVehicle == null)
                {
                    baseVehicle = mounted.VehicleParent();
                }
                if (!(baseVehicle == null))
                {
                    baseVehicle.SwapSeats(basePlayer, targetSeat);
                }
            }
        }
        private void HandleSpawn(BaseVehicle vehicle)
        {
            if (Rust.Application.isLoadingSave)
            {
                return;
            }

            NextTick(() =>
            {
                if (vehicle.creatorEntity == null)
                {
                    return;
                }

                var vehicleConfig = GetVehicleConfig(vehicle);
                if (vehicleConfig == null)
                {
                    return;
                }

                AdjustFuel(vehicle, vehicleConfig.FuelAmount);
                MaybeSetOwner(vehicle);
            });
        }
Esempio n. 31
0
 /// <summary>
 ///     Raises the <see cref="VehicleResprayed" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="VehicleResprayedEventArgs" /> that contains the event data. </param>
 protected virtual void OnVehicleResprayed(BaseVehicle vehicle, VehicleResprayedEventArgs e)
 {
     VehicleResprayed?.Invoke(vehicle, e);
 }
Esempio n. 32
0
 /// <summary>
 ///     Raises the <see cref="VehicleSirenStateChange" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle.</param>
 /// <param name="e">The <see cref="SirenStateEventArgs" /> instance containing the event data.</param>
 protected void OnVehicleSirenStateChange(BaseVehicle vehicle, SirenStateEventArgs e)
 {
     VehicleSirenStateChange?.Invoke(vehicle, e);
 }
Esempio n. 33
0
 /// <summary>
 ///     Raises the <see cref="VehicleSpawned" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="EventArgs" /> that contains the event data. </param>
 protected virtual void OnVehicleSpawned(BaseVehicle vehicle, EventArgs e)
 {
     VehicleSpawned?.Invoke(vehicle, e);
 }
Esempio n. 34
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EnterVehicleEventArgs" /> class.
 /// </summary>
 /// <param name="player">The player.</param>
 /// <param name="vehicle">The vehicle.</param>
 /// <param name="isPassenger">if set to <c>true</c> the player is a passenger.</param>
 public EnterVehicleEventArgs(BasePlayer player, BaseVehicle vehicle, bool isPassenger)
 {
     Player = player;
     Vehicle = vehicle;
     IsPassenger = isPassenger;
 }
Esempio n. 35
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PlayerVehicleEventArgs" /> class.
 /// </summary>
 /// <param name="player">The player.</param>
 /// <param name="vehicle">The vehicle.</param>
 public PlayerVehicleEventArgs(BasePlayer player, BaseVehicle vehicle) : base(player)
 {
     Vehicle = vehicle;
 }
Esempio n. 36
0
 /// <summary>
 ///     Raises the <see cref="VehicleDied" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="PlayerEventArgs" /> that contains the event data. </param>
 protected virtual void OnVehicleDied(BaseVehicle vehicle, PlayerEventArgs e)
 {
     VehicleDied?.Invoke(vehicle, e);
 }
Esempio n. 37
0
        /// <summary>
        ///     Returns an instance of <see cref="VehicleModelInfo" /> containing information about the specified vehicle.
        /// </summary>
        /// <param name="vehicle">The vehicle to find information about.</param>
        /// <returns>An instance of <see cref="VehicleModelInfo" /> containing information about the specified vehicle.</returns>
        public static VehicleModelInfo ForVehicle(BaseVehicle vehicle)
        {
            if (vehicle == null)
            {
                throw new ArgumentNullException(nameof(vehicle));
            }

            var model = (int) vehicle.Model;

            if (model < 400 || model > 611)
            {
                throw new ArgumentOutOfRangeException(nameof(vehicle), "vehicle's model is non-existant");
            }

            return VehicleModelInfos[model - 400];
        }
Esempio n. 38
0
 /// <summary>
 ///     Raises the <see cref="TrailerUpdate" /> event.
 /// </summary>
 /// <param name="trailer">The trailer triggering the event.</param>
 /// <param name="e">An <see cref="PlayerVehicleEventArgs" /> that contains the event data. </param>
 protected virtual void OnTrailerUpdate(BaseVehicle trailer, TrailerEventArgs e)
 {
     TrailerUpdate?.Invoke(trailer, e);
 }
Esempio n. 39
0
 /// <summary>
 ///     Raises the <see cref="VehicleMod" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="VehicleModEventArgs" /> that contains the event data. </param>
 protected virtual void OnVehicleMod(BaseVehicle vehicle, VehicleModEventArgs e)
 {
     VehicleMod?.Invoke(vehicle, e);
 }
Esempio n. 40
0
 /// <summary>
 ///     Raises the <see cref="VehiclePaintjobApplied" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="VehiclePaintjobEventArgs" /> that contains the event data. </param>
 protected virtual void OnVehiclePaintjobApplied(BaseVehicle vehicle, VehiclePaintjobEventArgs e)
 {
     VehiclePaintjobApplied?.Invoke(vehicle, e);
 }
Esempio n. 41
0
 /// <summary>
 ///     Raises the <see cref="VehicleStreamOut" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="PlayerVehicleEventArgs" /> that contains the event data. </param>
 protected virtual void OnVehicleStreamOut(BaseVehicle vehicle, PlayerEventArgs e)
 {
     VehicleStreamOut?.Invoke(vehicle, e);
 }
Esempio n. 42
0
 /// <summary>
 ///     Raises the <see cref="UnoccupiedVehicleUpdated" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="UnoccupiedVehicleEventArgs" /> that contains the event data. </param>
 protected virtual void OnUnoccupiedVehicleUpdated(BaseVehicle vehicle, UnoccupiedVehicleEventArgs e)
 {
     UnoccupiedVehicleUpdated?.Invoke(vehicle, e);
 }
Esempio n. 43
0
 /// <summary>
 ///     Raises the <see cref="VehicleDamageStatusUpdated" /> event.
 /// </summary>
 /// <param name="vehicle">The vehicle triggering the event.</param>
 /// <param name="e">An <see cref="PlayerVehicleEventArgs" /> that contains the event data. </param>
 protected virtual void OnVehicleDamageStatusUpdated(BaseVehicle vehicle, PlayerEventArgs e)
 {
     VehicleDamageStatusUpdated?.Invoke(vehicle, e);
 }