Actor.traits is implementation detail
This commit is contained in:
@@ -22,13 +22,13 @@ namespace OpenRA
|
|||||||
public class Actor
|
public class Actor
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
public readonly TypeDictionary traits = new TypeDictionary();
|
readonly TypeDictionary traits = new TypeDictionary();
|
||||||
public readonly ActorInfo Info;
|
public readonly ActorInfo Info;
|
||||||
|
|
||||||
public readonly World World;
|
public readonly World World;
|
||||||
public readonly uint ActorID;
|
public readonly uint ActorID;
|
||||||
|
|
||||||
public int2 Location { get { return traits.Get<IOccupySpace>().TopLeft; } }
|
public int2 Location { get { return Trait<IOccupySpace>().TopLeft; } }
|
||||||
[Sync]
|
[Sync]
|
||||||
public Player Owner;
|
public Player Owner;
|
||||||
|
|
||||||
@@ -51,10 +51,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
Info = Rules.Info[name.ToLowerInvariant()];
|
Info = Rules.Info[name.ToLowerInvariant()];
|
||||||
foreach (var trait in Info.TraitsInConstructOrder())
|
foreach (var trait in Info.TraitsInConstructOrder())
|
||||||
traits.Add(trait.Create(init));
|
AddTrait(trait.Create(init));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( CenterLocation == float2.Zero && traits.Contains<IOccupySpace>() )
|
if( CenterLocation == float2.Zero && HasTrait<IOccupySpace>() )
|
||||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||||
|
|
||||||
Size = Lazy.New(() =>
|
Size = Lazy.New(() =>
|
||||||
@@ -64,7 +64,7 @@ namespace OpenRA
|
|||||||
return new float2(si.Bounds[0], si.Bounds[1]);
|
return new float2(si.Bounds[0], si.Bounds[1]);
|
||||||
|
|
||||||
// auto size from render
|
// auto size from render
|
||||||
var firstSprite = traits.WithInterface<IRender>().SelectMany(x => x.Render(this)).FirstOrDefault();
|
var firstSprite = TraitsImplementing<IRender>().SelectMany(x => x.Render(this)).FirstOrDefault();
|
||||||
if (firstSprite.Sprite == null) return float2.Zero;
|
if (firstSprite.Sprite == null) return float2.Zero;
|
||||||
return firstSprite.Sprite.size;
|
return firstSprite.Sprite.size;
|
||||||
});
|
});
|
||||||
@@ -83,7 +83,7 @@ namespace OpenRA
|
|||||||
if (currentActivity is Idle)
|
if (currentActivity is Idle)
|
||||||
{
|
{
|
||||||
if (!wasIdle)
|
if (!wasIdle)
|
||||||
foreach (var ni in traits.WithInterface<INotifyIdle>())
|
foreach (var ni in TraitsImplementing<INotifyIdle>())
|
||||||
ni.Idle(this);
|
ni.Idle(this);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -102,8 +102,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public IEnumerable<Renderable> Render()
|
public IEnumerable<Renderable> Render()
|
||||||
{
|
{
|
||||||
var mods = traits.WithInterface<IRenderModifier>();
|
var mods = TraitsImplementing<IRenderModifier>();
|
||||||
var sprites = traits.WithInterface<IRender>().SelectMany(x => x.Render(this));
|
var sprites = TraitsImplementing<IRender>().SelectMany(x => x.Render(this));
|
||||||
return mods.Aggregate(sprites, (m, p) => p.ModifyRender(this, m));
|
return mods.Aggregate(sprites, (m, p) => p.ModifyRender(this, m));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ namespace OpenRA
|
|||||||
.OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
|
.OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
return traits.WithInterface<IIssueOrder>()
|
return TraitsImplementing<IIssueOrder>()
|
||||||
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
|
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
|
||||||
.FirstOrDefault( x => x != null );
|
.FirstOrDefault( x => x != null );
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
if (useAltitude)
|
if (useAltitude)
|
||||||
{
|
{
|
||||||
var move = traits.GetOrDefault<IMove>();
|
var move = TraitOrDefault<IMove>();
|
||||||
if (move != null) loc -= new float2(0, move.Altitude);
|
if (move != null) loc -= new float2(0, move.Altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,5 +188,30 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
return "{0} {1}{2}".F( Info.Name, ActorID, IsInWorld ? "" : " (not in world)" );
|
return "{0} {1}{2}".F( Info.Name, ActorID, IsInWorld ? "" : " (not in world)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T Trait<T>()
|
||||||
|
{
|
||||||
|
return traits.Get<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T TraitOrDefault<T>()
|
||||||
|
{
|
||||||
|
return traits.GetOrDefault<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T> TraitsImplementing<T>()
|
||||||
|
{
|
||||||
|
return traits.WithInterface<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasTrait<T>()
|
||||||
|
{
|
||||||
|
return traits.Contains<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTrait( object t )
|
||||||
|
{
|
||||||
|
traits.Add( t );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ namespace OpenRA
|
|||||||
LoadMap(map);
|
LoadMap(map);
|
||||||
world.Queries = new World.AllQueries(world);
|
world.Queries = new World.AllQueries(world);
|
||||||
|
|
||||||
foreach (var gs in world.WorldActor.traits.WithInterface<IGameStarted>())
|
foreach (var gs in world.WorldActor.TraitsImplementing<IGameStarted>())
|
||||||
gs.GameStarted(world);
|
gs.GameStarted(world);
|
||||||
orderManager.StartGame();
|
orderManager.StartGame();
|
||||||
}
|
}
|
||||||
@@ -398,7 +398,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
world.Queries = new World.AllQueries(world);
|
world.Queries = new World.AllQueries(world);
|
||||||
|
|
||||||
foreach (var gs in world.WorldActor.traits.WithInterface<IGameStarted>())
|
foreach (var gs in world.WorldActor.TraitsImplementing<IGameStarted>())
|
||||||
gs.GameStarted(world);
|
gs.GameStarted(world);
|
||||||
|
|
||||||
viewport.GoToStartLocation(world.LocalPlayer);
|
viewport.GoToStartLocation(world.LocalPlayer);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace OpenRA.Graphics
|
|||||||
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
|
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
|
||||||
PrimitiveType.TriangleList, Game.Renderer.SpriteShader));
|
PrimitiveType.TriangleList, Game.Renderer.SpriteShader));
|
||||||
|
|
||||||
foreach (var r in world.WorldActor.traits.WithInterface<IRenderOverlay>())
|
foreach (var r in world.WorldActor.TraitsImplementing<IRenderOverlay>())
|
||||||
r.Render();
|
r.Render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace OpenRA.Graphics
|
|||||||
public void RefreshPalette()
|
public void RefreshPalette()
|
||||||
{
|
{
|
||||||
Game.world.WorldRenderer.palette.Update(
|
Game.world.WorldRenderer.palette.Update(
|
||||||
Game.world.WorldActor.traits.WithInterface<IPaletteModifier>());
|
Game.world.WorldActor.TraitsImplementing<IPaletteModifier>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA.Network
|
|||||||
order.Player.Stances[targetPlayer] = (Stance)order.TargetLocation.Y;
|
order.Player.Stances[targetPlayer] = (Stance)order.TargetLocation.Y;
|
||||||
|
|
||||||
if (targetPlayer == world.LocalPlayer)
|
if (targetPlayer == world.LocalPlayer)
|
||||||
world.WorldActor.traits.Get<Shroud>().UpdatePlayerStance(world, order.Player, oldStance, order.Player.Stances[targetPlayer]);
|
world.WorldActor.Trait<Shroud>().UpdatePlayerStance(world, order.Player, oldStance, order.Player.Stances[targetPlayer]);
|
||||||
|
|
||||||
Game.Debug("{0} has set diplomatic stance vs {1} to {2}".F(
|
Game.Debug("{0} has set diplomatic stance vs {1} to {2}".F(
|
||||||
order.Player.PlayerName, targetPlayer.PlayerName, order.Player.Stances[targetPlayer]));
|
order.Player.PlayerName, targetPlayer.PlayerName, order.Player.Stances[targetPlayer]));
|
||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Network
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if( !order.IsImmediate )
|
if( !order.IsImmediate )
|
||||||
foreach (var t in order.Subject.traits.WithInterface<IResolveOrder>())
|
foreach (var t in order.Subject.TraitsImplementing<IResolveOrder>())
|
||||||
t.ResolveOrder(order.Subject, order);
|
t.ResolveOrder(order.Subject, order);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Orders
|
|||||||
|
|
||||||
public void Tick( World world )
|
public void Tick( World world )
|
||||||
{
|
{
|
||||||
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.Info[ Building ].Category );
|
var producing = Producer.Trait<Traits.ProductionQueue>().CurrentItem( Rules.Info[ Building ].Category );
|
||||||
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,21 +38,21 @@ namespace OpenRA.Orders
|
|||||||
public void RenderBeforeWorld(World world)
|
public void RenderBeforeWorld(World world)
|
||||||
{
|
{
|
||||||
foreach (var a in world.Selection.Actors)
|
foreach (var a in world.Selection.Actors)
|
||||||
foreach (var t in a.traits.WithInterface<IPreRenderSelection>())
|
foreach (var t in a.TraitsImplementing<IPreRenderSelection>())
|
||||||
t.RenderBeforeWorld(a);
|
t.RenderBeforeWorld(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld( World world )
|
public void RenderAfterWorld( World world )
|
||||||
{
|
{
|
||||||
foreach (var a in world.Selection.Actors)
|
foreach (var a in world.Selection.Actors)
|
||||||
foreach (var t in a.traits.WithInterface<IPostRenderSelection>())
|
foreach (var t in a.TraitsImplementing<IPostRenderSelection>())
|
||||||
t.RenderAfterWorld(a);
|
t.RenderAfterWorld(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCursor( World world, int2 xy, MouseInput mi )
|
public string GetCursor( World world, int2 xy, MouseInput mi )
|
||||||
{
|
{
|
||||||
var c = Order(world, xy, mi)
|
var c = Order(world, xy, mi)
|
||||||
.Select(o => o.Subject.traits.WithInterface<IOrderCursor>()
|
.Select(o => o.Subject.TraitsImplementing<IOrderCursor>()
|
||||||
.Select(pc => pc.CursorForOrder(o.Subject, o)).FirstOrDefault(a => a != null))
|
.Select(pc => pc.CursorForOrder(o.Subject, o)).FirstOrDefault(a => a != null))
|
||||||
.FirstOrDefault(a => a != null);
|
.FirstOrDefault(a => a != null);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
using( new PerfSample( "find_unit_path_multiple_src" ) )
|
using( new PerfSample( "find_unit_path_multiple_src" ) )
|
||||||
{
|
{
|
||||||
var mobile = self.traits.Get<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
var tilesInRange = world.FindTilesInCircle(target, range)
|
var tilesInRange = world.FindTilesInCircle(target, range)
|
||||||
.Where( t => mobile.CanEnterCell(t));
|
.Where( t => mobile.CanEnterCell(t));
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA
|
|||||||
return q =>
|
return q =>
|
||||||
p != q &&
|
p != q &&
|
||||||
((p - q).LengthSquared < dist * dist) &&
|
((p - q).LengthSquared < dist * dist) &&
|
||||||
(world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(q).Any(a => a.Group != self.Group));
|
(world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(q).Any(a => a.Group != self.Group));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int2> FindPath( PathSearch search )
|
public List<int2> FindPath( PathSearch search )
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
world = self.World;
|
world = self.World;
|
||||||
cellInfo = InitCellInfo();
|
cellInfo = InitCellInfo();
|
||||||
mobile = self.traits.Get<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
queue = new PriorityQueue<PathDistance>();
|
queue = new PriorityQueue<PathDistance>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA
|
|||||||
public void Add(World w, Actor a)
|
public void Add(World w, Actor a)
|
||||||
{
|
{
|
||||||
actors.Add(a);
|
actors.Add(a);
|
||||||
foreach (var ns in w.WorldActor.traits.WithInterface<INotifySelection>())
|
foreach (var ns in w.WorldActor.TraitsImplementing<INotifySelection>())
|
||||||
ns.SelectionChanged();
|
ns.SelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
|||||||
var voicedUnit = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
|
var voicedUnit = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
|
||||||
Sound.PlayVoice("Select", voicedUnit);
|
Sound.PlayVoice("Select", voicedUnit);
|
||||||
|
|
||||||
foreach (var ns in world.WorldActor.traits.WithInterface<INotifySelection>())
|
foreach (var ns in world.WorldActor.TraitsImplementing<INotifySelection>())
|
||||||
ns.SelectionChanged();
|
ns.SelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public ShroudRenderer(Player owner, Map map)
|
public ShroudRenderer(Player owner, Map map)
|
||||||
{
|
{
|
||||||
this.shroud = owner.World.WorldActor.traits.Get<Traits.Shroud>();
|
this.shroud = owner.World.WorldActor.Trait<Traits.Shroud>();
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|
||||||
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
|
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace OpenRA.Traits.Activities
|
|||||||
|
|
||||||
public IActivity Tick( Actor self )
|
public IActivity Tick( Actor self )
|
||||||
{
|
{
|
||||||
var mobile = self.traits.Get<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
if( move != null )
|
if( move != null )
|
||||||
{
|
{
|
||||||
@@ -165,10 +165,10 @@ namespace OpenRA.Traits.Activities
|
|||||||
|
|
||||||
void NudgeBlocker(Actor self, int2 nextCell)
|
void NudgeBlocker(Actor self, int2 nextCell)
|
||||||
{
|
{
|
||||||
var blocker = self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(nextCell).FirstOrDefault();
|
var blocker = self.World.WorldActor.Trait<UnitInfluence>().GetUnitsAt(nextCell).FirstOrDefault();
|
||||||
if (blocker == null) return;
|
if (blocker == null) return;
|
||||||
|
|
||||||
var nudge = blocker.traits.GetOrDefault<INudge>();
|
var nudge = blocker.TraitOrDefault<INudge>();
|
||||||
if (nudge != null)
|
if (nudge != null)
|
||||||
nudge.OnNudge(blocker, self);
|
nudge.OnNudge(blocker, self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ namespace OpenRA.Traits.Activities
|
|||||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||||
var cost = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
|
var cost = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||||
|
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
var refundFraction = self.Info.Traits.Get<BuildingInfo>().RefundPercent * (health == null ? 1f : health.HPFraction);
|
var refundFraction = self.Info.Traits.Get<BuildingInfo>().RefundPercent * (health == null ? 1f : health.HPFraction);
|
||||||
|
|
||||||
self.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash((int)(refundFraction * cost));
|
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash((int)(refundFraction * cost));
|
||||||
|
|
||||||
foreach (var ns in self.traits.WithInterface<INotifySold>())
|
foreach (var ns in self.TraitsImplementing<INotifySold>())
|
||||||
ns.Sold(self);
|
ns.Sold(self);
|
||||||
self.World.AddFrameEndTask( _ => self.World.Remove( self ) );
|
self.World.AddFrameEndTask( _ => self.World.Remove( self ) );
|
||||||
}
|
}
|
||||||
@@ -37,10 +37,10 @@ namespace OpenRA.Traits.Activities
|
|||||||
{
|
{
|
||||||
if( !started )
|
if( !started )
|
||||||
{
|
{
|
||||||
framesRemaining = self.traits.Get<RenderSimple>().anim.HasSequence("make")
|
framesRemaining = self.Trait<RenderSimple>().anim.HasSequence("make")
|
||||||
? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
? self.Trait<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||||
|
|
||||||
foreach( var ns in self.traits.WithInterface<INotifySold>() )
|
foreach( var ns in self.TraitsImplementing<INotifySold>() )
|
||||||
ns.Selling( self );
|
ns.Selling( self );
|
||||||
|
|
||||||
started = true;
|
started = true;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Traits.Activities
|
|||||||
|
|
||||||
public IActivity Tick( Actor self )
|
public IActivity Tick( Actor self )
|
||||||
{
|
{
|
||||||
var facing = self.traits.Get<IFacing>();
|
var facing = self.Trait<IFacing>();
|
||||||
|
|
||||||
if( desiredFacing == facing.Facing )
|
if( desiredFacing == facing.Facing )
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Traits.Activities
|
|||||||
|
|
||||||
public void Cancel( Actor self )
|
public void Cancel( Actor self )
|
||||||
{
|
{
|
||||||
desiredFacing = self.traits.Get<IFacing>().Facing;
|
desiredFacing = self.Trait<IFacing>().Facing;
|
||||||
NextActivity = null;
|
NextActivity = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public bool Disabled
|
public bool Disabled
|
||||||
{
|
{
|
||||||
get { return self.traits.WithInterface<IDisable>().Any(t => t.Disabled); }
|
get { return self.TraitsImplementing<IDisable>().Any(t => t.Disabled); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Building(ActorInitializer init)
|
public Building(ActorInitializer init)
|
||||||
@@ -61,14 +61,14 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public int GetPowerUsage()
|
public int GetPowerUsage()
|
||||||
{
|
{
|
||||||
var modifier = self.traits
|
var modifier = self
|
||||||
.WithInterface<IPowerModifier>()
|
.TraitsImplementing<IPowerModifier>()
|
||||||
.Select(t => t.GetPowerModifier())
|
.Select(t => t.GetPowerModifier())
|
||||||
.Product();
|
.Product();
|
||||||
|
|
||||||
if (Info.Power > 0)
|
if (Info.Power > 0)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
var healthFraction = (health == null) ? 1f : health.HPFraction;
|
var healthFraction = (health == null) ? 1f : health.HPFraction;
|
||||||
return (int)(modifier * healthFraction * Info.Power);
|
return (int)(modifier * healthFraction * Info.Power);
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
if (e.DamageState == DamageState.Dead)
|
if (e.DamageState == DamageState.Dead)
|
||||||
{
|
{
|
||||||
self.World.WorldActor.traits.Get<ScreenShaker>().AddEffect(10, self.CenterLocation, 1);
|
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(10, self.CenterLocation, 1);
|
||||||
Sound.Play(Info.DestroyedSound, self.CenterLocation);
|
Sound.Play(Info.DestroyedSound, self.CenterLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Traits
|
|||||||
var oldState = this.DamageState;
|
var oldState = this.DamageState;
|
||||||
|
|
||||||
/* apply the damage modifiers, if we have any. */
|
/* apply the damage modifiers, if we have any. */
|
||||||
var modifier = (float)self.traits.WithInterface<IDamageModifier>()
|
var modifier = (float)self.TraitsImplementing<IDamageModifier>()
|
||||||
.Select(t => t.GetDamageModifier(warhead)).Product();
|
.Select(t => t.GetDamageModifier(warhead)).Product();
|
||||||
|
|
||||||
damage = (int)(damage * modifier);
|
damage = (int)(damage * modifier);
|
||||||
@@ -103,7 +103,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
if (hp > MaxHP) hp = MaxHP;
|
if (hp > MaxHP) hp = MaxHP;
|
||||||
|
|
||||||
foreach (var nd in self.traits.WithInterface<INotifyDamage>())
|
foreach (var nd in self.TraitsImplementing<INotifyDamage>())
|
||||||
nd.Damaged(self, new AttackInfo
|
nd.Damaged(self, new AttackInfo
|
||||||
{
|
{
|
||||||
Attacker = attacker,
|
Attacker = attacker,
|
||||||
@@ -140,26 +140,26 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public static bool IsDead(this Actor self)
|
public static bool IsDead(this Actor self)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
return (health == null) ? true : health.IsDead;
|
return (health == null) ? true : health.IsDead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DamageState GetDamageState(this Actor self)
|
public static DamageState GetDamageState(this Actor self)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
return (health == null) ? DamageState.Undamaged : health.DamageState;
|
return (health == null) ? DamageState.Undamaged : health.DamageState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InflictDamage(this Actor self, Actor attacker, int damage, WarheadInfo warhead)
|
public static void InflictDamage(this Actor self, Actor attacker, int damage, WarheadInfo warhead)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
if (health == null) return;
|
if (health == null) return;
|
||||||
health.InflictDamage(self, attacker, damage, warhead);
|
health.InflictDamage(self, attacker, damage, warhead);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Kill(this Actor self, Actor attacker)
|
public static void Kill(this Actor self, Actor attacker)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
if (health == null) return;
|
if (health == null) return;
|
||||||
health.InflictDamage(self, attacker, health.HP, null);
|
health.InflictDamage(self, attacker, health.HP, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ namespace OpenRA.Traits
|
|||||||
this.self = init.self;
|
this.self = init.self;
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
|
|
||||||
shroud = self.World.WorldActor.traits.Get<Shroud>();
|
shroud = self.World.WorldActor.Trait<Shroud>();
|
||||||
uim = self.World.WorldActor.traits.Get<UnitInfluence>();
|
uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||||
bim = self.World.WorldActor.traits.Get<BuildingInfluence>();
|
bim = self.World.WorldActor.Trait<BuildingInfluence>();
|
||||||
canShareCell = self.traits.Contains<SharesCell>();
|
canShareCell = self.HasTrait<SharesCell>();
|
||||||
|
|
||||||
if (init.Contains<LocationInit>())
|
if (init.Contains<LocationInit>())
|
||||||
{
|
{
|
||||||
@@ -149,7 +149,7 @@ namespace OpenRA.Traits
|
|||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Add(new MoveFlash(self.World, order.TargetLocation));
|
w.Add(new MoveFlash(self.World, order.TargetLocation));
|
||||||
var line = self.traits.GetOrDefault<DrawLineToTarget>();
|
var line = self.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTarget(self, Target.FromOrder(order), Color.Green);
|
line.SetTarget(self, Target.FromOrder(order), Color.Green);
|
||||||
});
|
});
|
||||||
@@ -203,7 +203,7 @@ namespace OpenRA.Traits
|
|||||||
if (Info.Crushes == null)
|
if (Info.Crushes == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var crushable = building.traits.WithInterface<ICrushable>();
|
var crushable = building.TraitsImplementing<ICrushable>();
|
||||||
if (crushable.Count() == 0)
|
if (crushable.Count() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -215,11 +215,11 @@ namespace OpenRA.Traits
|
|||||||
if (checkTransientActors && uim.AnyUnitsAt(cell))
|
if (checkTransientActors && uim.AnyUnitsAt(cell))
|
||||||
{
|
{
|
||||||
var actors = uim.GetUnitsAt(cell).Where(a => a != self && a != ignoreActor).ToArray();
|
var actors = uim.GetUnitsAt(cell).Where(a => a != self && a != ignoreActor).ToArray();
|
||||||
var nonshareable = canShareCell ? actors : actors.Where(a => !a.traits.Contains<SharesCell>()).ToArray();
|
var nonshareable = canShareCell ? actors : actors.Where(a => !a.HasTrait<SharesCell>()).ToArray();
|
||||||
|
|
||||||
if (canShareCell)
|
if (canShareCell)
|
||||||
{
|
{
|
||||||
var shareable = actors.Where(a => a.traits.Contains<SharesCell>());
|
var shareable = actors.Where(a => a.HasTrait<SharesCell>());
|
||||||
|
|
||||||
// only allow 5 in a cell
|
// only allow 5 in a cell
|
||||||
if (shareable.Count() >= 5)
|
if (shareable.Count() >= 5)
|
||||||
@@ -230,8 +230,8 @@ namespace OpenRA.Traits
|
|||||||
if (Info.Crushes == null && nonshareable.Length > 0)
|
if (Info.Crushes == null && nonshareable.Length > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (nonshareable.Length > 0 && nonshareable.Any(a => !(a.traits.Contains<ICrushable>() &&
|
if (nonshareable.Length > 0 && nonshareable.Any(a => !(a.HasTrait<ICrushable>() &&
|
||||||
a.traits.WithInterface<ICrushable>().Any(b => b.CrushClasses.Intersect(Info.Crushes).Any()))))
|
a.TraitsImplementing<ICrushable>().Any(b => b.CrushClasses.Intersect(Info.Crushes).Any()))))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,10 +241,10 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public virtual void FinishedMoving(Actor self)
|
public virtual void FinishedMoving(Actor self)
|
||||||
{
|
{
|
||||||
var crushable = uim.GetUnitsAt(toCell).Where(a => a != self && a.traits.Contains<ICrushable>());
|
var crushable = uim.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait<ICrushable>());
|
||||||
foreach (var a in crushable)
|
foreach (var a in crushable)
|
||||||
{
|
{
|
||||||
var crushActions = a.traits.WithInterface<ICrushable>().Where(b => b.CrushClasses.Intersect(Info.Crushes).Any());
|
var crushActions = a.TraitsImplementing<ICrushable>().Where(b => b.CrushClasses.Intersect(Info.Crushes).Any());
|
||||||
foreach (var b in crushActions)
|
foreach (var b in crushActions)
|
||||||
b.OnCrush(self);
|
b.OnCrush(self);
|
||||||
}
|
}
|
||||||
@@ -263,8 +263,8 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
var type = self.World.GetTerrainType(cell);
|
var type = self.World.GetTerrainType(cell);
|
||||||
|
|
||||||
var modifier = self.traits
|
var modifier = self
|
||||||
.WithInterface<ISpeedModifier>()
|
.TraitsImplementing<ISpeedModifier>()
|
||||||
.Select(t => t.GetSpeedModifier())
|
.Select(t => t.GetSpeedModifier())
|
||||||
.Product();
|
.Product();
|
||||||
return Info.Speed * TerrainSpeed[type] * modifier;
|
return Info.Speed * TerrainSpeed[type] * modifier;
|
||||||
@@ -323,7 +323,7 @@ namespace OpenRA.Traits
|
|||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var line = self.traits.GetOrDefault<DrawLineToTarget>();
|
var line = self.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTargetSilently(self, Target.FromCell(moveTo.Value), Color.Green);
|
line.SetTargetSilently(self, Target.FromCell(moveTo.Value), Color.Green);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
case "DevGiveCash":
|
case "DevGiveCash":
|
||||||
{
|
{
|
||||||
self.traits.Get<PlayerResources>().GiveCash(Info.Cash);
|
self.Trait<PlayerResources>().GiveCash(Info.Cash);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "DevShroud":
|
case "DevShroud":
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
var prevItems = GetNumBuildables(self.Owner);
|
var prevItems = GetNumBuildables(self.Owner);
|
||||||
|
|
||||||
var queue = self.traits.Get<ProductionQueue>();
|
var queue = self.Trait<ProductionQueue>();
|
||||||
var unit = Rules.Info[order.TargetString];
|
var unit = Rules.Info[order.TargetString];
|
||||||
var producing = queue.CurrentItem(unit.Category);
|
var producing = queue.CurrentItem(unit.Category);
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Traits
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if( producer.Actor != null )
|
if( producer.Actor != null )
|
||||||
producer.Actor.traits.WithInterface<RenderSimple>().First().PlayCustomAnim( producer.Actor, "build" );
|
producer.Actor.TraitsImplementing<RenderSimple>().First().PlayCustomAnim( producer.Actor, "build" );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetNumBuildables(Player p)
|
static int GetNumBuildables(Player p)
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Traits
|
|||||||
void TickOre(Actor self)
|
void TickOre(Actor self)
|
||||||
{
|
{
|
||||||
OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait<IStoreOre>()
|
OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait<IStoreOre>()
|
||||||
.Sum(a => a.Actor.traits.WithInterface<IStoreOre>().Sum(b => b.Capacity));
|
.Sum(a => a.Actor.TraitsImplementing<IStoreOre>().Sum(b => b.Capacity));
|
||||||
|
|
||||||
if (Ore > OreCapacity)
|
if (Ore > OreCapacity)
|
||||||
Ore = OreCapacity;
|
Ore = OreCapacity;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
while( p.Value.Count > 0 && !Rules.TechTree.BuildableItems( self.Owner, p.Key ).Contains( p.Value[ 0 ].Item ) )
|
while( p.Value.Count > 0 && !Rules.TechTree.BuildableItems( self.Owner, p.Key ).Contains( p.Value[ 0 ].Item ) )
|
||||||
{
|
{
|
||||||
self.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash(p.Value[0].TotalCost - p.Value[0].RemainingCost); // refund what's been paid so far.
|
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(p.Value[0].TotalCost - p.Value[0].RemainingCost); // refund what's been paid so far.
|
||||||
FinishProduction(p.Key);
|
FinishProduction(p.Key);
|
||||||
}
|
}
|
||||||
if( p.Value.Count > 0 )
|
if( p.Value.Count > 0 )
|
||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Traits
|
|||||||
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (Game.LobbyInfo.GlobalSettings.AllowCheats && self.traits.Get<DeveloperMode>().FastBuild) return 0;
|
if (Game.LobbyInfo.GlobalSettings.AllowCheats && self.Trait<DeveloperMode>().FastBuild) return 0;
|
||||||
var ui = unit.Traits.Get<BuildableInfo>();
|
var ui = unit.Traits.Get<BuildableInfo>();
|
||||||
var time = ui.Cost
|
var time = ui.Cost
|
||||||
* self.Owner.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().BuildSpeed /* todo: country-specific build speed bonus */
|
* self.Owner.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().BuildSpeed /* todo: country-specific build speed bonus */
|
||||||
@@ -139,7 +139,7 @@ namespace OpenRA.Traits
|
|||||||
else if( lastIndex == 0 )
|
else if( lastIndex == 0 )
|
||||||
{
|
{
|
||||||
var item = queue[0];
|
var item = queue[0];
|
||||||
self.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.
|
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.
|
||||||
FinishProduction(category);
|
FinishProduction(category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
static bool IsDisabledBuilding(Actor a)
|
static bool IsDisabledBuilding(Actor a)
|
||||||
{
|
{
|
||||||
var building = a.traits.GetOrDefault<Building>();
|
var building = a.TraitOrDefault<Building>();
|
||||||
return building != null && building.Disabled;
|
return building != null && building.Disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
if (Paused) return;
|
if (Paused) return;
|
||||||
|
|
||||||
if (player.PlayerActor.traits.Get<PlayerResources>().GetPowerState() != PowerState.Normal)
|
if (player.PlayerActor.Trait<PlayerResources>().GetPowerState() != PowerState.Normal)
|
||||||
{
|
{
|
||||||
if (--slowdown <= 0)
|
if (--slowdown <= 0)
|
||||||
slowdown = player.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().LowPowerSlowdown;
|
slowdown = player.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().LowPowerSlowdown;
|
||||||
@@ -236,7 +236,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
var costThisFrame = RemainingCost / RemainingTime;
|
var costThisFrame = RemainingCost / RemainingTime;
|
||||||
if (costThisFrame != 0 && !player.PlayerActor.traits.Get<PlayerResources>().TakeCash(costThisFrame)) return;
|
if (costThisFrame != 0 && !player.PlayerActor.Trait<PlayerResources>().TakeCash(costThisFrame)) return;
|
||||||
RemainingCost -= costThisFrame;
|
RemainingCost -= costThisFrame;
|
||||||
RemainingTime -= 1;
|
RemainingTime -= 1;
|
||||||
if (RemainingTime > 0) return;
|
if (RemainingTime > 0) return;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
var effectivePrereq = prerequisites.Where( a => a.Traits.Get<BuildableInfo>().Owner.Contains( owner.Country.Race ) );
|
var effectivePrereq = prerequisites.Where( a => a.Traits.Get<BuildableInfo>().Owner.Contains( owner.Country.Race ) );
|
||||||
var nowHasPrerequisites = effectivePrereq.Any() &&
|
var nowHasPrerequisites = effectivePrereq.Any() &&
|
||||||
effectivePrereq.All( a => buildings[ a.Name ].Any( b => !b.traits.Get<Building>().Disabled ) );
|
effectivePrereq.All( a => buildings[ a.Name ].Any( b => !b.Trait<Building>().Disabled ) );
|
||||||
|
|
||||||
if( nowHasPrerequisites && !hasPrerequisites )
|
if( nowHasPrerequisites && !hasPrerequisites )
|
||||||
watcher.Available();
|
watcher.Available();
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public static bool IsPrimaryBuilding(this Actor a)
|
public static bool IsPrimaryBuilding(this Actor a)
|
||||||
{
|
{
|
||||||
var pb = a.traits.GetOrDefault<PrimaryBuilding>();
|
var pb = a.TraitOrDefault<PrimaryBuilding>();
|
||||||
return pb != null && pb.IsPrimary;
|
return pb != null && pb.IsPrimary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void DoProduction(Actor self, Actor newUnit, int2 exit, float2 spawn)
|
public void DoProduction(Actor self, Actor newUnit, int2 exit, float2 spawn)
|
||||||
{
|
{
|
||||||
var move = newUnit.traits.Get<IMove>();
|
var move = newUnit.Trait<IMove>();
|
||||||
var facing = newUnit.traits.GetOrDefault<IFacing>();
|
var facing = newUnit.TraitOrDefault<IFacing>();
|
||||||
|
|
||||||
// Set the physical position of the unit as the exit cell
|
// Set the physical position of the unit as the exit cell
|
||||||
move.SetPosition(newUnit,exit);
|
move.SetPosition(newUnit,exit);
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
// For the target line
|
// For the target line
|
||||||
var target = exit;
|
var target = exit;
|
||||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
var rp = self.TraitOrDefault<RallyPoint>();
|
||||||
if (rp != null)
|
if (rp != null)
|
||||||
{
|
{
|
||||||
target = rp.rallyPoint;
|
target = rp.rallyPoint;
|
||||||
@@ -70,13 +70,13 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var line = newUnit.traits.GetOrDefault<DrawLineToTarget>();
|
var line = newUnit.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTargetSilently(newUnit, Target.FromCell(target), Color.Green);
|
line.SetTargetSilently(newUnit, Target.FromCell(target), Color.Green);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var t in self.traits.WithInterface<INotifyProduction>())
|
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||||
t.UnitProduced(self, newUnit, exit);
|
t.UnitProduced(self, newUnit, exit);
|
||||||
|
|
||||||
Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID);
|
Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID);
|
||||||
@@ -91,7 +91,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
// Todo: remove assumption on Mobile;
|
// Todo: remove assumption on Mobile;
|
||||||
// required for 3-arg CanEnterCell
|
// required for 3-arg CanEnterCell
|
||||||
var mobile = newUnit.traits.Get<Mobile>();
|
var mobile = newUnit.Trait<Mobile>();
|
||||||
|
|
||||||
// Pick a spawn/exit point pair
|
// Pick a spawn/exit point pair
|
||||||
// Todo: Reorder in a synced random way
|
// Todo: Reorder in a synced random way
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Traits
|
|||||||
bool UpdateActive(Actor self)
|
bool UpdateActive(Actor self)
|
||||||
{
|
{
|
||||||
// Check if powered
|
// Check if powered
|
||||||
var b = self.traits.Get<Building>();
|
var b = self.Trait<Building>();
|
||||||
if (b.Disabled) return false;
|
if (b.Disabled) return false;
|
||||||
|
|
||||||
var isJammed = self.World.Queries.WithTrait<JamsRadar>().Any(a => self.Owner != a.Actor.Owner
|
var isJammed = self.World.Queries.WithTrait<JamsRadar>().Any(a => self.Owner != a.Actor.Owner
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Traits
|
|||||||
RepairableBuildingInfo Info;
|
RepairableBuildingInfo Info;
|
||||||
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
public RepairableBuilding(Actor self, RepairableBuildingInfo info)
|
||||||
{
|
{
|
||||||
Health = self.traits.Get<Health>();
|
Health = self.Trait<Health>();
|
||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Traits
|
|||||||
var costPerHp = (Info.RepairPercent * buildingValue) / Health.MaxHP;
|
var costPerHp = (Info.RepairPercent * buildingValue) / Health.MaxHP;
|
||||||
var hpToRepair = Math.Min(Info.RepairStep, Health.MaxHP - Health.HP);
|
var hpToRepair = Math.Min(Info.RepairStep, Health.MaxHP - Health.HP);
|
||||||
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
||||||
if (!self.Owner.PlayerActor.traits.Get<PlayerResources>().TakeCash(cost))
|
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
|
||||||
{
|
{
|
||||||
remainingTicks = 1;
|
remainingTicks = 1;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Traits
|
|||||||
if (!self.IsIdle && previousLocation != self.Location)
|
if (!self.IsIdle && previousLocation != self.Location)
|
||||||
{
|
{
|
||||||
previousLocation = self.Location;
|
previousLocation = self.Location;
|
||||||
self.World.WorldActor.traits.Get<Shroud>().UpdateActor(self);
|
self.World.WorldActor.Trait<Shroud>().UpdateActor(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void DrawHealthBar(Actor self, float2 xy, float2 Xy)
|
void DrawHealthBar(Actor self, float2 xy, float2 Xy)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
if (self.IsDead() || health == null)
|
if (self.IsDead() || health == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ namespace OpenRA.Traits
|
|||||||
var pipxyBase = basePosition + new float2(-12, -7); // Correct for the offset in the shp file
|
var pipxyBase = basePosition + new float2(-12, -7); // Correct for the offset in the shp file
|
||||||
var pipxyOffset = new float2(0, 0); // Correct for offset due to multiple columns/rows
|
var pipxyOffset = new float2(0, 0); // Correct for offset due to multiple columns/rows
|
||||||
|
|
||||||
foreach (var pips in self.traits.WithInterface<IPips>())
|
foreach (var pips in self.TraitsImplementing<IPips>())
|
||||||
{
|
{
|
||||||
foreach (var pip in pips.GetPips(self))
|
foreach (var pip in pips.GetPips(self))
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,7 @@ namespace OpenRA.Traits
|
|||||||
var tagxyBase = basePosition + new float2(-16, 2); // Correct for the offset in the shp file
|
var tagxyBase = basePosition + new float2(-16, 2); // Correct for the offset in the shp file
|
||||||
var tagxyOffset = new float2(0, 0); // Correct for offset due to multiple rows
|
var tagxyOffset = new float2(0, 0); // Correct for offset due to multiple rows
|
||||||
|
|
||||||
foreach (var tags in self.traits.WithInterface<ITags>())
|
foreach (var tags in self.TraitsImplementing<ITags>())
|
||||||
{
|
{
|
||||||
foreach (var tag in tags.GetTags())
|
foreach (var tag in tags.GetTags())
|
||||||
{
|
{
|
||||||
@@ -154,9 +154,9 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void DrawUnitPath(Actor self)
|
void DrawUnitPath(Actor self)
|
||||||
{
|
{
|
||||||
if (!Game.world.LocalPlayer.PlayerActor.traits.Get<DeveloperMode>().PathDebug) return;
|
if (!Game.world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug) return;
|
||||||
|
|
||||||
var mobile = self.traits.GetOrDefault<IMove>();
|
var mobile = self.TraitOrDefault<IMove>();
|
||||||
if (mobile != null)
|
if (mobile != null)
|
||||||
{
|
{
|
||||||
var alt = new float2(0, -mobile.Altitude);
|
var alt = new float2(0, -mobile.Altitude);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Traits
|
|||||||
RemainingTime = TotalTime;
|
RemainingTime = TotalTime;
|
||||||
Owner = self.Owner;
|
Owner = self.Owner;
|
||||||
|
|
||||||
self.traits.Get<TechTreeCache>().Add( Info.Prerequisites.Select( a => Rules.Info[ a.ToLowerInvariant() ] ).ToList(), this );
|
self.Trait<TechTreeCache>().Add( Info.Prerequisites.Select( a => Rules.Info[ a.ToLowerInvariant() ] ).ToList(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
@@ -69,7 +69,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
if (IsAvailable && (!Info.RequiresPower || IsPowered()))
|
if (IsAvailable && (!Info.RequiresPower || IsPowered()))
|
||||||
{
|
{
|
||||||
if (Game.LobbyInfo.GlobalSettings.AllowCheats && self.traits.Get<DeveloperMode>().FastCharge) RemainingTime = 0;
|
if (Game.LobbyInfo.GlobalSettings.AllowCheats && self.Trait<DeveloperMode>().FastCharge) RemainingTime = 0;
|
||||||
if (RemainingTime > 0) --RemainingTime;
|
if (RemainingTime > 0) --RemainingTime;
|
||||||
if (!notifiedCharging)
|
if (!notifiedCharging)
|
||||||
{
|
{
|
||||||
@@ -96,10 +96,10 @@ namespace OpenRA.Traits
|
|||||||
.Where(a => Rules.Info[a].Traits.Get<ValuedInfo>().Owner.Contains(Owner.Country.Race));
|
.Where(a => Rules.Info[a].Traits.Get<ValuedInfo>().Owner.Contains(Owner.Country.Race));
|
||||||
|
|
||||||
if (Info.Prerequisites.Count() == 0)
|
if (Info.Prerequisites.Count() == 0)
|
||||||
return Owner.PlayerActor.traits.Get<PlayerResources>().GetPowerState() == PowerState.Normal;
|
return Owner.PlayerActor.Trait<PlayerResources>().GetPowerState() == PowerState.Normal;
|
||||||
|
|
||||||
return effectivePrereq.Any() &&
|
return effectivePrereq.Any() &&
|
||||||
effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get<Building>().Disabled));
|
effectivePrereq.All(a => buildings[a].Any(b => !b.Trait<Building>().Disabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishActivate()
|
public void FinishActivate()
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
turretFacing = info.InitialFacing;
|
turretFacing = info.InitialFacing;
|
||||||
facing = self.traits.GetOrDefault<IFacing>();
|
facing = self.TraitOrDefault<IFacing>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Actor self )
|
public void Tick( Actor self )
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
@@ -37,9 +37,9 @@ namespace OpenRA.Traits
|
|||||||
bibSprites = info.BibTypes.Select(x => SpriteSheetBuilder.LoadAllSprites(x)).ToArray();
|
bibSprites = info.BibTypes.Select(x => SpriteSheetBuilder.LoadAllSprites(x)).ToArray();
|
||||||
|
|
||||||
self.World.ActorAdded +=
|
self.World.ActorAdded +=
|
||||||
a => { if (a.traits.Contains<Bib>()) DoBib(a,true); };
|
a => { if (a.HasTrait<Bib>()) DoBib(a,true); };
|
||||||
self.World.ActorRemoved +=
|
self.World.ActorRemoved +=
|
||||||
a => { if (a.traits.Contains<Bib>()) DoBib(a,false); };
|
a => { if (a.HasTrait<Bib>()) DoBib(a,false); };
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
int bib = Array.IndexOf(info.BibWidths,size);
|
int bib = Array.IndexOf(info.BibWidths,size);
|
||||||
if (bib < 0)
|
if (bib < 0)
|
||||||
{
|
{
|
||||||
Log.Write("debug", "Cannot bib {0}-wide building {1}", size, b.Info.Name);
|
Log.Write("debug", "Cannot bib {0}-wide building {1}", size, b.Info.Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,23 +72,23 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Render()
|
public void Render()
|
||||||
{
|
{
|
||||||
var cliprect = Game.viewport.ShroudBounds().HasValue
|
var cliprect = Game.viewport.ShroudBounds().HasValue
|
||||||
? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
|
? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
|
||||||
|
|
||||||
var minx = cliprect.Left;
|
var minx = cliprect.Left;
|
||||||
var maxx = cliprect.Right;
|
var maxx = cliprect.Right;
|
||||||
|
|
||||||
var miny = cliprect.Top;
|
var miny = cliprect.Top;
|
||||||
var maxy = cliprect.Bottom;
|
var maxy = cliprect.Bottom;
|
||||||
|
|
||||||
for (int x = minx; x < maxx; x++)
|
for (int x = minx; x < maxx; x++)
|
||||||
for (int y = miny; y < maxy; y++)
|
for (int y = miny; y < maxy; y++)
|
||||||
{
|
{
|
||||||
var t = new int2(x, y);
|
var t = new int2(x, y);
|
||||||
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
|
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(t) || tiles[x,y].type == 0) continue;
|
||||||
|
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[tiles[x, y].type - 1][tiles[x, y].image],
|
Game.Renderer.SpriteRenderer.DrawSprite(bibSprites[tiles[x, y].type - 1][tiles[x, y].image],
|
||||||
Game.CellSize * t, "terrain");
|
Game.CellSize * t, "terrain");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ namespace OpenRA.Traits
|
|||||||
influence = new Actor[map.MapSize.X, map.MapSize.Y];
|
influence = new Actor[map.MapSize.X, map.MapSize.Y];
|
||||||
|
|
||||||
world.ActorAdded +=
|
world.ActorAdded +=
|
||||||
a => { if (a.traits.Contains<Building>())
|
a => { if (a.HasTrait<Building>())
|
||||||
ChangeInfluence(a, a.traits.Get<Building>(), true); };
|
ChangeInfluence(a, a.Trait<Building>(), true); };
|
||||||
world.ActorRemoved +=
|
world.ActorRemoved +=
|
||||||
a => { if (a.traits.Contains<Building>())
|
a => { if (a.HasTrait<Building>())
|
||||||
ChangeInfluence(a, a.traits.Get<Building>(), false); };
|
ChangeInfluence(a, a.Trait<Building>(), false); };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeInfluence( Actor a, Building building, bool isAdd )
|
void ChangeInfluence( Actor a, Building building, bool isAdd )
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Traits
|
|||||||
this.world = w;
|
this.world = w;
|
||||||
content = new CellContents[w.Map.MapSize.X, w.Map.MapSize.Y];
|
content = new CellContents[w.Map.MapSize.X, w.Map.MapSize.Y];
|
||||||
|
|
||||||
resourceTypes = w.WorldActor.traits.WithInterface<ResourceType>().ToArray();
|
resourceTypes = w.WorldActor.TraitsImplementing<ResourceType>().ToArray();
|
||||||
foreach (var rt in resourceTypes)
|
foreach (var rt in resourceTypes)
|
||||||
rt.info.Sprites = rt.info.SpriteNames.Select(a => SpriteSheetBuilder.LoadAllSprites(a)).ToArray();
|
rt.info.Sprites = rt.info.SpriteNames.Select(a => SpriteSheetBuilder.LoadAllSprites(a)).ToArray();
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void AddActor(Actor a)
|
void AddActor(Actor a)
|
||||||
{
|
{
|
||||||
if (!a.traits.Contains<RevealsShroud>())
|
if (!a.HasTrait<RevealsShroud>())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (a.Owner == null || a.Owner.World.LocalPlayer == null
|
if (a.Owner == null || a.Owner.World.LocalPlayer == null
|
||||||
@@ -78,7 +78,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
var v = new ActorVisibility
|
var v = new ActorVisibility
|
||||||
{
|
{
|
||||||
range = a.traits.Get<RevealsShroud>().RevealRange,
|
range = a.Trait<RevealsShroud>().RevealRange,
|
||||||
vis = GetVisOrigins(a).ToArray()
|
vis = GetVisOrigins(a).ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var mobile = a.traits.GetOrDefault<Mobile>();
|
var mobile = a.TraitOrDefault<Mobile>();
|
||||||
if (mobile != null)
|
if (mobile != null)
|
||||||
return new[] { mobile.fromCell, mobile.toCell };
|
return new[] { mobile.fromCell, mobile.toCell };
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Traits
|
|||||||
for (int j = 0; j < world.Map.MapSize.Y; j++)
|
for (int j = 0; j < world.Map.MapSize.Y; j++)
|
||||||
influence[ i, j ] = new List<Actor>();
|
influence[ i, j ] = new List<Actor>();
|
||||||
|
|
||||||
world.ActorRemoved += a => Remove( a, a.traits.GetOrDefault<IOccupySpace>() );
|
world.ActorRemoved += a => Remove( a, a.TraitOrDefault<IOccupySpace>() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Actor self )
|
public void Tick( Actor self )
|
||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Traits
|
|||||||
for( int y = 0 ; y < self.World.Map.MapSize.Y ; y++ )
|
for( int y = 0 ; y < self.World.Map.MapSize.Y ; y++ )
|
||||||
if( influence[ x, y ] != null )
|
if( influence[ x, y ] != null )
|
||||||
foreach (var a in influence[ x, y ])
|
foreach (var a in influence[ x, y ])
|
||||||
if (!a.traits.Get<IOccupySpace>().OccupiedCells().Contains( new int2( x, y ) ) )
|
if (!a.Trait<IOccupySpace>().OccupiedCells().Contains( new int2( x, y ) ) )
|
||||||
throw new InvalidOperationException( "UIM: Sanity check failed A" );
|
throw new InvalidOperationException( "UIM: Sanity check failed A" );
|
||||||
|
|
||||||
foreach( var t in self.World.Queries.WithTraitMultiple<IOccupySpace>() )
|
foreach( var t in self.World.Queries.WithTraitMultiple<IOccupySpace>() )
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
if (Game.Settings.UnitDebug)
|
if (Game.Settings.UnitDebug)
|
||||||
{
|
{
|
||||||
var uim = world.WorldActor.traits.Get<UnitInfluence>();
|
var uim = world.WorldActor.Trait<UnitInfluence>();
|
||||||
|
|
||||||
for (var i = world.Map.Bounds.Left; i < world.Map.Bounds.Right; i++)
|
for (var i = world.Map.Bounds.Left; i < world.Map.Bounds.Right; i++)
|
||||||
for (var j = world.Map.Bounds.Top; j < world.Map.Bounds.Bottom; j++)
|
for (var j = world.Map.Bounds.Top; j < world.Map.Bounds.Bottom; j++)
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var res = world.WorldActor.traits.Get<ResourceLayer>();
|
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||||
var isCloseEnough = world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, topLeft);
|
var isCloseEnough = world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, topLeft);
|
||||||
foreach (var t in Footprint.Tiles(name, bi, topLeft))
|
foreach (var t in Footprint.Tiles(name, bi, topLeft))
|
||||||
Game.Renderer.SpriteRenderer.DrawSprite((isCloseEnough && world.IsCellBuildable(t, bi.WaterBound) && res.GetResource(t) == null)
|
Game.Renderer.SpriteRenderer.DrawSprite((isCloseEnough && world.IsCellBuildable(t, bi.WaterBound) && res.GetResource(t) == null)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_SHROUD").Checked =
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_SHROUD").Checked =
|
||||||
() => Game.world.LocalPlayer.PlayerActor.traits.Get<DeveloperMode>().DisableShroud;
|
() => Game.world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().DisableShroud;
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_SHROUD").OnMouseDown = mi =>
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_SHROUD").OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.IssueOrder(new Order("DevShroud", Game.world.LocalPlayer.PlayerActor));
|
Game.IssueOrder(new Order("DevShroud", Game.world.LocalPlayer.PlayerActor));
|
||||||
@@ -57,7 +57,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_PATHDEBUG").Checked =
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_PATHDEBUG").Checked =
|
||||||
() => Game.world.LocalPlayer.PlayerActor.traits.Get<DeveloperMode>().PathDebug;
|
() => Game.world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug;
|
||||||
devmodeBG.GetWidget("SETTINGS_CHECKBOX_PATHDEBUG").OnMouseDown = mi =>
|
devmodeBG.GetWidget("SETTINGS_CHECKBOX_PATHDEBUG").OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.IssueOrder(new Order("DevPathDebug", Game.world.LocalPlayer.PlayerActor));
|
Game.IssueOrder(new Order("DevPathDebug", Game.world.LocalPlayer.PlayerActor));
|
||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_BUILD_SPEED").Checked =
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_BUILD_SPEED").Checked =
|
||||||
() => Game.world.LocalPlayer.PlayerActor.traits.Get<DeveloperMode>().FastBuild;
|
() => Game.world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().FastBuild;
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_BUILD_SPEED").OnMouseDown = mi =>
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_BUILD_SPEED").OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.IssueOrder(new Order("DevFastBuild", Game.world.LocalPlayer.PlayerActor));
|
Game.IssueOrder(new Order("DevFastBuild", Game.world.LocalPlayer.PlayerActor));
|
||||||
@@ -79,7 +79,7 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
|
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHARGE_TIME").Checked =
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHARGE_TIME").Checked =
|
||||||
() => Game.world.LocalPlayer.PlayerActor.traits.Get<DeveloperMode>().FastCharge;
|
() => Game.world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().FastCharge;
|
||||||
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHARGE_TIME").OnMouseDown = mi =>
|
devmodeBG.GetWidget<CheckboxWidget>("SETTINGS_CHARGE_TIME").OnMouseDown = mi =>
|
||||||
{
|
{
|
||||||
Game.IssueOrder(new Order("DevFastCharge", Game.world.LocalPlayer.PlayerActor));
|
Game.IssueOrder(new Order("DevFastCharge", Game.world.LocalPlayer.PlayerActor));
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace OpenRA.Widgets
|
|||||||
var done = false;
|
var done = false;
|
||||||
foreach (var o in orders)
|
foreach (var o in orders)
|
||||||
{
|
{
|
||||||
foreach (var v in o.Subject.traits.WithInterface<IOrderVoice>())
|
foreach (var v in o.Subject.TraitsImplementing<IOrderVoice>())
|
||||||
{
|
{
|
||||||
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject))
|
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject))
|
||||||
{
|
{
|
||||||
@@ -174,7 +174,7 @@ namespace OpenRA.Widgets
|
|||||||
IEnumerable<Actor> SelectActorsInBox(World world, float2 a, float2 b)
|
IEnumerable<Actor> SelectActorsInBox(World world, float2 a, float2 b)
|
||||||
{
|
{
|
||||||
return world.FindUnits(a, b)
|
return world.FindUnits(a, b)
|
||||||
.Where( x => x.traits.Contains<Selectable>() && x.IsVisible() )
|
.Where( x => x.HasTrait<Selectable>() && x.IsVisible() )
|
||||||
.GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
|
.GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
|
||||||
.OrderByDescending(g => g.Key)
|
.OrderByDescending(g => g.Key)
|
||||||
.Select( g => g.AsEnumerable() )
|
.Select( g => g.AsEnumerable() )
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
Timer.Time( "worldActor: {0}" );
|
Timer.Time( "worldActor: {0}" );
|
||||||
|
|
||||||
foreach (var wlh in WorldActor.traits.WithInterface<ILoadWorldHook>())
|
foreach (var wlh in WorldActor.TraitsImplementing<ILoadWorldHook>())
|
||||||
wlh.WorldLoaded(this);
|
wlh.WorldLoaded(this);
|
||||||
|
|
||||||
PathFinder = new PathFinder(this);
|
PathFinder = new PathFinder(this);
|
||||||
@@ -235,8 +235,8 @@ namespace OpenRA
|
|||||||
return ret;
|
return ret;
|
||||||
ret = new CachedView<Actor, TraitPair<T>>(
|
ret = new CachedView<Actor, TraitPair<T>>(
|
||||||
set,
|
set,
|
||||||
x => x.traits.Contains<T>(),
|
x => x.HasTrait<T>(),
|
||||||
x => new TraitPair<T> { Actor = x, Trait = x.traits.Get<T>() } );
|
x => new TraitPair<T> { Actor = x, Trait = x.Trait<T>() } );
|
||||||
hasTrait.Add( ret );
|
hasTrait.Add( ret );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -248,8 +248,8 @@ namespace OpenRA
|
|||||||
return ret;
|
return ret;
|
||||||
ret = new CachedView<Actor, TraitPair<T>>(
|
ret = new CachedView<Actor, TraitPair<T>>(
|
||||||
world.actors,
|
world.actors,
|
||||||
x => x.traits.Contains<T>(),
|
x => x.HasTrait<T>(),
|
||||||
x => x.traits.WithInterface<T>().Select( t => new TraitPair<T> { Actor = x, Trait = t } ) );
|
x => x.TraitsImplementing<T>().Select( t => new TraitPair<T> { Actor = x, Trait = t } ) );
|
||||||
hasTrait.Add( ret );
|
hasTrait.Add( ret );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static bool IsCellBuildable(this World world, int2 a, bool waterBound, Actor toIgnore)
|
public static bool IsCellBuildable(this World world, int2 a, bool waterBound, Actor toIgnore)
|
||||||
{
|
{
|
||||||
if (world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(a) != null) return false;
|
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(a) != null) return false;
|
||||||
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
if (world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||||
|
|
||||||
if (waterBound)
|
if (waterBound)
|
||||||
return world.Map.IsInMap(a.X,a.Y) && GetTerrainInfo(world,a).IsWater;
|
return world.Map.IsInMap(a.X,a.Y) && GetTerrainInfo(world,a).IsWater;
|
||||||
@@ -47,7 +47,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var u = float2.Min(a, b).ToInt2();
|
var u = float2.Min(a, b).ToInt2();
|
||||||
var v = float2.Max(a, b).ToInt2();
|
var v = float2.Max(a, b).ToInt2();
|
||||||
return world.WorldActor.traits.Get<SpatialBins>().ActorsInBox(u,v);
|
return world.WorldActor.Trait<SpatialBins>().ActorsInBox(u,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
|
public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
|
||||||
@@ -95,7 +95,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
|
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
|
||||||
{
|
{
|
||||||
var res = world.WorldActor.traits.Get<ResourceLayer>();
|
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||||
return Footprint.Tiles(name, building, topLeft).All(
|
return Footprint.Tiles(name, building, topLeft).All(
|
||||||
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
|
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
|
||||||
world.IsCellBuildable(t, building.WaterBound, toIgnore));
|
world.IsCellBuildable(t, building.WaterBound, toIgnore));
|
||||||
@@ -106,11 +106,11 @@ namespace OpenRA
|
|||||||
if (a.World.LocalPlayer != null && a.World.LocalPlayer.Shroud.Disabled)
|
if (a.World.LocalPlayer != null && a.World.LocalPlayer.Shroud.Disabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var shroud = a.World.WorldActor.traits.Get<Shroud>();
|
var shroud = a.World.WorldActor.Trait<Shroud>();
|
||||||
if (!Shroud.GetVisOrigins(a).Any(o => a.World.Map.IsInMap(o) && shroud.exploredCells[o.X, o.Y])) // covered by shroud
|
if (!Shroud.GetVisOrigins(a).Any(o => a.World.Map.IsInMap(o) && shroud.exploredCells[o.X, o.Y])) // covered by shroud
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (a.traits.WithInterface<IVisibilityModifier>().Any(t => !t.IsVisible(a)))
|
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -131,7 +131,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
for( int x = scanStart.X ; x < scanEnd.X ; x++ )
|
for( int x = scanStart.X ; x < scanEnd.X ; x++ )
|
||||||
{
|
{
|
||||||
var at = world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt( new int2( x, y ) );
|
var at = world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt( new int2( x, y ) );
|
||||||
if( at != null && at.Owner.Stances[ p ] == Stance.Ally && at.Info.Traits.Get<BuildingInfo>().BaseNormal )
|
if( at != null && at.Owner.Stances[ p ] == Stance.Ally && at.Info.Traits.Get<BuildingInfo>().BaseNormal )
|
||||||
nearnessCandidates.Add( new int2( x, y ) );
|
nearnessCandidates.Add( new int2( x, y ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
|
public DeadBuildingState(Actor self, DeadBuildingStateInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
rs = self.traits.Get<RenderSimple>();
|
rs = self.Trait<RenderSimple>();
|
||||||
self.traits.Get<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
self.Trait<Health>().RemoveOnDeath = !rs.anim.HasSequence("dead");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
if (--poisonTicks <= 0)
|
if (--poisonTicks <= 0)
|
||||||
{
|
{
|
||||||
var rl = self.World.WorldActor.traits.Get<ResourceLayer>();
|
var rl = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
var r = rl.GetResource(self.Location);
|
var r = rl.GetResource(self.Location);
|
||||||
|
|
||||||
if (r != null && info.Resources.Contains(r.info.Name))
|
if (r != null && info.Resources.Contains(r.info.Name))
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
|
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
|
||||||
});
|
});
|
||||||
|
|
||||||
var cargo = a.traits.Get<Cargo>();
|
var cargo = a.Trait<Cargo>();
|
||||||
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
|
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
|
||||||
{
|
{
|
||||||
new OwnerInit( self.Owner ),
|
new OwnerInit( self.Owner ),
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Traits.Activities;
|
using OpenRA.Traits.Activities;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc
|
namespace OpenRA.Mods.Cnc
|
||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
float2 startDock = harv.CenterLocation;
|
float2 startDock = harv.CenterLocation;
|
||||||
float2 endDock = self.CenterLocation + new float2(-15,8);
|
float2 endDock = self.CenterLocation + new float2(-15,8);
|
||||||
var harvester = harv.traits.Get<Harvester>();
|
var harvester = harv.Trait<Harvester>();
|
||||||
|
|
||||||
harv.QueueActivity( new Turn(112) );
|
harv.QueueActivity( new Turn(112) );
|
||||||
harv.QueueActivity( new CallFunc( () =>
|
harv.QueueActivity( new CallFunc( () =>
|
||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
if (!preventDock)
|
if (!preventDock)
|
||||||
{
|
{
|
||||||
dockedHarv = harv;
|
dockedHarv = harv;
|
||||||
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
|
|
||||||
harv.QueueActivity( new Drag(startDock, endDock, 12) );
|
harv.QueueActivity( new Drag(startDock, endDock, 12) );
|
||||||
harv.QueueActivity( new CallFunc( () =>
|
harv.QueueActivity( new CallFunc( () =>
|
||||||
@@ -51,16 +51,16 @@ namespace OpenRA.Mods.Cnc
|
|||||||
harv.QueueActivity( new CallFunc( () => harvester.Visible = true, false ) );
|
harv.QueueActivity( new CallFunc( () => harvester.Visible = true, false ) );
|
||||||
harv.QueueActivity( new Drag(endDock, startDock, 12) );
|
harv.QueueActivity( new Drag(endDock, startDock, 12) );
|
||||||
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
||||||
if (harvester.LastHarvestedCell != int2.Zero)
|
if (harvester.LastHarvestedCell != int2.Zero)
|
||||||
{
|
{
|
||||||
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
|
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
|
||||||
if (harv.Owner == self.World.LocalPlayer)
|
if (harv.Owner == self.World.LocalPlayer)
|
||||||
self.World.AddFrameEndTask( w =>
|
self.World.AddFrameEndTask( w =>
|
||||||
{
|
{
|
||||||
var line = harv.traits.GetOrDefault<DrawLineToTarget>();
|
var line = harv.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTargetSilently(harv, Target.FromCell(harvester.LastHarvestedCell), Color.Green);
|
line.SetTargetSilently(harv, Target.FromCell(harvester.LastHarvestedCell), Color.Green);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
harv.QueueActivity( new Harvest() );
|
harv.QueueActivity( new Harvest() );
|
||||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// invisible harvester makes ceiling cat cry
|
// invisible harvester makes ceiling cat cry
|
||||||
harv.traits.Get<Harvester>().Visible = true;
|
harv.Trait<Harvester>().Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Selling (Actor self) { CancelDock(self, dockedHarv); }
|
public void Selling (Actor self) { CancelDock(self, dockedHarv); }
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
public IActivity Tick( Actor self )
|
public IActivity Tick( Actor self )
|
||||||
{
|
{
|
||||||
var facing = self.traits.Get<IFacing>();
|
var facing = self.Trait<IFacing>();
|
||||||
if (!Target.IsValid)
|
if (!Target.IsValid)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return new Move( Target, Range ) { NextActivity = this };
|
return new Move( Target, Range ) { NextActivity = this };
|
||||||
|
|
||||||
var desiredFacing = Util.GetFacing((targetCell - self.Location).ToFloat2(), 0);
|
var desiredFacing = Util.GetFacing((targetCell - self.Location).ToFloat2(), 0);
|
||||||
var renderUnit = self.traits.GetOrDefault<RenderUnit>();
|
var renderUnit = self.TraitOrDefault<RenderUnit>();
|
||||||
var numDirs = (renderUnit != null)
|
var numDirs = (renderUnit != null)
|
||||||
? renderUnit.anim.CurrentSequence.Facings : 8;
|
? renderUnit.anim.CurrentSequence.Facings : 8;
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return new Turn( desiredFacing ) { NextActivity = this };
|
return new Turn( desiredFacing ) { NextActivity = this };
|
||||||
}
|
}
|
||||||
|
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
attack.target = Target;
|
attack.target = Target;
|
||||||
attack.DoAttack(self);
|
attack.DoAttack(self);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
target.Owner = self.Owner;
|
target.Owner = self.Owner;
|
||||||
w.Add(target);
|
w.Add(target);
|
||||||
|
|
||||||
foreach (var t in target.traits.WithInterface<INotifyCapture>())
|
foreach (var t in target.TraitsImplementing<INotifyCapture>())
|
||||||
t.OnCapture(target, self, oldOwner, self.Owner);
|
t.OnCapture(target, self, oldOwner, self.Owner);
|
||||||
|
|
||||||
w.Remove(self);
|
w.Remove(self);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if( NextActivity != null )
|
if( NextActivity != null )
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var harv = self.traits.Get<Harvester>();
|
var harv = self.Trait<Harvester>();
|
||||||
|
|
||||||
if (harv.LinkedProc == null)
|
if (harv.LinkedProc == null)
|
||||||
harv.ChooseNewProc(self, null);
|
harv.ChooseNewProc(self, null);
|
||||||
@@ -36,14 +36,14 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
var proc = harv.LinkedProc;
|
var proc = harv.LinkedProc;
|
||||||
|
|
||||||
if( self.Location != proc.Location + proc.traits.Get<IAcceptOre>().DeliverOffset )
|
if( self.Location != proc.Location + proc.Trait<IAcceptOre>().DeliverOffset )
|
||||||
{
|
{
|
||||||
return new Move(proc.Location + proc.traits.Get<IAcceptOre>().DeliverOffset, 0) { NextActivity = this };
|
return new Move(proc.Location + proc.Trait<IAcceptOre>().DeliverOffset, 0) { NextActivity = this };
|
||||||
}
|
}
|
||||||
else if (!isDocking)
|
else if (!isDocking)
|
||||||
{
|
{
|
||||||
isDocking = true;
|
isDocking = true;
|
||||||
proc.traits.Get<IAcceptOre>().OnDock(self, this);
|
proc.Trait<IAcceptOre>().OnDock(self, this);
|
||||||
}
|
}
|
||||||
return new Wait(10) { NextActivity = this };
|
return new Wait(10) { NextActivity = this };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
if (transport == null || !transport.IsInWorld) return NextActivity;
|
if (transport == null || !transport.IsInWorld) return NextActivity;
|
||||||
|
|
||||||
var cargo = transport.traits.Get<Cargo>();
|
var cargo = transport.Trait<Cargo>();
|
||||||
if (cargo.IsFull(transport))
|
if (cargo.IsFull(transport))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (d.LengthSquared < 50) /* close enough */
|
if (d.LengthSquared < 50) /* close enough */
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
|
|
||||||
var desiredFacing = Util.GetFacing(d, aircraft.Facing);
|
var desiredFacing = Util.GetFacing(d, aircraft.Facing);
|
||||||
if (aircraft.Altitude == cruiseAltitude)
|
if (aircraft.Altitude == cruiseAltitude)
|
||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
public static void Fly(Actor self, int desiredAltitude )
|
public static void Fly(Actor self, int desiredAltitude )
|
||||||
{
|
{
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||||
var angle = aircraft.Facing / 128f * Math.PI;
|
var angle = aircraft.Facing / 128f * Math.PI;
|
||||||
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (!Target.IsValid)
|
if (!Target.IsValid)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if( isHarvesting ) return this;
|
if( isHarvesting ) return this;
|
||||||
if( NextActivity != null ) return NextActivity;
|
if( NextActivity != null ) return NextActivity;
|
||||||
|
|
||||||
var harv = self.traits.Get<Harvester>();
|
var harv = self.Trait<Harvester>();
|
||||||
harv.LastHarvestedCell = self.Location;
|
harv.LastHarvestedCell = self.Location;
|
||||||
|
|
||||||
if( harv.IsFull )
|
if( harv.IsFull )
|
||||||
@@ -42,10 +42,10 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
bool HarvestThisTile(Actor self)
|
bool HarvestThisTile(Actor self)
|
||||||
{
|
{
|
||||||
var harv = self.traits.Get<Harvester>();
|
var harv = self.Trait<Harvester>();
|
||||||
var renderUnit = self.traits.Get<RenderUnit>(); /* better have one of these! */
|
var renderUnit = self.Trait<RenderUnit>(); /* better have one of these! */
|
||||||
|
|
||||||
var resource = self.World.WorldActor.traits.Get<ResourceLayer>().Harvest(self.Location);
|
var resource = self.World.WorldActor.Trait<ResourceLayer>().Harvest(self.Location);
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
void FindMoreResource(Actor self)
|
void FindMoreResource(Actor self)
|
||||||
{
|
{
|
||||||
var res = self.World.WorldActor.traits.Get<ResourceLayer>();
|
var res = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
var harv = self.Info.Traits.Get<HarvesterInfo>();
|
var harv = self.Info.Traits.Get<HarvesterInfo>();
|
||||||
|
|
||||||
self.QueueActivity(new Move(
|
self.QueueActivity(new Move(
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (!target.IsValid)
|
if (!target.IsValid)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
{
|
{
|
||||||
self.QueueActivity(new HeliReturn());
|
self.QueueActivity(new HeliReturn());
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||||
if (aircraft.Altitude != info.CruiseAltitude)
|
if (aircraft.Altitude != info.CruiseAltitude)
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
var range = self.traits.Get<AttackBase>().GetMaximumRange() - 1;
|
var range = self.Trait<AttackBase>().GetMaximumRange() - 1;
|
||||||
var dist = target.CenterLocation - self.CenterLocation;
|
var dist = target.CenterLocation - self.CenterLocation;
|
||||||
|
|
||||||
var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
|
var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
||||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
|
|
||||||
if (aircraft.Altitude != info.CruiseAltitude)
|
if (aircraft.Altitude != info.CruiseAltitude)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
if (aircraft.Altitude == 0)
|
if (aircraft.Altitude == 0)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
new HeliLand(true),
|
new HeliLand(true),
|
||||||
NextActivity);
|
NextActivity);
|
||||||
|
|
||||||
var res = dest.traits.GetOrDefault<Reservable>();
|
var res = dest.TraitOrDefault<Reservable>();
|
||||||
if (res != null)
|
if (res != null)
|
||||||
self.traits.Get<Helicopter>().reservation = res.Reserve(self);
|
self.Trait<Helicopter>().reservation = res.Reserve(self);
|
||||||
|
|
||||||
var pi = dest.traits.Get<Production>();
|
var pi = dest.Trait<Production>();
|
||||||
var offset = pi != null ? pi.Spawns.First().First : float2.Zero;
|
var offset = pi != null ? pi.Spawns.First().First : float2.Zero;
|
||||||
|
|
||||||
return Util.SequenceActivities(
|
return Util.SequenceActivities(
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (target == null || target.IsDead()) return NextActivity;
|
if (target == null || target.IsDead()) return NextActivity;
|
||||||
if (target.Owner == self.Owner) return NextActivity;
|
if (target.Owner == self.Owner) return NextActivity;
|
||||||
|
|
||||||
foreach (var t in target.traits.WithInterface<IAcceptSpy>())
|
foreach (var t in target.TraitsImplementing<IAcceptSpy>())
|
||||||
t.OnInfiltrate(target, self);
|
t.OnInfiltrate(target, self);
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w => w.Remove(self));
|
self.World.AddFrameEndTask(w => w.Remove(self));
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (d.LengthSquared < 50) /* close enough */
|
if (d.LengthSquared < 50) /* close enough */
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
|
|
||||||
if (aircraft.Altitude > 0)
|
if (aircraft.Altitude > 0)
|
||||||
--aircraft.Altitude;
|
--aircraft.Altitude;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
if (canceled) return NextActivity;
|
if (canceled) return NextActivity;
|
||||||
|
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (!limitedAmmo.HasAmmo())
|
if (!limitedAmmo.HasAmmo())
|
||||||
{
|
{
|
||||||
// rearm & repair at fix, then back out here to refill the minefield some more
|
// rearm & repair at fix, then back out here to refill the minefield some more
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{ NextActivity = new Rearm() { NextActivity = new Repair(rearmTarget) { NextActivity = this } } };
|
{ NextActivity = new Rearm() { NextActivity = new Repair(rearmTarget) { NextActivity = this } } };
|
||||||
}
|
}
|
||||||
|
|
||||||
var ml = self.traits.Get<Minelayer>();
|
var ml = self.Trait<Minelayer>();
|
||||||
if (ml.minefield.Contains(self.Location) &&
|
if (ml.minefield.Contains(self.Location) &&
|
||||||
ShouldLayMine(self, self.Location))
|
ShouldLayMine(self, self.Location))
|
||||||
{
|
{
|
||||||
@@ -64,13 +64,13 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
bool ShouldLayMine(Actor self, int2 p)
|
bool ShouldLayMine(Actor self, int2 p)
|
||||||
{
|
{
|
||||||
// if there is no unit (other than me) here, we want to place a mine here
|
// if there is no unit (other than me) here, we want to place a mine here
|
||||||
return !self.World.WorldActor.traits.Get<UnitInfluence>()
|
return !self.World.WorldActor.Trait<UnitInfluence>()
|
||||||
.GetUnitsAt(p).Any(a => a != self);
|
.GetUnitsAt(p).Any(a => a != self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayMine(Actor self)
|
void LayMine(Actor self)
|
||||||
{
|
{
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null) limitedAmmo.Attacking(self);
|
if (limitedAmmo != null) limitedAmmo.Attacking(self);
|
||||||
|
|
||||||
self.World.AddFrameEndTask(
|
self.World.AddFrameEndTask(
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
this.target = target;
|
this.target = target;
|
||||||
initialLocation = self.CenterLocation;
|
initialLocation = self.CenterLocation;
|
||||||
|
|
||||||
self.traits.Get<RenderInfantry>().Attacking(self);
|
self.Trait<RenderInfantry>().Attacking(self);
|
||||||
Sound.Play("dogg5p.aud", self.CenterLocation);
|
Sound.Play("dogg5p.aud", self.CenterLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
if (t >= 1f)
|
if (t >= 1f)
|
||||||
{
|
{
|
||||||
self.traits.WithInterface<IMove>().FirstOrDefault()
|
self.TraitsImplementing<IMove>().FirstOrDefault()
|
||||||
.SetPosition(self, Util.CellContaining(target.CenterLocation));
|
.SetPosition(self, Util.CellContaining(target.CenterLocation));
|
||||||
|
|
||||||
if (target.IsActor)
|
if (target.IsActor)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo == null) return NextActivity;
|
if (limitedAmmo == null) return NextActivity;
|
||||||
|
|
||||||
if (--remainingTicks == 0)
|
if (--remainingTicks == 0)
|
||||||
@@ -33,10 +33,10 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (!limitedAmmo.GiveAmmo()) return NextActivity;
|
if (!limitedAmmo.GiveAmmo()) return NextActivity;
|
||||||
|
|
||||||
var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
|
var hostBuilding = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
|
||||||
.FirstOrDefault(a => a.traits.Contains<RenderBuilding>());
|
.FirstOrDefault(a => a.HasTrait<RenderBuilding>());
|
||||||
|
|
||||||
if (hostBuilding != null)
|
if (hostBuilding != null)
|
||||||
hostBuilding.traits.Get<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
|
hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
|
||||||
|
|
||||||
remainingTicks = ticksPerPip;
|
remainingTicks = ticksPerPip;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
if (remainingTicks == 0)
|
if (remainingTicks == 0)
|
||||||
{
|
{
|
||||||
var health = self.traits.GetOrDefault<Health>();
|
var health = self.TraitOrDefault<Health>();
|
||||||
if (health == null) return NextActivity;
|
if (health == null) return NextActivity;
|
||||||
|
|
||||||
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
var costPerHp = (repairsUnits.URepairPercent * unitCost) / health.MaxHP;
|
var costPerHp = (repairsUnits.URepairPercent * unitCost) / health.MaxHP;
|
||||||
var hpToRepair = Math.Min(host.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, health.MaxHP - health.HP);
|
var hpToRepair = Math.Min(host.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, health.MaxHP - health.HP);
|
||||||
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
||||||
if (!self.Owner.PlayerActor.traits.Get<PlayerResources>().TakeCash(cost))
|
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
|
||||||
{
|
{
|
||||||
remainingTicks = 1;
|
remainingTicks = 1;
|
||||||
return this;
|
return this;
|
||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
if (host != null)
|
if (host != null)
|
||||||
host.traits.Get<RenderBuilding>()
|
host.Trait<RenderBuilding>()
|
||||||
.PlayCustomAnim(host, "active");
|
.PlayCustomAnim(host, "active");
|
||||||
|
|
||||||
remainingTicks = (int)(repairsUnits.RepairRate * 60 * 25);
|
remainingTicks = (int)(repairsUnits.RepairRate * 60 * 25);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (target == null || target.IsDead()) return NextActivity;
|
if (target == null || target.IsDead()) return NextActivity;
|
||||||
var health = target.traits.Get<Health>();
|
var health = target.Trait<Health>();
|
||||||
if (health.DamageState == DamageState.Undamaged)
|
if (health.DamageState == DamageState.Undamaged)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
|
|||||||
@@ -40,16 +40,16 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
dest = ChooseAirfield(self);
|
dest = ChooseAirfield(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = dest.traits.GetOrDefault<Reservable>();
|
var res = dest.TraitOrDefault<Reservable>();
|
||||||
if (res != null)
|
if (res != null)
|
||||||
{
|
{
|
||||||
var plane = self.traits.Get<Plane>();
|
var plane = self.Trait<Plane>();
|
||||||
plane.UnReserve();
|
plane.UnReserve();
|
||||||
plane.reservation = res.Reserve(self);
|
plane.reservation = res.Reserve(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
var landPos = dest.CenterLocation;
|
var landPos = dest.CenterLocation;
|
||||||
var aircraft = self.traits.Get<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
|
|
||||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
self.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(self, destination);
|
self.TraitsImplementing<IMove>().FirstOrDefault().SetPosition(self, destination);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.sounds = sounds;
|
this.sounds = sounds;
|
||||||
this.facing = facing;
|
this.facing = facing;
|
||||||
rb = self.traits.GetOrDefault<RenderBuilding>();
|
rb = self.TraitOrDefault<RenderBuilding>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
@@ -59,8 +59,8 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
new OwnerInit( self.Owner ),
|
new OwnerInit( self.Owner ),
|
||||||
new FacingInit( facing ),
|
new FacingInit( facing ),
|
||||||
};
|
};
|
||||||
if (self.traits.Contains<Health>())
|
if (self.HasTrait<Health>())
|
||||||
init.Add( new HealthInit( self.traits.Get<Health>().HPFraction ));
|
init.Add( new HealthInit( self.Trait<Health>().HPFraction ));
|
||||||
|
|
||||||
var a = w.CreateActor( actor, init );
|
var a = w.CreateActor( actor, init );
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
int2? ChooseExitTile(Actor self, Actor cargo)
|
int2? ChooseExitTile(Actor self, Actor cargo)
|
||||||
{
|
{
|
||||||
// is anyone still hogging this tile?
|
// is anyone still hogging this tile?
|
||||||
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(self.Location).Count() > 1)
|
if (self.World.WorldActor.Trait<UnitInfluence>().GetUnitsAt(self.Location).Count() > 1)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var mobile = cargo.traits.Get<Mobile>();
|
var mobile = cargo.Trait<Mobile>();
|
||||||
|
|
||||||
for (var i = -1; i < 2; i++)
|
for (var i = -1; i < 2; i++)
|
||||||
for (var j = -1; j < 2; j++)
|
for (var j = -1; j < 2; j++)
|
||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
// if we're a thing that can turn, turn to the
|
// if we're a thing that can turn, turn to the
|
||||||
// right facing for the unload animation
|
// right facing for the unload animation
|
||||||
var facing = self.traits.GetOrDefault<IFacing>();
|
var facing = self.TraitOrDefault<IFacing>();
|
||||||
var unloadFacing = self.Info.Traits.Get<CargoInfo>().UnloadFacing;
|
var unloadFacing = self.Info.Traits.Get<CargoInfo>().UnloadFacing;
|
||||||
if (facing != null && facing.Facing != unloadFacing)
|
if (facing != null && facing.Facing != unloadFacing)
|
||||||
return new Turn(unloadFacing) { NextActivity = this };
|
return new Turn(unloadFacing) { NextActivity = this };
|
||||||
@@ -52,11 +52,11 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
// todo: handle the BS of open/close sequences, which are inconsistent,
|
// todo: handle the BS of open/close sequences, which are inconsistent,
|
||||||
// for reasons that probably make good sense to the westwood guys.
|
// for reasons that probably make good sense to the westwood guys.
|
||||||
|
|
||||||
var cargo = self.traits.Get<Cargo>();
|
var cargo = self.Trait<Cargo>();
|
||||||
if (cargo.IsEmpty(self))
|
if (cargo.IsEmpty(self))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var ru = self.traits.GetOrDefault<RenderUnit>();
|
var ru = self.TraitOrDefault<RenderUnit>();
|
||||||
if (ru != null)
|
if (ru != null)
|
||||||
ru.PlayCustomAnimation(self, "unload", null);
|
ru.PlayCustomAnimation(self, "unload", null);
|
||||||
|
|
||||||
@@ -69,12 +69,12 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Add(actor);
|
w.Add(actor);
|
||||||
actor.traits.WithInterface<IMove>().FirstOrDefault().SetPosition(actor, self.Location);
|
actor.TraitsImplementing<IMove>().FirstOrDefault().SetPosition(actor, self.Location);
|
||||||
actor.CancelActivity();
|
actor.CancelActivity();
|
||||||
actor.QueueActivity(new Move(exitTile.Value, 0));
|
actor.QueueActivity(new Move(exitTile.Value, 0));
|
||||||
if (actor.Owner == self.World.LocalPlayer)
|
if (actor.Owner == self.World.LocalPlayer)
|
||||||
{
|
{
|
||||||
var line = actor.traits.GetOrDefault<DrawLineToTarget>();
|
var line = actor.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTargetSilently(self, Target.FromCell(exitTile.Value), Color.Green);
|
line.SetTargetSilently(self, Target.FromCell(exitTile.Value), Color.Green);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public float MovementSpeedForCell(Actor self, int2 cell)
|
public float MovementSpeedForCell(Actor self, int2 cell)
|
||||||
{
|
{
|
||||||
var modifier = self.traits
|
var modifier = self
|
||||||
.WithInterface<ISpeedModifier>()
|
.TraitsImplementing<ISpeedModifier>()
|
||||||
.Select(t => t.GetSpeedModifier())
|
.Select(t => t.GetSpeedModifier())
|
||||||
.Product();
|
.Product();
|
||||||
return Info.Speed * modifier;
|
return Info.Speed * modifier;
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ namespace OpenRA.Mods.RA
|
|||||||
public IEnumerable<int2> RadarSignatureCells(Actor self)
|
public IEnumerable<int2> RadarSignatureCells(Actor self)
|
||||||
{
|
{
|
||||||
if (Space == null)
|
if (Space == null)
|
||||||
Space = self.traits.Get<IOccupySpace>();
|
Space = self.Trait<IOccupySpace>();
|
||||||
return Space.OccupiedCells();
|
return Space.OccupiedCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color RadarSignatureColor(Actor self)
|
public Color RadarSignatureColor(Actor self)
|
||||||
{
|
{
|
||||||
var mod = self.traits.WithInterface<IRadarColorModifier>().FirstOrDefault();
|
var mod = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
|
||||||
if (mod != null)
|
if (mod != null)
|
||||||
return mod.RadarColorOverride(self);
|
return mod.RadarColorOverride(self);
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (!target.IsValid) return false;
|
if (!target.IsValid) return false;
|
||||||
if (Weapons.All(w => w.IsReloading)) return false;
|
if (Weapons.All(w => w.IsReloading)) return false;
|
||||||
if (self.traits.WithInterface<IDisable>().Any(d => d.Disabled)) return false;
|
if (self.TraitsImplementing<IDisable>().Any(d => d.Disabled)) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -102,8 +102,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if( !CanAttack( self ) ) return;
|
if( !CanAttack( self ) ) return;
|
||||||
|
|
||||||
var move = self.traits.GetOrDefault<IMove>();
|
var move = self.TraitOrDefault<IMove>();
|
||||||
var facing = self.traits.GetOrDefault<IFacing>();
|
var facing = self.TraitOrDefault<IFacing>();
|
||||||
foreach (var w in Weapons)
|
foreach (var w in Weapons)
|
||||||
if (CheckFire(self, move, facing, w))
|
if (CheckFire(self, move, facing, w))
|
||||||
w.FiredShot();
|
w.FiredShot();
|
||||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (w.FireDelay > 0) return false;
|
if (w.FireDelay > 0) return false;
|
||||||
|
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!w.IsValidAgainst(target)) return false;
|
if (!w.IsValidAgainst(target)) return false;
|
||||||
|
|
||||||
var barrel = w.Barrels[w.Burst % w.Barrels.Length];
|
var barrel = w.Barrels[w.Burst % w.Barrels.Length];
|
||||||
var destMove = target.IsActor ? target.Actor.traits.GetOrDefault<IMove>() : null;
|
var destMove = target.IsActor ? target.Actor.TraitOrDefault<IMove>() : null;
|
||||||
|
|
||||||
var args = new ProjectileArgs
|
var args = new ProjectileArgs
|
||||||
{
|
{
|
||||||
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.RA
|
|||||||
destAltitude = destMove != null ? destMove.Altitude : 0,
|
destAltitude = destMove != null ? destMove.Altitude : 0,
|
||||||
|
|
||||||
facing = barrel.Facing +
|
facing = barrel.Facing +
|
||||||
(self.traits.Contains<Turreted>() ? self.traits.Get<Turreted>().turretFacing :
|
(self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing :
|
||||||
facing != null ? facing.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0)),
|
facing != null ? facing.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0)),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var na in self.traits.WithInterface<INotifyAttack>())
|
foreach (var na in self.TraitsImplementing<INotifyAttack>())
|
||||||
na.Attacking(self);
|
na.Attacking(self);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -219,7 +219,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.TargetActor != null)
|
if (order.TargetActor != null)
|
||||||
w.Add(new FlashTarget(order.TargetActor));
|
w.Add(new FlashTarget(order.TargetActor));
|
||||||
|
|
||||||
var line = self.traits.GetOrDefault<DrawLineToTarget>();
|
var line = self.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
if (order.TargetActor != null) line.SetTarget(self, Target.FromOrder(order), Color.Red);
|
if (order.TargetActor != null) line.SetTarget(self, Target.FromOrder(order), Color.Red);
|
||||||
else line.SetTarget(self, Target.FromOrder(order), Color.Red);
|
else line.SetTarget(self, Target.FromOrder(order), Color.Red);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (!target.IsValid) return;
|
if (!target.IsValid) return;
|
||||||
|
|
||||||
var facing = self.traits.Get<IFacing>().Facing;
|
var facing = self.Trait<IFacing>().Facing;
|
||||||
var facingToTarget = Util.GetFacing(target.CenterLocation - self.CenterLocation, facing);
|
var facingToTarget = Util.GetFacing(target.CenterLocation - self.CenterLocation, facing);
|
||||||
|
|
||||||
if (Math.Abs(facingToTarget - facing) % 256 < FacingTolerance)
|
if (Math.Abs(facingToTarget - facing) % 256 < FacingTolerance)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!target.IsValid) return;
|
if (!target.IsValid) return;
|
||||||
if (self.GetCurrentActivity() is Leap) return;
|
if (self.GetCurrentActivity() is Leap) return;
|
||||||
|
|
||||||
var weapon = self.traits.Get<AttackBase>().Weapons[0].Info;
|
var weapon = self.Trait<AttackBase>().Weapons[0].Info;
|
||||||
if (weapon.Range * Game.CellSize * weapon.Range * Game.CellSize
|
if (weapon.Range * Game.CellSize * weapon.Range * Game.CellSize
|
||||||
< (target.CenterLocation - self.CenterLocation).LengthSquared) return;
|
< (target.CenterLocation - self.CenterLocation).LengthSquared) return;
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected override bool CanAttack( Actor self )
|
protected override bool CanAttack( Actor self )
|
||||||
{
|
{
|
||||||
var isBuilding = ( self.traits.Contains<Building>() && !buildComplete );
|
var isBuilding = ( self.HasTrait<Building>() && !buildComplete );
|
||||||
return base.CanAttack( self ) && !isBuilding;
|
return base.CanAttack( self ) && !isBuilding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (target.Actor != previousTarget)
|
if (target.Actor != previousTarget)
|
||||||
{
|
{
|
||||||
previousTarget = target.Actor;
|
previousTarget = target.Actor;
|
||||||
self.traits.Get<RenderBuildingCharge>().PlayCharge(self);
|
self.Trait<RenderBuildingCharge>().PlayCharge(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected override bool CanAttack( Actor self )
|
protected override bool CanAttack( Actor self )
|
||||||
{
|
{
|
||||||
if( self.traits.Contains<Building>() && !buildComplete )
|
if( self.HasTrait<Building>() && !buildComplete )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!target.IsValid) return false;
|
if (!target.IsValid) return false;
|
||||||
var turreted = self.traits.Get<Turreted>();
|
var turreted = self.Trait<Turreted>();
|
||||||
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
|
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
|
||||||
if( turreted.desiredFacing != turreted.turretFacing )
|
if( turreted.desiredFacing != turreted.turretFacing )
|
||||||
return false;
|
return false;
|
||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected override void QueueAttack( Actor self, Order order )
|
protected override void QueueAttack( Actor self, Order order )
|
||||||
{
|
{
|
||||||
if (self.traits.Contains<Building>() && self.traits.Get<Building>().Disabled)
|
if (self.HasTrait<Building>() && self.Trait<Building>().Disabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
target = Target.FromOrder(order);
|
target = Target.FromOrder(order);
|
||||||
|
|
||||||
if (self.traits.Contains<Mobile>())
|
if (self.HasTrait<Mobile>())
|
||||||
self.QueueActivity( new Follow( target,
|
self.QueueActivity( new Follow( target,
|
||||||
Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
|
Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
void AttackTarget(Actor self, Actor target)
|
void AttackTarget(Actor self, Actor target)
|
||||||
{
|
{
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
if (target != null)
|
if (target != null)
|
||||||
attack.ResolveOrder(self, new Order("Attack", self, target));
|
attack.ResolveOrder(self, new Order("Attack", self, target));
|
||||||
else
|
else
|
||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
bool NeedsNewTarget(Actor self)
|
bool NeedsNewTarget(Actor self)
|
||||||
{
|
{
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
var range = attack.GetMaximumRange();
|
var range = attack.GetMaximumRange();
|
||||||
|
|
||||||
if (!attack.target.IsValid)
|
if (!attack.target.IsValid)
|
||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
var range = attack.GetMaximumRange();
|
var range = attack.GetMaximumRange();
|
||||||
|
|
||||||
if (NeedsNewTarget(self))
|
if (NeedsNewTarget(self))
|
||||||
@@ -57,12 +57,12 @@ namespace OpenRA.Mods.RA
|
|||||||
Actor ChooseTarget(Actor self, float range)
|
Actor ChooseTarget(Actor self, float range)
|
||||||
{
|
{
|
||||||
var inRange = self.World.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range);
|
var inRange = self.World.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range);
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
|
|
||||||
return inRange
|
return inRange
|
||||||
.Where(a => a != self && self.Owner.Stances[a.Owner] == Stance.Ally)
|
.Where(a => a != self && self.Owner.Stances[a.Owner] == Stance.Ally)
|
||||||
.Where(a => !a.IsDead())
|
.Where(a => !a.IsDead())
|
||||||
.Where(a => a.traits.Contains<Health>() && a.GetDamageState() > DamageState.Undamaged)
|
.Where(a => a.HasTrait<Health>() && a.GetDamageState() > DamageState.Undamaged)
|
||||||
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
||||||
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
void AttackTarget(Actor self, Actor target)
|
void AttackTarget(Actor self, Actor target)
|
||||||
{
|
{
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
if (target != null)
|
if (target != null)
|
||||||
attack.ResolveOrder(self, new Order("Attack", self, target));
|
attack.ResolveOrder(self, new Order("Attack", self, target));
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (--nextScanTime <= 0)
|
if (--nextScanTime <= 0)
|
||||||
{
|
{
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
var range = attack.GetMaximumRange();
|
var range = attack.GetMaximumRange();
|
||||||
|
|
||||||
if (!attack.target.IsValid ||
|
if (!attack.target.IsValid ||
|
||||||
@@ -53,12 +53,12 @@ namespace OpenRA.Mods.RA
|
|||||||
Actor ChooseTarget(Actor self, float range)
|
Actor ChooseTarget(Actor self, float range)
|
||||||
{
|
{
|
||||||
var inRange = self.World.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range);
|
var inRange = self.World.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range);
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
|
|
||||||
return inRange
|
return inRange
|
||||||
.Where(a => a.Owner != null && self.Owner.Stances[ a.Owner ] == Stance.Enemy)
|
.Where(a => a.Owner != null && self.Owner.Stances[ a.Owner ] == Stance.Enemy)
|
||||||
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
||||||
.Where(a => !a.traits.Contains<Cloak>() || !a.traits.Get<Cloak>().Cloaked)
|
.Where(a => !a.HasTrait<Cloak>() || !a.Trait<Cloak>().Cloaked)
|
||||||
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!self.IsIdle) return;
|
if (!self.IsIdle) return;
|
||||||
|
|
||||||
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
|
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
|
||||||
var attack = self.traits.Get<AttackBase>();
|
var attack = self.Trait<AttackBase>();
|
||||||
if (!attack.HasAnyValidWeapons(Target.FromActor(e.Attacker))) return;
|
if (!attack.HasAnyValidWeapons(Target.FromActor(e.Attacker))) return;
|
||||||
|
|
||||||
// don't retaliate against own units force-firing on us. it's usually not what the player wanted.
|
// don't retaliate against own units force-firing on us. it's usually not what the player wanted.
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public Bridge(Actor self, BridgeInfo info)
|
public Bridge(Actor self, BridgeInfo info)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
Health = self.traits.Get<Health>();
|
Health = self.Trait<Health>();
|
||||||
Health.RemoveOnDeath = false;
|
Health.RemoveOnDeath = false;
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
this.Type = self.Info.Name;
|
this.Type = self.Info.Name;
|
||||||
@@ -144,11 +144,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
void KillUnitsOnBridge()
|
void KillUnitsOnBridge()
|
||||||
{
|
{
|
||||||
var uim = self.World.WorldActor.traits.Get<UnitInfluence>();
|
var uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||||
|
|
||||||
foreach (var c in TileSprites[currentTemplate].Keys)
|
foreach (var c in TileSprites[currentTemplate].Keys)
|
||||||
foreach (var a in uim.GetUnitsAt(c))
|
foreach (var a in uim.GetUnitsAt(c))
|
||||||
if (a.traits.Contains<IMove>() && !a.traits.Get<IMove>().CanEnterCell(c))
|
if (a.HasTrait<IMove>() && !a.Trait<IMove>().CanEnterCell(c))
|
||||||
a.Kill(self);
|
a.Kill(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA
|
|||||||
ConvertBridgeToActor(w, i, j);
|
ConvertBridgeToActor(w, i, j);
|
||||||
|
|
||||||
// Link adjacent (long)-bridges so that artwork is updated correctly
|
// Link adjacent (long)-bridges so that artwork is updated correctly
|
||||||
foreach (var b in w.Actors.SelectMany(a => a.traits.WithInterface<Bridge>()))
|
foreach (var b in w.Actors.SelectMany(a => a.TraitsImplementing<Bridge>()))
|
||||||
b.LinkNeighbouringBridges(w,this);
|
b.LinkNeighbouringBridges(w,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.RA
|
|||||||
new LocationInit( new int2(ni, nj) ),
|
new LocationInit( new int2(ni, nj) ),
|
||||||
new OwnerInit( w.WorldActor.Owner ),
|
new OwnerInit( w.WorldActor.Owner ),
|
||||||
new HealthInit( BridgeTypes[tile].Second ),
|
new HealthInit( BridgeTypes[tile].Second ),
|
||||||
}).traits.Get<Bridge>();
|
}).Trait<Bridge>();
|
||||||
|
|
||||||
Dictionary<int2, byte> subTiles = new Dictionary<int2, byte>();
|
Dictionary<int2, byte> subTiles = new Dictionary<int2, byte>();
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
var anim = new Animation("fire", () => 0);
|
var anim = new Animation("fire", () => 0);
|
||||||
anim.PlayRepeating(self.Info.Traits.Get<BurnsInfo>().Anim);
|
anim.PlayRepeating(self.Info.Traits.Get<BurnsInfo>().Anim);
|
||||||
self.traits.Get<RenderSimple>().anims.Add("fire",
|
self.Trait<RenderSimple>().anims.Add("fire",
|
||||||
new RenderSimple.AnimationWithOffset(anim, () => new float2(0, -3), null));
|
new RenderSimple.AnimationWithOffset(anim, () => new float2(0, -3), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
if (underCursor == null) return null;
|
if (underCursor == null) return null;
|
||||||
if (underCursor.Owner == self.Owner && !mi.Modifiers.HasModifier(Modifiers.Ctrl)) return null;
|
if (underCursor.Owner == self.Owner && !mi.Modifiers.HasModifier(Modifiers.Ctrl)) return null;
|
||||||
if (!underCursor.traits.Contains<Building>()) return null;
|
if (!underCursor.HasTrait<Building>()) return null;
|
||||||
|
|
||||||
return new Order("C4", self, underCursor);
|
return new Order("C4", self, underCursor);
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
|
|||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Add(new FlashTarget(order.TargetActor));
|
w.Add(new FlashTarget(order.TargetActor));
|
||||||
var line = self.traits.GetOrDefault<DrawLineToTarget>();
|
var line = self.TraitOrDefault<DrawLineToTarget>();
|
||||||
if (line != null)
|
if (line != null)
|
||||||
line.SetTarget(self, Target.FromOrder(order), Color.Red);
|
line.SetTarget(self, Target.FromOrder(order), Color.Red);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Cannot unload mid-air
|
// Cannot unload mid-air
|
||||||
var move = self.traits.GetOrDefault<IMove>();
|
var move = self.TraitOrDefault<IMove>();
|
||||||
if (move != null && move.Altitude > 0)
|
if (move != null && move.Altitude > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
static PipType GetPipForPassenger(Actor a)
|
static PipType GetPipForPassenger(Actor a)
|
||||||
{
|
{
|
||||||
return a.traits.Get<Passenger>().ColorOfCargoPip( a );
|
return a.Trait<Passenger>().ColorOfCargoPip( a );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load(Actor self, Actor a)
|
public void Load(Actor self, Actor a)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if ((self.Location - Target).LengthSquared > info.Range * info.Range)
|
if ((self.Location - Target).LengthSquared > info.Range * info.Range)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -45,11 +45,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
var args = new ProjectileArgs
|
var args = new ProjectileArgs
|
||||||
{
|
{
|
||||||
srcAltitude = self.traits.Get<IMove>().Altitude,
|
srcAltitude = self.Trait<IMove>().Altitude,
|
||||||
destAltitude = 0,
|
destAltitude = 0,
|
||||||
src = self.CenterLocation.ToInt2(),
|
src = self.CenterLocation.ToInt2(),
|
||||||
dest = self.CenterLocation.ToInt2(),
|
dest = self.CenterLocation.ToInt2(),
|
||||||
facing = self.traits.Get<IFacing>().Facing,
|
facing = self.Trait<IFacing>().Facing,
|
||||||
firedBy = self,
|
firedBy = self,
|
||||||
weapon = weapon
|
weapon = weapon
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var movement = self.traits.GetOrDefault<IMove>();
|
var movement = self.TraitOrDefault<IMove>();
|
||||||
if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation))
|
if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation))
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ namespace OpenRA.Mods.RA
|
|||||||
chronoshiftReturnTicks = duration;
|
chronoshiftReturnTicks = duration;
|
||||||
|
|
||||||
// Kill cargo
|
// Kill cargo
|
||||||
if (killCargo && self.traits.Contains<Cargo>())
|
if (killCargo && self.HasTrait<Cargo>())
|
||||||
{
|
{
|
||||||
var cargo = self.traits.Get<Cargo>();
|
var cargo = self.Trait<Cargo>();
|
||||||
while (!cargo.IsEmpty(self))
|
while (!cargo.IsEmpty(self))
|
||||||
{
|
{
|
||||||
chronosphere.Owner.Kills++;
|
chronosphere.Owner.Kills++;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (warhead.SmudgeType != null)
|
if (warhead.SmudgeType != null)
|
||||||
{
|
{
|
||||||
var smudgeLayer = world.WorldActor.traits.WithInterface<SmudgeLayer>()
|
var smudgeLayer = world.WorldActor.TraitsImplementing<SmudgeLayer>()
|
||||||
.FirstOrDefault(x => x.Info.Type == warhead.SmudgeType);
|
.FirstOrDefault(x => x.Info.Type == warhead.SmudgeType);
|
||||||
if (smudgeLayer == null)
|
if (smudgeLayer == null)
|
||||||
throw new NotImplementedException("Unknown smudge type `{0}`".F(warhead.SmudgeType));
|
throw new NotImplementedException("Unknown smudge type `{0}`".F(warhead.SmudgeType));
|
||||||
@@ -68,10 +68,10 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (warhead.Ore)
|
if (warhead.Ore)
|
||||||
world.WorldActor.traits.Get<ResourceLayer>().Destroy(targetTile);
|
world.WorldActor.Trait<ResourceLayer>().Destroy(targetTile);
|
||||||
|
|
||||||
var firepowerModifier = args.firedBy.traits
|
var firepowerModifier = args.firedBy
|
||||||
.WithInterface<IFirepowerModifier>()
|
.TraitsImplementing<IFirepowerModifier>()
|
||||||
.Select(a => a.GetFirepowerModifier())
|
.Select(a => a.GetFirepowerModifier())
|
||||||
.Product();
|
.Product();
|
||||||
|
|
||||||
@@ -184,10 +184,10 @@ namespace OpenRA.Mods.RA
|
|||||||
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
|
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
|
||||||
if (abInfo == null || abInfo.Recoil == 0) return float2.Zero;
|
if (abInfo == null || abInfo.Recoil == 0) return float2.Zero;
|
||||||
|
|
||||||
var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
|
var rut = self.TraitOrDefault<RenderUnitTurreted>();
|
||||||
if (rut == null) return float2.Zero;
|
if (rut == null) return float2.Zero;
|
||||||
|
|
||||||
var facing = self.traits.Get<Turreted>().turretFacing;
|
var facing = self.Trait<Turreted>().turretFacing;
|
||||||
var localRecoil = new float2(0, recoil * abInfo.Recoil); // vector in turret-space.
|
var localRecoil = new float2(0, recoil * abInfo.Recoil); // vector in turret-space.
|
||||||
|
|
||||||
return Util.RotateVectorByFacing(localRecoil, facing, .7f);
|
return Util.RotateVectorByFacing(localRecoil, facing, .7f);
|
||||||
@@ -196,7 +196,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if(facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
|
if(facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
|
||||||
|
|
||||||
var ru = self.traits.GetOrDefault<RenderUnit>();
|
var ru = self.TraitOrDefault<RenderUnit>();
|
||||||
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
|
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
|
||||||
var bodyFacing = facing.Facing;
|
var bodyFacing = facing.Facing;
|
||||||
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
||||||
@@ -209,7 +209,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// gets the screen-space position of a barrel.
|
// gets the screen-space position of a barrel.
|
||||||
public static float2 GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
public static float2 GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
||||||
{
|
{
|
||||||
var turreted = self.traits.GetOrDefault<Turreted>();
|
var turreted = self.TraitOrDefault<Turreted>();
|
||||||
|
|
||||||
if (turreted == null && facing == null)
|
if (turreted == null && facing == null)
|
||||||
return float2.Zero;
|
return float2.Zero;
|
||||||
|
|||||||
@@ -54,12 +54,12 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
this.Info = info;
|
this.Info = info;
|
||||||
|
|
||||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
self.World.WorldActor.Trait<UnitInfluence>().Add(self, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
{
|
{
|
||||||
var shares = self.traits.WithInterface<CrateAction>().Select(
|
var shares = self.TraitsImplementing<CrateAction>().Select(
|
||||||
a => Pair.New(a, a.GetSelectionShares(crusher)));
|
a => Pair.New(a, a.GetSelectionShares(crusher)));
|
||||||
var totalShares = shares.Sum(a => a.Second);
|
var totalShares = shares.Sum(a => a.Second);
|
||||||
var n = self.World.SharedRandom.Next(totalShares);
|
var n = self.World.SharedRandom.Next(totalShares);
|
||||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void SetPosition(Actor self, int2 cell)
|
public void SetPosition(Actor self, int2 cell)
|
||||||
{
|
{
|
||||||
var uim = self.World.WorldActor.traits.Get<UnitInfluence>();
|
var uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||||
|
|
||||||
uim.Remove(self, this);
|
uim.Remove(self, this);
|
||||||
|
|
||||||
@@ -102,8 +102,8 @@ namespace OpenRA.Mods.RA
|
|||||||
self.CenterLocation = Util.CenterOfCell(cell);
|
self.CenterLocation = Util.CenterOfCell(cell);
|
||||||
|
|
||||||
var seq = self.World.GetTerrainInfo(cell).IsWater ? "water" : "idle";
|
var seq = self.World.GetTerrainInfo(cell).IsWater ? "water" : "idle";
|
||||||
if (seq != self.traits.Get<RenderSimple>().anim.CurrentSequence.Name)
|
if (seq != self.Trait<RenderSimple>().anim.CurrentSequence.Name)
|
||||||
self.traits.Get<RenderSimple>().anim.PlayRepeating(seq);
|
self.Trait<RenderSimple>().anim.PlayRepeating(seq);
|
||||||
|
|
||||||
uim.Add(self, this);
|
uim.Add(self, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType)) continue;
|
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType)) continue;
|
||||||
|
|
||||||
// Don't drop on any actors
|
// Don't drop on any actors
|
||||||
if (self.World.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(p) != null) continue;
|
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(p) != null) continue;
|
||||||
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p).Any()) continue;
|
if (self.World.WorldActor.Trait<UnitInfluence>().GetUnitsAt(p).Any()) continue;
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
@@ -81,8 +81,8 @@ namespace OpenRA.Mods.RA
|
|||||||
});
|
});
|
||||||
plane.CancelActivity();
|
plane.CancelActivity();
|
||||||
plane.QueueActivity(new FlyCircle(p));
|
plane.QueueActivity(new FlyCircle(p));
|
||||||
plane.traits.Get<ParaDrop>().SetLZ(p, null);
|
plane.Trait<ParaDrop>().SetLZ(p, null);
|
||||||
plane.traits.Get<Cargo>().Load(plane, crate);
|
plane.Trait<Cargo>().Load(plane, crate);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
public class CrateSpawnerInfo : TraitInfo<CrateSpawner>
|
public class CrateSpawnerInfo : TraitInfo<CrateSpawner>
|
||||||
@@ -62,14 +62,14 @@ namespace OpenRA.Mods.RA
|
|||||||
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType)) continue;
|
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType)) continue;
|
||||||
|
|
||||||
// Don't spawn on any actors
|
// Don't spawn on any actors
|
||||||
if (self.World.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(p) != null) continue;
|
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(p) != null) continue;
|
||||||
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p).Any()) continue;
|
if (self.World.WorldActor.Trait<UnitInfluence>().GetUnitsAt(p).Any()) continue;
|
||||||
|
|
||||||
self.World.AddFrameEndTask(
|
self.World.AddFrameEndTask(
|
||||||
w => crates.Add(w.CreateActor("crate", new TypeDictionary
|
w => crates.Add(w.CreateActor("crate", new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit( p ),
|
new LocationInit( p ),
|
||||||
new OwnerInit( self.World.WorldActor.Owner ),
|
new OwnerInit( self.World.WorldActor.Owner ),
|
||||||
})));
|
})));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
|
|
||||||
public override int GetSelectionShares(Actor collector)
|
public override int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
return collector.traits.Contains<Cloak>()
|
return collector.HasTrait<Cloak>()
|
||||||
? 0 : base.GetSelectionShares(collector);
|
? 0 : base.GetSelectionShares(collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Remove(collector);
|
w.Remove(collector);
|
||||||
collector.traits.Add(cloak);
|
collector.AddTrait(cloak);
|
||||||
w.Add(collector);
|
w.Add(collector);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
|
|||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var amount = (info as GiveCashCrateActionInfo).Amount;
|
var amount = (info as GiveCashCrateActionInfo).Amount;
|
||||||
collector.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash(amount);
|
collector.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(amount);
|
||||||
});
|
});
|
||||||
base.Activate(collector);
|
base.Activate(collector);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
int2? ChooseEmptyCellNear(Actor a)
|
int2? ChooseEmptyCellNear(Actor a)
|
||||||
{
|
{
|
||||||
// hack: use `a`'s movement capability.
|
// hack: use `a`'s movement capability.
|
||||||
var move = a.traits.Get<ITeleportable>();
|
var move = a.Trait<ITeleportable>();
|
||||||
var loc = a.Location;
|
var loc = a.Location;
|
||||||
|
|
||||||
for (var i = -1; i < 2; i++)
|
for (var i = -1; i < 2; i++)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
collector.World.AddFrameEndTask(w =>
|
collector.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var gainsExperience = collector.traits.GetOrDefault<GainsExperience>();
|
var gainsExperience = collector.TraitOrDefault<GainsExperience>();
|
||||||
if (gainsExperience != null)
|
if (gainsExperience != null)
|
||||||
gainsExperience.GiveOneLevel();
|
gainsExperience.GiveOneLevel();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
base.Activate(collector);
|
base.Activate(collector);
|
||||||
if (collector.Owner == collector.World.LocalPlayer)
|
if (collector.Owner == collector.World.LocalPlayer)
|
||||||
collector.World.WorldActor.traits.Get<Shroud>().ResetExploration();
|
collector.World.WorldActor.Trait<Shroud>().ResetExploration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
|
|
||||||
public override void Activate(Actor collector)
|
public override void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
var p = collector.Owner.PlayerActor.traits.WithInterface<SupportPower>()
|
var p = collector.Owner.PlayerActor.TraitsImplementing<SupportPower>()
|
||||||
.FirstOrDefault(sp => sp.GetType().Name == (info as SupportPowerCrateActionInfo).Power);
|
.FirstOrDefault(sp => sp.GetType().Name == (info as SupportPowerCrateActionInfo).Power);
|
||||||
|
|
||||||
if (p != null) p.Give(1);
|
if (p != null) p.Give(1);
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class DefaultShellmapScriptInfo : TraitInfo<DefaultShellmapScript> { }
|
class DefaultShellmapScriptInfo : TraitInfo<DefaultShellmapScript> { }
|
||||||
|
|
||||||
class DefaultShellmapScript: ILoadWorldHook, ITick
|
class DefaultShellmapScript: ILoadWorldHook, ITick
|
||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// Sound.PlayMusic("hell226m.aud");
|
// Sound.PlayMusic("hell226m.aud");
|
||||||
goodguy = w.players.Values.Where(x => x.InternalName == "GoodGuy").FirstOrDefault();
|
goodguy = w.players.Values.Where(x => x.InternalName == "GoodGuy").FirstOrDefault();
|
||||||
greece = w.players.Values.Where(x => x.InternalName == "Greece").FirstOrDefault();
|
greece = w.players.Values.Where(x => x.InternalName == "Greece").FirstOrDefault();
|
||||||
MapActors = w.WorldActor.traits.Get<SpawnMapActors>().MapActors;
|
MapActors = w.WorldActor.Trait<SpawnMapActors>().MapActors;
|
||||||
|
|
||||||
|
|
||||||
goodguy.Stances[greece] = Stance.Enemy;
|
goodguy.Stances[greece] = Stance.Enemy;
|
||||||
@@ -37,18 +37,18 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ticks == 250)
|
if (ticks == 250)
|
||||||
{
|
{
|
||||||
MapActors["pdox"].traits.Get<Chronosphere>().Teleport(MapActors["ca1"], new int2(90, 70));
|
MapActors["pdox"].Trait<Chronosphere>().Teleport(MapActors["ca1"], new int2(90, 70));
|
||||||
MapActors["pdox"].traits.Get<Chronosphere>().Teleport(MapActors["ca2"], new int2(92, 71));
|
MapActors["pdox"].Trait<Chronosphere>().Teleport(MapActors["ca2"], new int2(92, 71));
|
||||||
}
|
}
|
||||||
if (ticks == 100)
|
if (ticks == 100)
|
||||||
MapActors["mslo1"].traits.Get<NukeSilo>().Attack(new int2(96,53));
|
MapActors["mslo1"].Trait<NukeSilo>().Attack(new int2(96,53));
|
||||||
if (ticks == 110)
|
if (ticks == 110)
|
||||||
MapActors["mslo2"].traits.Get<NukeSilo>().Attack(new int2(92,53));
|
MapActors["mslo2"].Trait<NukeSilo>().Attack(new int2(92,53));
|
||||||
if (ticks == 120)
|
if (ticks == 120)
|
||||||
MapActors["mslo3"].traits.Get<NukeSilo>().Attack(new int2(94,50));
|
MapActors["mslo3"].Trait<NukeSilo>().Attack(new int2(94,50));
|
||||||
|
|
||||||
ticks++;
|
ticks++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Detonate(Actor self, Actor detonatedBy)
|
public void Detonate(Actor self, Actor detonatedBy)
|
||||||
{
|
{
|
||||||
var move = self.traits.GetOrDefault<IMove>();
|
var move = self.TraitOrDefault<IMove>();
|
||||||
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
var info = self.Info.Traits.Get<AttackBaseInfo>();
|
||||||
var altitude = move != null ? move.Altitude : 0;
|
var altitude = move != null ? move.Altitude : 0;
|
||||||
|
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ namespace OpenRA.Mods.RA
|
|||||||
ticks = info.Interval;
|
ticks = info.Interval;
|
||||||
|
|
||||||
var toDecloak = self.World.FindUnitsInCircle(self.CenterLocation, info.Range * Game.CellSize)
|
var toDecloak = self.World.FindUnitsInCircle(self.CenterLocation, info.Range * Game.CellSize)
|
||||||
.Where(a => a.traits.Contains<Cloak>());
|
.Where(a => a.HasTrait<Cloak>());
|
||||||
|
|
||||||
if (!info.AffectOwnUnits)
|
if (!info.AffectOwnUnits)
|
||||||
toDecloak = toDecloak.Where(a => self.Owner.Stances[a.Owner] != Stance.Ally);
|
toDecloak = toDecloak.Where(a => self.Owner.Stances[a.Owner] != Stance.Ally);
|
||||||
|
|
||||||
foreach (var a in toDecloak)
|
foreach (var a in toDecloak)
|
||||||
a.traits.Get<Cloak>().Decloak((int)(25 * info.DecloakTime));
|
a.Trait<Cloak>().Decloak((int)(25 * info.DecloakTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
var pos = float2.Lerp(Args.src, Args.dest, at);
|
var pos = float2.Lerp(Args.src, Args.dest, at);
|
||||||
var cell = Traits.Util.CellContaining(pos);
|
var cell = Traits.Util.CellContaining(pos);
|
||||||
|
|
||||||
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(cell).Any(
|
if (world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||||
a => a.traits.Contains<IBlocksBullets>()))
|
a => a.HasTrait<IBlocksBullets>()))
|
||||||
{
|
{
|
||||||
Args.dest = pos.ToInt2();
|
Args.dest = pos.ToInt2();
|
||||||
Explode(world);
|
Explode(world);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
public Corpse(Actor fromActor, int death)
|
public Corpse(Actor fromActor, int death)
|
||||||
{
|
{
|
||||||
anim = new Animation(fromActor.traits.GetOrDefault<RenderSimple>().GetImage(fromActor));
|
anim = new Animation(fromActor.TraitOrDefault<RenderSimple>().GetImage(fromActor));
|
||||||
anim.PlayThen("die{0}".F(death + 1),
|
anim.PlayThen("die{0}".F(death + 1),
|
||||||
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
|
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
public InvulnEffect(Actor a)
|
public InvulnEffect(Actor a)
|
||||||
{
|
{
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.b = a.traits.Get<IronCurtainable>();
|
this.b = a.Trait<IronCurtainable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( World world )
|
public void Tick( World world )
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user