diff --git a/OpenRA.Game/Effects/Bullet.cs b/OpenRA.Game/Effects/Bullet.cs index e5cee69600..c66d998f38 100755 --- a/OpenRA.Game/Effects/Bullet.cs +++ b/OpenRA.Game/Effects/Bullet.cs @@ -25,6 +25,26 @@ using OpenRA.Traits; namespace OpenRA.Effects { + class BulletInfo : IProjectileInfo + { + public readonly int Speed = 1; + public readonly bool AA = false; + public readonly bool AG = true; + public readonly bool ASW = false; + public readonly string Trail = null; + public readonly bool Inaccurate = false; + public readonly string Image = null; + public readonly bool High = false; + public readonly bool Arcing = false; + public readonly int RangeLimit = 0; + public readonly int Arm = 0; + public readonly bool UnderWater = false; + public readonly bool Shadow = false; + public readonly bool Proximity = false; + + public IEffect Create(ProjectileArgs args) { return null; } + } + public class Bullet : IEffect { readonly Player Owner; diff --git a/OpenRA.Game/Effects/Missile.cs b/OpenRA.Game/Effects/Missile.cs index 22e5fc25c2..5976666ee2 100755 --- a/OpenRA.Game/Effects/Missile.cs +++ b/OpenRA.Game/Effects/Missile.cs @@ -26,6 +26,26 @@ using OpenRA.Traits; namespace OpenRA.Effects { + class MissileInfo : IProjectileInfo + { + public readonly int Speed = 1; + public readonly int Arm = 0; + public readonly bool High = false; + public readonly bool Shadow = true; + public readonly bool Proximity = false; + public readonly string Trail = null; + public readonly bool Inaccurate = false; + public readonly bool AA = false; + public readonly bool AG = true; + public readonly bool ASW = false; + public readonly string Image = null; + public readonly int ROT = 5; + public readonly int RangeLimit = 0; + public readonly bool TurboBoost = false; + + public IEffect Create(ProjectileArgs args) { return null; } + } + class Missile : IEffect { readonly Actor FiredBy; diff --git a/OpenRA.Game/Effects/NukeLaunch.cs b/OpenRA.Game/Effects/NukeLaunch.cs index 3b74c18e24..3c65eae10d 100644 --- a/OpenRA.Game/Effects/NukeLaunch.cs +++ b/OpenRA.Game/Effects/NukeLaunch.cs @@ -28,6 +28,12 @@ using OpenRA.Graphics; namespace OpenRA.Effects { + class NukeInfo : IProjectileInfo + { + public readonly string Image = null; + public IEffect Create(ProjectileArgs args) { return null; } + } + class NukeLaunch : IEffect { readonly ProjectileInfo projectileUp, projectileDown; diff --git a/OpenRA.Game/Effects/TeslaZap.cs b/OpenRA.Game/Effects/TeslaZap.cs index 9df281dbe2..b7ed153b0a 100755 --- a/OpenRA.Game/Effects/TeslaZap.cs +++ b/OpenRA.Game/Effects/TeslaZap.cs @@ -21,9 +21,15 @@ using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Traits; +using OpenRA.GameRules; namespace OpenRA.Effects { + class TeslaZapInfo : IProjectileInfo + { + public IEffect Create(ProjectileArgs args) { return null; } + } + class TeslaZap : IEffect { readonly int2 from, to; diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs index 8a7ab90de0..f386648538 100644 --- a/OpenRA.Game/GameRules/ActorInfo.cs +++ b/OpenRA.Game/GameRules/ActorInfo.cs @@ -43,7 +43,7 @@ namespace OpenRA.GameRules foreach( var t in mergedNode ) if( t.Key != "Inherits" && t.Key != "Category" && !t.Key.StartsWith("-") ) - Traits.Add( LoadTraitInfo( t.Key, t.Value ) ); + Traits.Add( LoadTraitInfo( t.Key.Split('@')[0], t.Value ) ); } static MiniYaml GetParent( MiniYaml node, Dictionary allUnits ) @@ -71,9 +71,6 @@ namespace OpenRA.GameRules static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my) { - if (traitName.Contains('@')) - traitName = traitName.Substring(0, traitName.IndexOf('@')); - foreach (var mod in Game.ModAssemblies) { var fullTypeName = mod.Second + "." + traitName + "Info"; diff --git a/OpenRA.Game/GameRules/NewWeaponInfo.cs b/OpenRA.Game/GameRules/NewWeaponInfo.cs index 0314f1732f..b8e561b631 100644 --- a/OpenRA.Game/GameRules/NewWeaponInfo.cs +++ b/OpenRA.Game/GameRules/NewWeaponInfo.cs @@ -21,12 +21,25 @@ using System.Collections.Generic; using OpenRA.FileFormats; using OpenRA.Effects; +using System; namespace OpenRA.GameRules { + public class ProjectileArgs + { + public NewWeaponInfo weapon; + public Actor firedBy; + public int2 offset; + public int srcAltitude; + public int facing; + public Actor target; + public int2 dest; + public int destAltitude; + } + public interface IProjectileInfo { - IEffect Create(); // todo: args for this + IEffect Create(ProjectileArgs args); } public class NewWeaponInfo @@ -34,6 +47,8 @@ namespace OpenRA.GameRules public readonly float Range = 0; public readonly string Report = null; public readonly int ROF = 1; + public readonly int Burst = 1; + public readonly bool Charges = false; public IProjectileInfo Projectile; public List Warheads = new List(); @@ -48,6 +63,8 @@ namespace OpenRA.GameRules case "Range": FieldLoader.LoadField(this, "Range", content.Nodes["Range"].Value); break; case "ROF": FieldLoader.LoadField(this, "ROF", content.Nodes["ROF"].Value); break; case "Report": FieldLoader.LoadField(this, "Report", content.Nodes["Report"].Value); break; + case "Burst": FieldLoader.LoadField(this, "Burst", content.Nodes["Burst"].Value); break; + case "Charges": FieldLoader.LoadField(this, "Charges", content.Nodes["Charges"].Value); break; case "Warhead": { @@ -59,9 +76,11 @@ namespace OpenRA.GameRules // in this case, it's an implementation of IProjectileInfo default: { - // todo: create the right implementation! - // fill it with the args - // etc etc + var fullTypeName = typeof(IEffect).Namespace + "." + key + "Info"; + Projectile = (IProjectileInfo)typeof(IEffect).Assembly.CreateInstance(fullTypeName); + if (Projectile == null) + throw new InvalidOperationException("Cannot locate projectile type: {0}".F(key)); + FieldLoader.Load(Projectile, kv.Value); } break; } } diff --git a/mods/ra/weapons.yaml b/mods/ra/weapons.yaml index 478f5a5027..0f6e68fa06 100644 --- a/mods/ra/weapons.yaml +++ b/mods/ra/weapons.yaml @@ -195,7 +195,7 @@ Grenade: Bullet: Speed: 5 High: true - Arching: true + Arcing: true Inaccurate: true Image: BOMB Warhead: @@ -328,7 +328,7 @@ MammothTusk: Bullet: Speed: 12 High: true - Arching: true + Arcing: true Inaccurate:true Image: 120MM Warhead: @@ -458,7 +458,7 @@ RedEye: Bullet: Speed: 12 High: true - Arching: true + Arcing: true Inaccurate:true Image: 120MM Warhead: @@ -539,7 +539,7 @@ DepthCharge: Bullet: Speed: 5 Image: BOMB - Arching: true + Arcing: true High: true Inaccurate: true ASW: true