Beispiel #1
0
        public void ApplyTo(Vehicle vehicle, SpawnFlags spawnFlags = SpawnFlags.Default)
        {
            ApplyTo2(vehicle, spawnFlags.HasFlag(SpawnFlags.NoOccupants));

            if (!spawnFlags.HasFlag(SpawnFlags.NoPosition))
            {
                vehicle.PositionNoOffset = Position;
                vehicle.Heading          = Heading;
                vehicle.Rotation         = Rotation;
            }

            if (spawnFlags.HasFlag(SpawnFlags.SetRotation))
            {
                vehicle.Rotation = Rotation;
            }

            if (!spawnFlags.HasFlag(SpawnFlags.NoVelocity))
            {
                vehicle.Velocity = Velocity;
                vehicle.Speed    = Speed;
            }

            if (spawnFlags.HasFlag(SpawnFlags.NoWheels))
            {
                return;
            }

            for (int i = 0; i < WheelsRotations.Length; i++)
            {
                VehicleControl.SetWheelRotation(vehicle, i, FusionUtils.Wrap(WheelsRotations[i], -(float)Math.PI, (float)Math.PI));
                VehicleControl.SetWheelCompression(vehicle, i, WheelsCompressions[i]);
            }
        }
Beispiel #2
0
        public void ApplyTo(Vehicle vehicle, SpawnFlags spawnFlags = SpawnFlags.Default, VehicleReplica nextReplica = default, float adjustedRatio = 0)
        {
            ApplyTo2(vehicle, spawnFlags.HasFlag(SpawnFlags.NoOccupants));

            if (nextReplica == default || nextReplica == null)
            {
                nextReplica = this;
            }

            if (!spawnFlags.HasFlag(SpawnFlags.NoPosition))
            {
                vehicle.PositionNoOffset = FusionUtils.Lerp(Position, nextReplica.Position, adjustedRatio);
                vehicle.Heading          = FusionUtils.Lerp(Heading, nextReplica.Heading, adjustedRatio);
                vehicle.Rotation         = FusionUtils.Lerp(Rotation, nextReplica.Rotation, adjustedRatio, -180, 180);
            }

            if (spawnFlags.HasFlag(SpawnFlags.SetRotation))
            {
                vehicle.Rotation = FusionUtils.Lerp(Rotation, nextReplica.Rotation, adjustedRatio, -180, 180);
            }

            if (!spawnFlags.HasFlag(SpawnFlags.NoVelocity))
            {
                vehicle.Velocity = FusionUtils.Lerp(Velocity, nextReplica.Velocity, adjustedRatio);
                vehicle.Speed    = FusionUtils.Lerp(Speed, nextReplica.Speed, adjustedRatio);
            }

            if (spawnFlags.HasFlag(SpawnFlags.NoWheels))
            {
                return;
            }

            for (int i = 0; i < WheelsRotations.Length; i++)
            {
                VehicleControl.SetWheelRotation(vehicle, i, FusionUtils.Lerp(WheelsRotations[i], nextReplica.WheelsRotations[i], adjustedRatio));
                VehicleControl.SetWheelCompression(vehicle, i, FusionUtils.Lerp(WheelsCompressions[i], nextReplica.WheelsCompressions[i], adjustedRatio));
            }
        }