Example #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);
        }
        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;
        }
            public Outrigger(Vehicle vehicle, OutriggersEntry.Outrigger data)
            {
                this.vehicle = vehicle;
                this.data    = data;

                extensionDirection = data.ExtensionDirection;
                supportDirection   = data.SupportDirection;

                if (!VehicleBone.TryGetForVehicle(vehicle, data.ExtensionBoneName, out extensionBone))
                {
                    throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{data.ExtensionBoneName}\" for the Outrigger Extension");
                }

                if (!VehicleBone.TryGetForVehicle(vehicle, data.SupportBoneName, out supportBone))
                {
                    throw new InvalidOperationException($"The model \"{vehicle.Model.Name}\" doesn't have the bone \"{data.SupportBoneName}\" for the Outrigger Support");
                }
            }
Example #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;
            }
        }
        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);
            }
        }