Move Shape from Health to new HitShape trait

Renamed Shape to Type
This commit is contained in:
reaperrr
2017-05-21 12:44:47 +02:00
parent c7c6cf864c
commit 43b55ae333
9 changed files with 87 additions and 51 deletions

View File

@@ -10,7 +10,6 @@
#endregion
using System.Linq;
using OpenRA.Mods.Common.HitShapes;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
@@ -22,36 +21,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Trigger interfaces such as AnnounceOnKill?")]
public readonly bool NotifyAppliedDamage = true;
[FieldLoader.LoadUsing("LoadShape")]
public readonly IHitShape Shape;
static object LoadShape(MiniYaml yaml)
{
IHitShape ret;
var shapeNode = yaml.Nodes.Find(n => n.Key == "Shape");
var shape = shapeNode != null ? shapeNode.Value.Value : string.Empty;
if (!string.IsNullOrEmpty(shape))
{
ret = Game.CreateObject<IHitShape>(shape + "Shape");
try
{
FieldLoader.Load(ret, shapeNode.Value);
}
catch (YamlException e)
{
throw new YamlException("HitShape {0}: {1}".F(shape, e.Message));
}
}
else
ret = new CircleShape();
ret.Initialize();
return ret;
}
public virtual object Create(ActorInitializer init) { return new Health(init, this); }
}