.Trait[OrDefault]<Trait> => .Info.Traits.Get[OrDefault]<TraitInfo> where applicable
This commit is contained in:
@@ -17,20 +17,16 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
public class HeliReturn : Activity
|
||||
{
|
||||
readonly AircraftInfo aircraftInfo;
|
||||
readonly Helicopter heli;
|
||||
readonly HelicopterInfo heliInfo;
|
||||
|
||||
public HeliReturn(Actor self)
|
||||
{
|
||||
aircraftInfo = self.Info.Traits.Get<AircraftInfo>();
|
||||
heli = self.Trait<Helicopter>();
|
||||
heliInfo = self.Info.Traits.Get<HelicopterInfo>();
|
||||
}
|
||||
|
||||
public static Actor ChooseHelipad(Actor self)
|
||||
public Actor ChooseHelipad(Actor self)
|
||||
{
|
||||
var rearmBuildings = self.Info.Traits.Get<HelicopterInfo>().RearmBuildings;
|
||||
var rearmBuildings = heli.Info.RearmBuildings;
|
||||
return self.World.Actors.Where(a => a.Owner == self.Owner).FirstOrDefault(
|
||||
a => rearmBuildings.Contains(a.Info.Name) && !Reservable.IsReserved(a));
|
||||
}
|
||||
@@ -41,11 +37,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return NextActivity;
|
||||
|
||||
var dest = ChooseHelipad(self);
|
||||
var initialFacing = aircraftInfo.InitialFacing;
|
||||
var initialFacing = heli.Info.InitialFacing;
|
||||
|
||||
if (dest == null)
|
||||
{
|
||||
var rearmBuildings = heliInfo.RearmBuildings;
|
||||
var rearmBuildings = heli.Info.RearmBuildings;
|
||||
var nearestHpad = self.World.ActorsWithTrait<Reservable>()
|
||||
.Where(a => a.Actor.Owner == self.Owner && rearmBuildings.Contains(a.Actor.Info.Name))
|
||||
.Select(a => a.Actor)
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
readonly IMove movement;
|
||||
readonly Harvester harv;
|
||||
readonly HarvesterInfo harvInfo;
|
||||
|
||||
bool isDocking;
|
||||
int chosenTicks;
|
||||
@@ -30,7 +29,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
movement = self.Trait<IMove>();
|
||||
harv = self.Trait<Harvester>();
|
||||
harvInfo = self.Info.Traits.Get<HarvesterInfo>();
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -57,7 +55,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// No refineries exist; check again after delay defined in Harvester.
|
||||
if (harv.LinkedProc == null)
|
||||
return Util.SequenceActivities(new Wait(harvInfo.SearchForDeliveryBuildingDelay), this);
|
||||
return Util.SequenceActivities(new Wait(harv.Info.SearchForDeliveryBuildingDelay), this);
|
||||
|
||||
var proc = harv.LinkedProc;
|
||||
var iao = proc.Trait<IAcceptResources>();
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public class SpriteHarvesterDockSequence : HarvesterDockSequence
|
||||
{
|
||||
readonly WithSpriteBody wsb;
|
||||
readonly WithDockingAnimation wda;
|
||||
readonly WithDockingAnimationInfo wda;
|
||||
|
||||
public SpriteHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
|
||||
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
|
||||
{
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
wda = self.Trait<WithDockingAnimation>();
|
||||
wda = self.Info.Traits.Get<WithDockingAnimationInfo>();
|
||||
}
|
||||
|
||||
public override Activity OnStateDock(Actor self)
|
||||
@@ -30,14 +30,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
trait.Docked();
|
||||
|
||||
wsb.PlayCustomAnimation(self, wda.Info.DockSequence, () => wsb.PlayCustomAnimationRepeating(self, wda.Info.DockLoopSequence));
|
||||
wsb.PlayCustomAnimation(self, wda.DockSequence, () => wsb.PlayCustomAnimationRepeating(self, wda.DockLoopSequence));
|
||||
dockingState = State.Loop;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Activity OnStateUndock(Actor self)
|
||||
{
|
||||
wsb.PlayCustomAnimationBackwards(self, wda.Info.DockSequence,
|
||||
wsb.PlayCustomAnimationBackwards(self, wda.DockSequence,
|
||||
() =>
|
||||
{
|
||||
dockingState = State.Complete;
|
||||
|
||||
Reference in New Issue
Block a user