public int ShootIntervalInMiliseconds; // derivative of Rate of fire

            public MyWeaponAmmoData(MyObjectBuilder_WeaponDefinition.WeaponAmmoData data) : this(data.RateOfFire, data.ShootSoundName, data.ShotsInBurst)
            {
            }
Exemplo n.º 2
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            MyObjectBuilder_WeaponDefinition definition = builder as MyObjectBuilder_WeaponDefinition;

            this.WeaponAmmoDatas = new MyWeaponAmmoData[Enum.GetValues(typeof(MyAmmoType)).Length];
            this.WeaponEffects   = new MyWeaponEffect[(definition.Effects == null) ? 0 : definition.Effects.Length];
            if (definition.Effects != null)
            {
                for (int j = 0; j < definition.Effects.Length; j++)
                {
                    this.WeaponEffects[j] = new MyWeaponEffect(definition.Effects[j].Action, definition.Effects[j].Dummy, definition.Effects[j].Particle, definition.Effects[j].Loop, definition.Effects[j].InstantStop);
                }
            }
            this.PhysicalMaterial      = MyStringHash.GetOrCompute(definition.PhysicalMaterial);
            this.UseDefaultMuzzleFlash = definition.UseDefaultMuzzleFlash;
            this.NoAmmoSound           = new MySoundPair(definition.NoAmmoSoundName, true);
            this.ReloadSound           = new MySoundPair(definition.ReloadSoundName, true);
            this.SecondarySound        = new MySoundPair(definition.SecondarySoundName, true);
            this.DeviateShotAngle      = MathHelper.ToRadians(definition.DeviateShotAngle);
            this.ReleaseTimeAfterFire  = definition.ReleaseTimeAfterFire;
            this.MuzzleFlashLifeSpan   = definition.MuzzleFlashLifeSpan;
            this.ReloadTime            = definition.ReloadTime;
            this.DamageMultiplier      = definition.DamageMultiplier;
            this.RangeMultiplier       = definition.RangeMultiplier;
            this.UseRandomizedRange    = definition.UseRandomizedRange;
            this.AmmoMagazinesId       = new MyDefinitionId[definition.AmmoMagazines.Length];
            for (int i = 0; i < this.AmmoMagazinesId.Length; i++)
            {
                MyObjectBuilder_WeaponDefinition.WeaponAmmoMagazine magazine = definition.AmmoMagazines[i];
                this.AmmoMagazinesId[i] = new MyDefinitionId(magazine.Type, magazine.Subtype);
                MyAmmoMagazineDefinition ammoMagazineDefinition = MyDefinitionManager.Static.GetAmmoMagazineDefinition(this.AmmoMagazinesId[i]);
                MyAmmoType ammoType = MyDefinitionManager.Static.GetAmmoDefinition(ammoMagazineDefinition.AmmoDefinitionId).AmmoType;
                string     str      = null;
                if (ammoType == MyAmmoType.HighSpeed)
                {
                    if (definition.ProjectileAmmoData != null)
                    {
                        this.WeaponAmmoDatas[0] = new MyWeaponAmmoData(definition.ProjectileAmmoData);
                    }
                    else
                    {
                        str = string.Format(ErrorMessageTemplate, "projectile", "Projectile");
                    }
                }
                else
                {
                    if (ammoType != MyAmmoType.Missile)
                    {
                        throw new NotImplementedException();
                    }
                    if (definition.MissileAmmoData != null)
                    {
                        this.WeaponAmmoDatas[1] = new MyWeaponAmmoData(definition.MissileAmmoData);
                    }
                    else
                    {
                        str = string.Format(ErrorMessageTemplate, "missile", "Missile");
                    }
                }
                if (!string.IsNullOrEmpty(str))
                {
                    MyDefinitionErrors.Add(base.Context, str, TErrorSeverity.Critical, true);
                }
            }
        }