Add ActorInfo.TraitInfo[OrDefault]<T>() requiring ITraitIfo types
This commit is contained in:
@@ -26,15 +26,15 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public CaptureProperties(ScriptContext context, Actor self)
|
||||
: base(context, self)
|
||||
{
|
||||
normalInfo = Self.Info.Traits.GetOrDefault<CapturesInfo>();
|
||||
externalInfo = Self.Info.Traits.GetOrDefault<ExternalCapturesInfo>();
|
||||
normalInfo = Self.Info.TraitInfoOrDefault<CapturesInfo>();
|
||||
externalInfo = Self.Info.TraitInfoOrDefault<ExternalCapturesInfo>();
|
||||
}
|
||||
|
||||
[Desc("Captures the target actor.")]
|
||||
public void Capture(Actor target)
|
||||
{
|
||||
var normalCapturable = target.Info.Traits.GetOrDefault<CapturableInfo>();
|
||||
var externalCapturable = target.Info.Traits.GetOrDefault<ExternalCapturableInfo>();
|
||||
var normalCapturable = target.Info.TraitInfoOrDefault<CapturableInfo>();
|
||||
var externalCapturable = target.Info.TraitInfoOrDefault<ExternalCapturableInfo>();
|
||||
|
||||
if (normalInfo != null && normalCapturable != null && normalInfo.CaptureTypes.Contains(normalCapturable.Type))
|
||||
Self.QueueActivity(new CaptureActor(Self, target));
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public DemolitionProperties(ScriptContext context, Actor self)
|
||||
: base(context, self)
|
||||
{
|
||||
info = Self.Info.Traits.Get<C4DemolitionInfo>();
|
||||
info = Self.Info.TraitInfo<C4DemolitionInfo>();
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
BuildableInfo GetBuildableInfo(string actorType)
|
||||
{
|
||||
var ri = Self.World.Map.Rules.Actors[actorType];
|
||||
var bi = ri.Traits.GetOrDefault<BuildableInfo>();
|
||||
var bi = ri.TraitInfoOrDefault<BuildableInfo>();
|
||||
|
||||
if (bi == null)
|
||||
throw new LuaException("Actor of type {0} cannot be produced".F(actorType));
|
||||
@@ -267,7 +267,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
BuildableInfo GetBuildableInfo(string actorType)
|
||||
{
|
||||
var ri = Player.World.Map.Rules.Actors[actorType];
|
||||
var bi = ri.Traits.GetOrDefault<BuildableInfo>();
|
||||
var bi = ri.TraitInfoOrDefault<BuildableInfo>();
|
||||
|
||||
if (bi == null)
|
||||
throw new LuaException("Actor of type {0} cannot be produced".F(actorType));
|
||||
|
||||
Reference in New Issue
Block a user