Ejemplo n.º 1
0
        public HideablePart(Vehicle vehicle, VehicleGadgetEntry dataEntry) : base(vehicle, dataEntry)
        {
            hideablePartDataEntry = (HideablePartEntry)dataEntry;

            if (!VehicleBone.TryGetForVehicle(vehicle, hideablePartDataEntry.BoneName, out bone))
            {
                throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{hideablePartDataEntry.BoneName}\" for the {HideablePartEntry.XmlName}");
            }

            conditions = Conditions.GetConditionsFromString(vehicle.Model, hideablePartDataEntry.Conditions);
        }
Ejemplo n.º 2
0
        public static VehicleGadget[] GetGadgetsForVehicle(Vehicle vehicle)
        {
            if (Plugin.VehicleConfigsByModel.TryGetValue(vehicle.Model, out VehicleConfig config))
            {
                VehicleGadget[] g = new VehicleGadget[config.Gadgets.Length];
                for (int i = 0; i < config.Gadgets.Length; i++)
                {
                    VehicleGadgetEntry entry = config.Gadgets[i];
                    g[i] = (VehicleGadget)Activator.CreateInstance(entry.GadgetType, vehicle, entry);
                }
                return(g);
            }

            return(null);
        }
        public HideablePart(Vehicle vehicle, VehicleGadgetEntry dataEntry) : base(vehicle, dataEntry)
        {
            hideablePartDataEntry = (HideablePartEntry)dataEntry;

            if (!VehicleBone.TryGetForVehicle(vehicle, hideablePartDataEntry.BoneName, out bone))
            {
                throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{hideablePartDataEntry.BoneName}\" for the {HideablePartEntry.XmlName}");
            }

            conditions = Conditions.GetConditionsFromString(vehicle.Model, hideablePartDataEntry.Conditions);

            nativeVeh  = (CVehicle *)vehicle.MemoryAddress;
            boundIndex = GameFunctions.fragInst_GetBoundIndexForBone(nativeVeh->Inst, bone.Index);
            hasBound   = boundIndex != -1;
        }
Ejemplo n.º 4
0
        public RotatingPart(Vehicle vehicle, VehicleGadgetEntry dataEntry) : base(vehicle, dataEntry)
        {
            rotatingPartDataEntry = (RotatingPartEntry)dataEntry;

            if (!VehicleBone.TryGetForVehicle(vehicle, rotatingPartDataEntry.BoneName, out bone))
            {
                throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{rotatingPartDataEntry.BoneName}\" for the {RotatingPartEntry.XmlName}");
            }

            conditions = Conditions.GetConditionsFromString(vehicle.Model, rotatingPartDataEntry.Conditions);

            if (rotatingPartDataEntry.HasRange)
            {
                hasRange = true;

                Quaternion min = Quaternion.RotationAxis(rotatingPartDataEntry.RotationAxis, MathHelper.ConvertDegreesToRadians(rotatingPartDataEntry.Range.Min));
                Quaternion max = Quaternion.RotationAxis(rotatingPartDataEntry.RotationAxis, MathHelper.ConvertDegreesToRadians(rotatingPartDataEntry.Range.Max));

                rangeMin = bone.OriginalRotation * min;
                rangeMax = bone.OriginalRotation * max;
            }
        }
Ejemplo n.º 5
0
        public Outriggers(Vehicle vehicle, VehicleGadgetEntry dataEntry) : base(vehicle, dataEntry)
        {
            outriggersDataEntry = (OutriggersEntry)dataEntry;

            outriggers = new Outrigger[outriggersDataEntry.Outriggers.Length];

            for (int i = 0; i < outriggersDataEntry.Outriggers.Length; i++)
            {
                outriggers[i] = new Outrigger(vehicle, outriggersDataEntry.Outriggers[i]);
            }

            if (outriggersDataEntry.HasSoundsSet)
            {
                Sound begin = null, loop = null, end = null;

                begin = outriggersDataEntry.SoundsSet.HasBegin ?
                        outriggersDataEntry.SoundsSet.IsDefaultBegin ?
                        null :
                        new Sound(false, outriggersDataEntry.SoundsSet.NormalizedVolume, () => outriggersDataEntry.SoundsSet.BeginSoundFilePath) :
                        null;

                loop = outriggersDataEntry.SoundsSet.HasLoop ?
                       outriggersDataEntry.SoundsSet.IsDefaultLoop ?
                       new Sound(true, outriggersDataEntry.SoundsSet.NormalizedVolume, () => Properties.Resources.default_outriggers_loop) :
                       new Sound(true, outriggersDataEntry.SoundsSet.NormalizedVolume, () => outriggersDataEntry.SoundsSet.LoopSoundFilePath) :
                       null;

                end = outriggersDataEntry.SoundsSet.HasEnd ?
                      outriggersDataEntry.SoundsSet.IsDefaultEnd ?
                      null :
                      new Sound(false, outriggersDataEntry.SoundsSet.NormalizedVolume, () => outriggersDataEntry.SoundsSet.EndSoundFilePath) :
                      null;

                sound = new SoundEffect(begin, loop, end);
            }
        }
