load ALL the weaponinfo properly

This commit is contained in:
Chris Forbes
2010-03-31 22:52:36 +13:00
parent 744eeabb3c
commit b4f5baf1a7
7 changed files with 80 additions and 12 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<string, MiniYaml> 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";

View File

@@ -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<WarheadInfo> Warheads = new List<WarheadInfo>();
@@ -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;
}
}

View File

@@ -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