Beispiel #1
0
 public WeaponBank(
     App game,
     IGameObject owner,
     LogicalBank bank,
     Module module,
     LogicalWeapon weapon,
     int weaponLevel,
     int designID,
     int targetFilter,
     int fireMode,
     WeaponEnums.WeaponSizes weaponSize,
     WeaponEnums.TurretClasses turretClass)
 {
     this.Owner           = owner;
     this.Weapon          = weapon;
     this.LogicalBank     = bank;
     this.Module          = module;
     this.WeaponLevel     = weaponLevel;
     this.DesignID        = designID;
     this.TargetFilter    = targetFilter;
     this.FireMode        = fireMode;
     this.TurretClass     = turretClass;
     this.WeaponSize      = weaponSize;
     this.m_ToggleStateOn = false;
 }
Beispiel #2
0
        public static WeaponModelPaths GetWeaponModelPaths(
            LogicalWeapon weapon,
            Faction faction)
        {
            WeaponModelPaths weaponModelPaths = new WeaponModelPaths();

            weaponModelPaths.ModelPath        = "";
            weaponModelPaths.DefaultModelPath = "";
            if (weapon != null && !string.IsNullOrEmpty(weapon.Model))
            {
                weaponModelPaths.ModelPath        = faction.GetWeaponModelPath(weapon.Model);
                weaponModelPaths.DefaultModelPath = "props\\Weapons\\" + weapon.Model;
            }
            return(weaponModelPaths);
        }
Beispiel #3
0
        public static IEnumerable <LogicalWeapon> Enumerate(App app)
        {
            string[]             files             = ScriptHost.FileSystem.FindFiles("weapons\\*.weapon");
            List <LogicalWeapon> logicalWeaponList = new List <LogicalWeapon>();
            int uniqueWeaponID = 0;

            foreach (string weaponFile in files)
            {
                ++uniqueWeaponID;
                try
                {
                    LogicalWeapon logicalWeaponFromFile = WeaponLibrary.CreateLogicalWeaponFromFile(app, weaponFile, uniqueWeaponID);
                    logicalWeaponList.Add(logicalWeaponFromFile);
                }
                catch (Exception ex)
                {
                    App.Log.Trace(string.Format("Weapon failed to load: {0} \r\n Exception: {1}", (object)weaponFile, (object)ex.Message), "data");
                }
            }
            return((IEnumerable <LogicalWeapon>)logicalWeaponList);
        }
Beispiel #4
0
 public PlanetWeaponBank(
     App game,
     IGameObject owner,
     LogicalBank bank,
     Module module,
     LogicalWeapon weapon,
     int weaponLevel,
     LogicalWeapon subWeapon,
     WeaponEnums.TurretClasses tClass,
     string model,
     string subModel,
     float thinkTime,
     int numLaunchers)
     : base(game, owner, bank, module, weapon, weaponLevel, 0, 0, 0, weapon.DefaultWeaponSize, tClass)
 {
     this.SubWeapon      = subWeapon;
     this.WeaponModel    = model;
     this.SubWeaponModel = subModel;
     this.ThinkTime      = thinkTime;
     this.NumLaunchers   = numLaunchers;
 }
