Actor.traits is implementation detail
This commit is contained in:
@@ -90,7 +90,7 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var mobile = self.traits.Get<Mobile>();
|
||||
var mobile = self.Trait<Mobile>();
|
||||
|
||||
if( move != null )
|
||||
{
|
||||
@@ -165,10 +165,10 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
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;
|
||||
|
||||
var nudge = blocker.traits.GetOrDefault<INudge>();
|
||||
var nudge = blocker.TraitOrDefault<INudge>();
|
||||
if (nudge != null)
|
||||
nudge.OnNudge(blocker, self);
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace OpenRA.Traits.Activities
|
||||
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
|
||||
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);
|
||||
|
||||
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);
|
||||
self.World.AddFrameEndTask( _ => self.World.Remove( self ) );
|
||||
}
|
||||
@@ -37,10 +37,10 @@ namespace OpenRA.Traits.Activities
|
||||
{
|
||||
if( !started )
|
||||
{
|
||||
framesRemaining = self.traits.Get<RenderSimple>().anim.HasSequence("make")
|
||||
? self.traits.Get<RenderSimple>().anim.GetSequence( "make" ).Length : 0;
|
||||
framesRemaining = self.Trait<RenderSimple>().anim.HasSequence("make")
|
||||
? 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 );
|
||||
|
||||
started = true;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
var facing = self.traits.Get<IFacing>();
|
||||
var facing = self.Trait<IFacing>();
|
||||
|
||||
if( desiredFacing == facing.Facing )
|
||||
return NextActivity;
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
public void Cancel( Actor self )
|
||||
{
|
||||
desiredFacing = self.traits.Get<IFacing>().Facing;
|
||||
desiredFacing = self.Trait<IFacing>().Facing;
|
||||
NextActivity = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user