Example #1
0
        /// <summary>
        /// Creates an IS_HCP packet and sets the various car handicaps.
        /// </summary>
        /// <param name="cars">The cars to set the handicap for.</param>
        /// <param name="H_Mass">The added mass to set in kilograms (0 - 200).</param>
        /// <param name="H_TRes">The intake restriction to set (0 - 50).</param>
        /// <returns>An IS_HCP packet.</returns>
        public static IS_HCP SetHandicap(CarFlags cars, byte H_Mass = 0, byte H_TRes = 0)
        {
            var packet = new IS_HCP();

            SetHandicap(packet, cars, H_Mass, H_TRes);
            return(packet);
        }
 /// <summary>
 /// Sets the handicap for the specified cars.
 /// </summary>
 /// <param name="packet">The <see cref="IS_HCP"/> packet containing the handicaps.</param>
 /// <param name="cars">The cars to set the handicap for.</param>
 /// <param name="H_Mass">The added mass to set in kilograms (0 - 200).</param>
 /// <param name="H_TRes">The intake restriction to set (0 - 50).</param>
 public static void SetHandicap(IS_HCP packet, CarFlags cars, byte H_Mass = 0, byte H_TRes = 0) {
     foreach (KeyValuePair<CarFlags, byte> map in CarMap) {
         if (cars.HasFlag(CarFlags.All) || cars.HasFlag(map.Key)) {
             packet.Info[map.Value].H_Mass = H_Mass;
             packet.Info[map.Value].H_TRes = H_TRes;
         }
     }
 }
        public CargoParcel(ushort buildingID, bool incoming, byte transferType, ushort transferSize, Vehicle.Flags flags)
        {
            this.transferSize = transferSize;
            this.building     = buildingID;
            this.flags        = incoming ? CarFlags.None: CarFlags.Sent;

            if ((flags & Vehicle.Flags.Exporting) != 0)
            {
                this.flags |= CarFlags.Exported;
            }
            else if ((flags & Vehicle.Flags.Importing) != 0)
            {
                this.flags |= CarFlags.Imported;
            }

            switch ((TransferType)transferType)
            {
            case TransferType.Oil:
                this.flags |= CarFlags.Oil;
                break;

            case TransferType.Ore:
                this.flags |= CarFlags.Ore;
                break;

            case TransferType.Logs:
                this.flags |= CarFlags.Logs;
                break;

            case TransferType.Grain:
                this.flags |= CarFlags.Grain;
                break;

            case TransferType.Petrol:
                this.flags |= CarFlags.Petrol;
                break;

            case TransferType.Coal:
                this.flags |= CarFlags.Coal;
                break;

            case TransferType.Lumber:
                this.flags |= CarFlags.Lumber;
                break;

            case TransferType.Food:
                this.flags |= CarFlags.Food;
                break;

            case TransferType.Goods:
                this.flags |= CarFlags.Goods;
                break;

            default:
                Debug.LogErrorFormat("Unexpected transfer type: {0}", Enum.GetName(typeof(TransferType), transferType));
                break;
            }
        }
Example #4
0
 /// <summary>
 /// Sets the handicap for the specified cars.
 /// </summary>
 /// <param name="packet">The <see cref="IS_HCP"/> packet containing the handicaps.</param>
 /// <param name="cars">The cars to set the handicap for.</param>
 /// <param name="H_Mass">The added mass to set in kilograms (0 - 200).</param>
 /// <param name="H_TRes">The intake restriction to set (0 - 50).</param>
 public static void SetHandicap(IS_HCP packet, CarFlags cars, byte H_Mass = 0, byte H_TRes = 0)
 {
     foreach (KeyValuePair <CarFlags, byte> map in CarMap)
     {
         if (cars.HasFlag(CarFlags.All) || cars.HasFlag(map.Key))
         {
             packet.Info[map.Value].H_Mass = H_Mass;
             packet.Info[map.Value].H_TRes = H_TRes;
         }
     }
 }