Beispiel #5
0
        public static LogicalWeapon CreateLogicalWeaponFromFile(
            App app,
            string weaponFile,
            int uniqueWeaponID = -1)
        {
            Kerberos.Sots.Data.WeaponFramework.Weapon w = new Kerberos.Sots.Data.WeaponFramework.Weapon();
            WeaponXmlUtility.LoadWeaponFromXml(weaponFile, ref w);
            LogicalWeapon logicalWeapon = new LogicalWeapon(app)
            {
                UniqueWeaponID           = uniqueWeaponID,
                FileName                 = Path.Combine("weapons", Path.GetFileName(weaponFile)),
                WeaponName               = Path.GetFileNameWithoutExtension(weaponFile),
                PayloadType              = !string.IsNullOrEmpty(w.PayloadType) ? (WeaponEnums.PayloadTypes)Enum.Parse(typeof(WeaponEnums.PayloadTypes), w.PayloadType) : WeaponEnums.PayloadTypes.Bolt,
                PlagueType               = !string.IsNullOrEmpty(w.PlagueType) ? (WeaponEnums.PlagueType)Enum.Parse(typeof(WeaponEnums.PlagueType), w.PlagueType) : WeaponEnums.PlagueType.NONE,
                Duration                 = w.Duration,
                TimeToLive               = w.TimeToLive,
                Model                    = w.Model,
                IsVisible                = w.isVisible,
                SubWeapon                = w.SubmunitionType,
                SecondaryWeapon          = w.SubweaponType,
                NumSubWeapons            = w.SubmunitionAmount,
                SubMunitionBlastType     = !string.IsNullOrEmpty(w.SubmunitionBlastType) ? (WeaponEnums.SubmunitionBlastType)Enum.Parse(typeof(WeaponEnums.SubmunitionBlastType), w.SubmunitionBlastType) : WeaponEnums.SubmunitionBlastType.Focus,
                SubmunitionConeDeviation = w.SubmunitionConeDeviation,
                CritHitRolls             = Math.Max(w.CritHitRolls, 1),
                NumArcs                  = w.NumArcs,
                Cost           = w.Cost,
                Range          = w.EffectiveRanges.MaxRange,
                IconSpriteName = w.Icon
            };

            logicalWeapon.IconTextureName    = Path.Combine("weapons\\Icons", logicalWeapon.IconSpriteName + ".bmp");
            logicalWeapon.RechargeTime       = w.BaseRechargeTime;
            logicalWeapon.BuildupTime        = w.BuildupDelay;
            logicalWeapon.ShotDelay          = w.VolleyDelay;
            logicalWeapon.VolleyPeriod       = w.VolleyPeriod;
            logicalWeapon.VolleyDeviation    = w.BaseVolleyDeviation;
            logicalWeapon.Health             = w.Health;
            logicalWeapon.TrackSpeedModifier = w.TrackSpeedModifier;
            logicalWeapon.NumVolleys         = Math.Max(w.Volleys, 1);
            logicalWeapon.DefaultWeaponSize  = (WeaponEnums.WeaponSizes)Enum.Parse(typeof(WeaponEnums.WeaponSizes), w.WeaponSize);
            logicalWeapon.Speed                           = w.MuzzleSpeed;
            logicalWeapon.Mass                            = w.RoundMass;
            logicalWeapon.Acceleration                    = w.ShotAcceleration;
            logicalWeapon.SolutionTolerance               = w.SolutionTolerance;
            logicalWeapon.DumbFireTime                    = w.DumbfireTime;
            logicalWeapon.CritHitBonus                    = w.CritHitBonus;
            logicalWeapon.Signature                       = w.Signature;
            logicalWeapon.RicochetModifier                = w.BaseRicochetModifier;
            logicalWeapon.MalfunctionDamage               = w.MalfunctionDamage;
            logicalWeapon.MalfunctionPercent              = w.MalfunctionPercent;
            logicalWeapon.Crew                            = w.Crew;
            logicalWeapon.isCrewPerBank                   = w.isCrewPerBank;
            logicalWeapon.Power                           = w.Power;
            logicalWeapon.isPowerPerBank                  = w.isPowerPerBank;
            logicalWeapon.Supply                          = w.Supply;
            logicalWeapon.isSupplyPerBank                 = w.isSupplyPerBank;
            logicalWeapon.TurretClasses                   = w.TurretClasses.SelectMany <TurretClass, LogicalTurretClass>((Func <TurretClass, IEnumerable <LogicalTurretClass> >)(x => x.GetLogicalTurretClasses(false))).ToArray <LogicalTurretClass>();
            logicalWeapon.Traits                          = w.Attributes.Select <Kerberos.Sots.Data.WeaponFramework.Attribute, WeaponEnums.WeaponTraits>((Func <Kerberos.Sots.Data.WeaponFramework.Attribute, WeaponEnums.WeaponTraits>)(x => (WeaponEnums.WeaponTraits)Enum.Parse(typeof(WeaponEnums.WeaponTraits), x.Name))).ToArray <WeaponEnums.WeaponTraits>();
            logicalWeapon.CompatibleSections              = w.CompatibleSections.Select <Section, string>((Func <Section, string>)(x => x.Name)).ToArray <string>();
            logicalWeapon.DeployableSections              = w.DeployableSections.Select <Section, string>((Func <Section, string>)(x => x.Name)).ToArray <string>();
            logicalWeapon.CompatibleFactions              = w.CompatibleFactions.Select <CompatibleFaction, string>((Func <CompatibleFaction, string>)(x => x.Name)).ToArray <string>();
            logicalWeapon.RangeTable                      = new WeaponRangeTable();
            logicalWeapon.RangeTable.PointBlank.Range     = w.EffectiveRanges.PbRange;
            logicalWeapon.RangeTable.PointBlank.Damage    = w.EffectiveRanges.PbDamage;
            logicalWeapon.RangeTable.PointBlank.Deviation = w.EffectiveRanges.PbDeviation;
            logicalWeapon.RangeTable.Effective.Range      = w.EffectiveRanges.EffectiveRange;
            logicalWeapon.RangeTable.Effective.Damage     = w.EffectiveRanges.EffectiveDamage;
            logicalWeapon.RangeTable.Effective.Deviation  = w.EffectiveRanges.EffectiveDeviation;
            logicalWeapon.RangeTable.Maximum.Range        = w.EffectiveRanges.MaxRange;
            logicalWeapon.RangeTable.Maximum.Damage       = w.EffectiveRanges.MaxDamage;
            logicalWeapon.RangeTable.Maximum.Deviation    = w.EffectiveRanges.MaxDeviation;
            logicalWeapon.RangeTable.PlanetRange          = w.EffectiveRanges.PlanetRange;
            logicalWeapon.PopDamage                       = w.PopDamage;
            logicalWeapon.InfraDamage                     = w.InfraDamage;
            logicalWeapon.TerraDamage                     = w.TerraDamage;
            logicalWeapon.MuzzleSize                      = w.MuzzleSize;
            logicalWeapon.Animation                       = w.Animation ?? string.Empty;
            logicalWeapon.AnimationDelay                  = w.AnimationDelay;
            logicalWeapon.ExplosiveMinEffectRange         = w.ExplosiveMinEffectRange;
            logicalWeapon.ExplosiveMaxEffectRange         = w.ExplosiveMaxEffectRange;
            logicalWeapon.DetonationRange                 = w.DetonationRange;
            logicalWeapon.MaxGravityForce                 = w.MaxGravityForce;
            logicalWeapon.GravityAffectRange              = w.GravityAffectRange;
            logicalWeapon.ArcRange                        = w.ArcRange;
            logicalWeapon.EMPRange                        = w.EMPRange;
            logicalWeapon.EMPDuration                     = w.EMPDuration;
            logicalWeapon.DOTDamage                       = w.DOT;
            logicalWeapon.BeamDamagePeriod                = (double)w.BeamDamagePeriod > 0.0 ? w.BeamDamagePeriod : 0.5f;
            List <DamagePattern> damagePatternList = new List <DamagePattern>();

            logicalWeapon.ArmorPiercingLevel = w.ArmorPiercingLevel;
            logicalWeapon.DisruptorValue     = w.DisruptorValue;
            logicalWeapon.DrainValue         = w.DrainValue;
            damagePatternList.Add(new DamagePattern(w.PbGrid.Width, w.PbGrid.Height, w.PbGrid.CollisionX, w.PbGrid.CollisionY, w.PbGrid.Data));
            damagePatternList.Add(new DamagePattern(w.EffectiveGrid.Width, w.EffectiveGrid.Height, w.EffectiveGrid.CollisionX, w.EffectiveGrid.CollisionY, w.EffectiveGrid.Data));
            damagePatternList.Add(new DamagePattern(w.MaxGrid.Width, w.MaxGrid.Height, w.MaxGrid.CollisionX, w.MaxGrid.CollisionY, w.MaxGrid.Data));
            logicalWeapon.DamagePattern = damagePatternList.ToArray();
            logicalWeapon.MuzzleEffect  = new LogicalEffect()
            {
                Name = w.MuzzleEffect
            };
            logicalWeapon.BuildupEffect = new LogicalEffect()
            {
                Name = w.BuildupEffect
            };
            logicalWeapon.ImpactEffect = new LogicalEffect()
            {
                Name = w.ImpactEffect
            };
            logicalWeapon.PlanetImpactEffect = new LogicalEffect()
            {
                Name = w.PlanetImpactEffect
            };
            logicalWeapon.BulletEffect = new LogicalEffect()
            {
                Name = w.BulletEffect
            };
            logicalWeapon.RicochetEffect = new LogicalEffect()
            {
                Name = w.RicochetEffect
            };
            logicalWeapon.DamageDecalMaterial     = w.DecalMaterial;
            logicalWeapon.DamageDecalSize         = w.DecalSize;
            logicalWeapon.isMuzzleEffectLooping   = w.isMuzzleEffectLooping;
            logicalWeapon.isBuildupEffectLooping  = w.isBuildupEffectLooping;
            logicalWeapon.isImpactEffectLooping   = w.isImpactEffectLooping;
            logicalWeapon.isBulletEffectLooping   = w.isBulletEffectLooping;
            logicalWeapon.isRicochetEffectLooping = w.isRicochetEffectLooping;
            logicalWeapon.MuzzleSound             = w.MuzzleSound;
            logicalWeapon.BuildupSound            = w.BuildupSound;
            logicalWeapon.ImpactSound             = w.ImpactSound;
            logicalWeapon.PlanetImpactSound       = w.PlanetImpactSound ?? string.Empty;
            logicalWeapon.ExpireSound             = w.ExpireSound;
            logicalWeapon.BulletSound             = w.BulletSound;
            logicalWeapon.RicochetSound           = w.RicochetSound;
            logicalWeapon.RequiredTechs           = w.RequiredTech.ToArray();
            logicalWeapon.PassThroughShields      = w.PassThroughShields.Select <PassableShield, LogicalShield.ShieldType>((Func <PassableShield, LogicalShield.ShieldType>)(x => (LogicalShield.ShieldType)Enum.Parse(typeof(LogicalShield.ShieldType), x.Name))).ToArray <LogicalShield.ShieldType>();
            return(logicalWeapon);
        }