Ejemplo n.º 6
0
 protected VehicleGadget(Vehicle vehicle, VehicleGadgetEntry dataEntry)
 {
     Vehicle   = vehicle;
     DataEntry = dataEntry;
 }
Ejemplo n.º 7
0
        public Ladder(Vehicle vehicle, VehicleGadgetEntry dataEntry) : base(vehicle, dataEntry)
        {
            ladderDataEntry = (LadderEntry)dataEntry;

            if (ladderDataEntry.HasBase)
            {
                if (!VehicleBone.TryGetForVehicle(vehicle, ladderDataEntry.Base.BoneName, out ladderBase))
                {
                    throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{ladderDataEntry.Base.BoneName}\" for the Ladder Base");
                }
            }

            if (ladderDataEntry.HasMain)
            {
                if (!VehicleBone.TryGetForVehicle(vehicle, ladderDataEntry.Main.BoneName, out ladderMain))
                {
                    throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{ladderDataEntry.Main.BoneName}\" for the Ladder Main");
                }
            }

            if (ladderDataEntry.HasExtensions)
            {
                ladderExtensions = new Extension[ladderDataEntry.Extensions.Parts.Length];

                for (int i = 0; i < ladderDataEntry.Extensions.Parts.Length; i++)
                {
                    if (!VehicleBone.TryGetForVehicle(vehicle, ladderDataEntry.Extensions.Parts[i].BoneName, out VehicleBone extensionBone))
                    {
                        throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{ladderDataEntry.Extensions.Parts[i].BoneName}\" for the Ladder Extension #{i}");
                    }

                    ladderExtensions[i] = new Extension(this, ladderDataEntry.Extensions.Parts[i], ladderDataEntry.Extensions.Direction, extensionBone);
                }
            }

            if (ladderDataEntry.HasBucket)
            {
                if (!VehicleBone.TryGetForVehicle(vehicle, ladderDataEntry.Bucket.BoneName, out ladderBucket))
                {
                    throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{ladderDataEntry.Bucket.BoneName}\" for the Ladder Bucket");
                }
            }

            if (ladderDataEntry.HasSoundsSet)
            {
                Sound begin = null, loop = null, end = null;

                begin = ladderDataEntry.SoundsSet.HasBegin ?
                        ladderDataEntry.SoundsSet.IsDefaultBegin ?
                        null :
                        new Sound(false, ladderDataEntry.SoundsSet.NormalizedVolume, () => ladderDataEntry.SoundsSet.BeginSoundFilePath) :
                        null;

                loop = ladderDataEntry.SoundsSet.HasLoop ?
                       ladderDataEntry.SoundsSet.IsDefaultLoop ?
                       new Sound(true, ladderDataEntry.SoundsSet.NormalizedVolume, () => Properties.Resources.default_ladder_loop) :
                       new Sound(true, ladderDataEntry.SoundsSet.NormalizedVolume, () => ladderDataEntry.SoundsSet.LoopSoundFilePath) :
                       null;

                end = ladderDataEntry.SoundsSet.HasEnd ?
                      ladderDataEntry.SoundsSet.IsDefaultEnd ?
                      new Sound(false, ladderDataEntry.SoundsSet.NormalizedVolume, () => Properties.Resources.default_ladder_end) :
                      new Sound(false, ladderDataEntry.SoundsSet.NormalizedVolume, () => ladderDataEntry.SoundsSet.EndSoundFilePath) :
                      null;

                sound = new SoundEffect(begin, loop, end);
            }
        }