Example #5
0
        //========= CONSTRUCTORS =========
        #region Constructors

        /** <summary> Constructs the default attraction car header. </summary> */
        public CarHeader()
        {
            this.LastRotationFrame = 0;
            this.Reserved0x01      = new byte[3];

            this.Unknown0x04 = 0;

            this.CarSpacing    = 0;
            this.Reserved0x07  = 0;
            this.CarFriction   = 0;
            this.CarTabHeight  = 0;
            this.RiderSettings = 0;
            this.SpriteFlags   = CarSpriteFlags.None;

            this.Unknown0x0E = new byte[3];
            for (int i = 0; i < this.Unknown0x0E.Length; i++)
            {
                this.Unknown0x0E[i] = 0;
            }

            this.Flags = CarFlags.None;

            this.Reserved0x16 = new byte[59];
            for (int i = 0; i < this.Reserved0x16.Length; i++)
            {
                this.Reserved0x16[i] = 0;
            }

            this.RiderSprites     = 0;
            this.SpinningInertia  = 0;
            this.SpinningFriction = 0;

            this.Unknown0x57 = new byte[4];
            for (int i = 0; i < this.Unknown0x57.Length; i++)
            {
                this.Unknown0x57[i] = 0;
            }

            this.PoweredAcceleration = 0;
            this.PoweredMaxSpeed     = 0;
            this.CarVisual           = CarVisuals.Default;
            this.UnknownSetting      = CarUnknownSettings.Default;
            this.DrawOrder           = 0;
            this.SpecialFrames       = 0;
            this.Reserved0x61        = 0;
        }
        //========= CONSTRUCTORS =========
        #region Constructors

        /**<summary>Constructs the default attraction car header.</summary>*/
        public CarHeader()
        {
            LastRotationFrame         = 0;
            NumVerticalFramesUnused   = 0;
            NumHorizontalFramesUnused = 0;

            Spacing       = 0;
            CarFriction   = 0;
            CarTabHeight  = 0;
            RiderSettings = 0;
            SpriteFlags   = CarSpriteFlags.None;

            SpriteWidth          = 0;
            SpriteHeightPositive = 0;
            SpriteHeightNegative = 0;

            Animation     = 0;
            Flags         = CarFlags.None;
            BaseNumFrames = 0;

            Reserved0x18 = new byte[60];
            for (int i = 0; i < Reserved0x18.Length; i++)
            {
                Reserved0x18[i] = 0;
            }

            RiderSprites     = 0;
            SpinningInertia  = 0;
            SpinningFriction = 0;

            FrictionSoundID = 0;
            Unknown0x58     = 0;
            SoundRange      = 0;
            Unknown0x5A     = 0;

            PoweredAcceleration = 0;
            PoweredMaxSpeed     = 0;
            CarVisual           = CarVisuals.Default;
            EffectVisual        = CarEffectVisuals.Default;
            DrawOrder           = 0;
            SpecialFrames       = 0;
            Reserved0x61        = 0;
        }
        //=========== READING ============
        #region Reading

        /**<summary>Reads the object header.</summary>*/
        public void Read(BinaryReader reader)
        {
            LastRotationFrame = reader.ReadUInt16();

            NumVerticalFramesUnused   = reader.ReadByte();
            NumHorizontalFramesUnused = reader.ReadByte();

            Spacing       = reader.ReadUInt32();
            CarFriction   = reader.ReadUInt16();
            CarTabHeight  = reader.ReadSByte();
            RiderSettings = reader.ReadByte();
            SpriteFlags   = (CarSpriteFlags)reader.ReadUInt16();

            SpriteWidth          = reader.ReadByte();
            SpriteHeightPositive = reader.ReadByte();
            SpriteHeightNegative = reader.ReadByte();

            Animation     = reader.ReadByte();
            Flags         = (CarFlags)reader.ReadUInt32();
            BaseNumFrames = reader.ReadUInt16();

            reader.Read(Reserved0x18, 0, Reserved0x18.Length);

            RiderSprites     = reader.ReadByte();
            SpinningInertia  = reader.ReadByte();
            SpinningFriction = reader.ReadByte();

            FrictionSoundID = reader.ReadByte();
            Unknown0x58     = reader.ReadByte();
            SoundRange      = reader.ReadByte();
            Unknown0x5A     = reader.ReadByte();

            PoweredAcceleration = reader.ReadByte();
            PoweredMaxSpeed     = reader.ReadByte();
            CarVisual           = (CarVisuals)reader.ReadByte();
            EffectVisual        = (CarEffectVisuals)reader.ReadByte();
            DrawOrder           = reader.ReadByte();
            SpecialFrames       = reader.ReadByte();

            Reserved0x61 = reader.ReadUInt32();
        }