Beispiel #6
0
        public void AddGameObjectReference()
        {
            ++this._weaponRefCount;
            if (this._weaponRefCount != 1)
            {
                return;
            }
            List <object> objectList     = new List <object>();
            LogicalWeapon logicalWeapon1 = this._game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.WeaponName == this.SubWeapon));

            logicalWeapon1?.AddGameObjectReference();
            LogicalWeapon logicalWeapon2 = this._game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.WeaponName == this.SecondaryWeapon));

            logicalWeapon2?.AddGameObjectReference();
            objectList.Add((object)this.UniqueWeaponID);
            objectList.Add((object)(logicalWeapon1 != null ? logicalWeapon1.GameObject.ObjectID : 0));
            objectList.Add((object)(logicalWeapon2 != null ? logicalWeapon2.GameObject.ObjectID : 0));
            objectList.Add(string.IsNullOrEmpty(this.MuzzleEffect.Name) ? (object)"effects\\placeholder.effect" : (object)this.MuzzleEffect.Name);
            objectList.Add((object)this.isMuzzleEffectLooping);
            objectList.Add(string.IsNullOrEmpty(this.BuildupEffect.Name) ? (object)string.Empty : (object)this.BuildupEffect.Name);
            objectList.Add((object)this.isBuildupEffectLooping);
            objectList.Add(string.IsNullOrEmpty(this.BulletEffect.Name) ? (object)"effects\\placeholder.effect" : (object)this.BulletEffect.Name);
            objectList.Add((object)this.isBulletEffectLooping);
            objectList.Add(string.IsNullOrEmpty(this.ImpactEffect.Name) ? (object)"effects\\placeholder.effect" : (object)this.ImpactEffect.Name);
            objectList.Add((object)this.isImpactEffectLooping);
            objectList.Add(string.IsNullOrEmpty(this.PlanetImpactEffect.Name) ? (object)string.Empty : (object)this.ImpactEffect.Name);
            objectList.Add(string.IsNullOrEmpty(this.RicochetEffect.Name) ? (object)"effects\\Weapons\\Ricochet_Impact.effect" : (object)this.RicochetEffect.Name);
            objectList.Add((object)this.isRicochetEffectLooping);
            objectList.Add((object)this.MuzzleSound);
            objectList.Add((object)this.BuildupSound);
            objectList.Add((object)this.ImpactSound);
            objectList.Add((object)this.PlanetImpactSound);
            objectList.Add((object)this.ExpireSound);
            objectList.Add((object)this.BulletSound);
            objectList.Add((object)this.RicochetSound);
            objectList.Add((object)this.WeaponName);
            objectList.Add((object)this.IconSpriteName);
            objectList.Add((object)this.Name);
            objectList.Add((object)(int)this.PayloadType);
            objectList.Add((object)this.DefaultWeaponSize);
            objectList.Add((object)this.PlagueType);
            objectList.Add((object)this.NumVolleys);
            objectList.Add((object)this.NumSubWeapons);
            objectList.Add((object)(int)this.SubMunitionBlastType);
            objectList.Add((object)this.SubmunitionConeDeviation);
            objectList.Add((object)this.CritHitRolls);
            objectList.Add((object)this.NumArcs);
            objectList.AddRange(this.RangeTable.EnumerateScriptMessageParams());
            objectList.Add((object)this.PopDamage);
            objectList.Add((object)this.InfraDamage);
            objectList.Add((object)this.TerraDamage);
            objectList.Add((object)this.VolleyDeviation);
            objectList.Add((object)this.Speed);
            objectList.Add((object)this.Mass);
            objectList.Add((object)this.Acceleration);
            objectList.Add((object)this.Duration);
            objectList.Add((object)this.TimeToLive);
            objectList.Add((object)this.Health);
            objectList.Add((object)this.Range);
            objectList.Add((object)this.BuildupTime);
            objectList.Add((object)this.ShotDelay);
            objectList.Add((object)this.VolleyPeriod);
            objectList.Add((object)this.RechargeTime);
            objectList.Add((object)this.DumbFireTime);
            objectList.Add((object)this.CritHitBonus);
            objectList.Add((object)this.Signature);
            objectList.Add((object)this.RicochetModifier);
            objectList.Add((object)this.BeamDamagePeriod);
            objectList.Add((object)this.ExplosiveMinEffectRange);
            objectList.Add((object)this.ExplosiveMaxEffectRange);
            objectList.Add((object)this.DetonationRange);
            objectList.Add((object)this.MaxGravityForce);
            objectList.Add((object)this.GravityAffectRange);
            objectList.Add((object)this.ArcRange);
            objectList.Add((object)this.EMPRange);
            objectList.Add((object)this.EMPDuration);
            objectList.Add((object)this.DOTDamage);
            objectList.Add((object)this.Animation);
            objectList.Add((object)this.AnimationDelay);
            objectList.Add((object)(this.MuzzleSize.MuzzleType ?? WeaponEnums.MuzzleShape.Rectangle.ToString()));
            objectList.Add((object)this.MuzzleSize.Height);
            objectList.Add((object)this.MuzzleSize.Width);
            objectList.Add((object)this.Crew);
            objectList.Add((object)this.Power);
            objectList.Add((object)this.Supply);
            objectList.Add((object)this.isCrewPerBank);
            objectList.Add((object)this.isPowerPerBank);
            objectList.Add((object)this.isSupplyPerBank);
            objectList.Add((object)this.Traits.Length);
            foreach (WeaponEnums.WeaponTraits trait in this.Traits)
            {
                objectList.Add((object)(int)trait);
            }
            objectList.Add((object)this.ArmorPiercingLevel);
            objectList.Add((object)this.DisruptorValue);
            objectList.Add((object)this.DrainValue);
            foreach (Kerberos.Sots.ShipFramework.DamagePattern damagePattern in this.DamagePattern)
            {
                objectList.Add((object)damagePattern);
            }
            objectList.Add((object)this.DamageDecalMaterial);
            objectList.Add((object)this.DamageDecalSize);
            objectList.Add((object)this.PassThroughShields.Length);
            foreach (LogicalShield.ShieldType passThroughShield in this.PassThroughShields)
            {
                objectList.Add((object)passThroughShield);
            }
            this._weapon = this._game.AddObject <Weapon>(objectList.ToArray());
        }