Example #8
0
        //=========== READING ============
        #region Reading

        /** <summary> Reads the object header. </summary> */
        public void Read(BinaryReader reader)
        {
            this.LastRotationFrame = reader.ReadByte();

            reader.Read(this.Reserved0x01, 0, this.Reserved0x01.Length);

            this.Unknown0x04 = reader.ReadByte();

            this.CarSpacing    = reader.ReadUInt16();
            this.Reserved0x07  = reader.ReadByte();
            this.CarFriction   = reader.ReadUInt16();
            this.CarTabHeight  = reader.ReadByte();
            this.RiderSettings = reader.ReadByte();
            this.SpriteFlags   = (CarSpriteFlags)reader.ReadUInt16();

            reader.Read(this.Unknown0x0E, 0, this.Unknown0x0E.Length);

            this.Flags = (CarFlags)reader.ReadUInt64();

            reader.Read(this.Reserved0x16, 0, this.Reserved0x16.Length);

            this.RiderSprites     = reader.ReadByte();
            this.SpinningInertia  = reader.ReadByte();
            this.SpinningFriction = reader.ReadByte();

            reader.Read(this.Unknown0x57, 0, this.Unknown0x57.Length);

            this.PoweredAcceleration = reader.ReadByte();
            this.PoweredMaxSpeed     = reader.ReadByte();
            this.CarVisual           = (CarVisuals)reader.ReadByte();
            this.UnknownSetting      = (CarUnknownSettings)reader.ReadByte();
            this.DrawOrder           = reader.ReadByte();
            this.SpecialFrames       = reader.ReadByte();

            this.Reserved0x61 = reader.ReadUInt32();
        }
        public CargoParcel(ushort buildingID, bool incoming, byte transferType, ushort transferSize, Vehicle.Flags flags)
        {
            this.transferSize = transferSize;
            this.building     = buildingID;
            this.flags        = incoming ? CarFlags.None : CarFlags.Sent;

            if ((flags & Vehicle.Flags.Exporting) != 0)
            {
                this.flags |= CarFlags.Exported;
            }
            else if ((flags & Vehicle.Flags.Importing) != 0)
            {
                this.flags |= CarFlags.Imported;
            }

            switch ((TransferType)transferType)
            {
            case TransferType.Oil:
                this.flags |= CarFlags.Oil;
                break;

            case TransferType.Ore:
                this.flags |= CarFlags.Ore;
                break;

            case TransferType.Logs:
                this.flags |= CarFlags.Logs;
                break;

            case TransferType.Grain:
                this.flags |= CarFlags.Grain;
                break;

            case TransferType.Petrol:
                this.flags |= CarFlags.Petrol;
                break;

            case TransferType.Coal:
                this.flags |= CarFlags.Coal;
                break;

            case TransferType.Lumber:
                this.flags |= CarFlags.Lumber;
                break;

            case TransferType.Food:
                this.flags |= CarFlags.Food;
                break;

            case TransferType.Goods:
                this.flags |= CarFlags.Goods;
                break;

            case TransferType.Mail:
                this.flags |= CarFlags.Mail;
                break;

            case TransferType.UnsortedMail:
                this.flags |= CarFlags.UnsortedMail;
                break;

            case TransferType.SortedMail:
                this.flags |= CarFlags.SortedMail;
                break;

            case TransferType.OutgoingMail:
                this.flags |= CarFlags.OutgoingMail;
                break;

            case TransferType.IncomingMail:
                this.flags |= CarFlags.IncomingMail;
                break;

            case TransferType.AnimalProducts:
                this.flags |= CarFlags.AnimalProducts;
                break;

            case TransferType.Flours:
                this.flags |= CarFlags.Flours;
                break;

            case TransferType.Paper:
                this.flags |= CarFlags.Paper;
                break;

            case TransferType.PlanedTimber:
                this.flags |= CarFlags.PlanedTimber;
                break;

            case TransferType.Petroleum:
                this.flags |= CarFlags.Petroleum;
                break;

            case TransferType.Plastics:
                this.flags |= CarFlags.Plastics;
                break;

            case TransferType.Glass:
                this.flags |= CarFlags.Glass;
                break;

            case TransferType.Metals:
                this.flags |= CarFlags.Metals;
                break;

            case TransferType.LuxuryProducts:
                this.flags |= CarFlags.LuxuryProducts;
                break;

            default:
                Debug.LogErrorFormat("Unexpected transfer type: {0}", Enum.GetName(typeof(TransferType), transferType));
                break;
            }
        }
 /// <summary>
 /// Creates an IS_HCP packet and sets the various car handicaps.
 /// </summary>
 /// <param name="cars">The cars to set the handicap for.</param>
 /// <param name="H_Mass">The added mass to set in kilograms (0 - 200).</param>
 /// <param name="H_TRes">The intake restriction to set (0 - 50).</param>
 /// <returns>An IS_HCP packet.</returns>
 public static IS_HCP SetHandicap(CarFlags cars, byte H_Mass = 0, byte H_TRes = 0)
 {
     var packet = new IS_HCP();
     SetHandicap(packet, cars, H_Mass, H_TRes);
     return packet;
 }