.Trait[OrDefault]<Trait> => .Info.Traits.Get[OrDefault]<TraitInfo> where applicable

This commit is contained in:
atlimit8
2015-08-02 18:31:57 -05:00
parent 8162fa27ab
commit 6970959ef1
16 changed files with 55 additions and 81 deletions

View File

@@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.AI
protected float RelativeSpeed(IEnumerable<Actor> own, IEnumerable<Actor> enemy) protected float RelativeSpeed(IEnumerable<Actor> own, IEnumerable<Actor> enemy)
{ {
return RelativeValue(own, enemy, 100, Average<MobileInfo>, (Actor a) => a.Trait<Mobile>().Info.Speed); return RelativeValue(own, enemy, 100, Average<MobileInfo>, (Actor a) => a.Info.Traits.Get<MobileInfo>().Speed);
} }
protected static float RelativeValue(IEnumerable<Actor> own, IEnumerable<Actor> enemy, float normalizeByValue, protected static float RelativeValue(IEnumerable<Actor> own, IEnumerable<Actor> enemy, float normalizeByValue,

View File

@@ -17,20 +17,16 @@ namespace OpenRA.Mods.Common.Activities
{ {
public class HeliReturn : Activity public class HeliReturn : Activity
{ {
readonly AircraftInfo aircraftInfo;
readonly Helicopter heli; readonly Helicopter heli;
readonly HelicopterInfo heliInfo;
public HeliReturn(Actor self) public HeliReturn(Actor self)
{ {
aircraftInfo = self.Info.Traits.Get<AircraftInfo>();
heli = self.Trait<Helicopter>(); 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( return self.World.Actors.Where(a => a.Owner == self.Owner).FirstOrDefault(
a => rearmBuildings.Contains(a.Info.Name) && !Reservable.IsReserved(a)); a => rearmBuildings.Contains(a.Info.Name) && !Reservable.IsReserved(a));
} }
@@ -41,11 +37,11 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
var dest = ChooseHelipad(self); var dest = ChooseHelipad(self);
var initialFacing = aircraftInfo.InitialFacing; var initialFacing = heli.Info.InitialFacing;
if (dest == null) if (dest == null)
{ {
var rearmBuildings = heliInfo.RearmBuildings; var rearmBuildings = heli.Info.RearmBuildings;
var nearestHpad = self.World.ActorsWithTrait<Reservable>() var nearestHpad = self.World.ActorsWithTrait<Reservable>()
.Where(a => a.Actor.Owner == self.Owner && rearmBuildings.Contains(a.Actor.Info.Name)) .Where(a => a.Actor.Owner == self.Owner && rearmBuildings.Contains(a.Actor.Info.Name))
.Select(a => a.Actor) .Select(a => a.Actor)

View File

@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Activities
readonly IMove movement; readonly IMove movement;
readonly Harvester harv; readonly Harvester harv;
readonly HarvesterInfo harvInfo;
bool isDocking; bool isDocking;
int chosenTicks; int chosenTicks;
@@ -30,7 +29,6 @@ namespace OpenRA.Mods.Common.Activities
{ {
movement = self.Trait<IMove>(); movement = self.Trait<IMove>();
harv = self.Trait<Harvester>(); harv = self.Trait<Harvester>();
harvInfo = self.Info.Traits.Get<HarvesterInfo>();
} }
public override Activity Tick(Actor self) 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. // No refineries exist; check again after delay defined in Harvester.
if (harv.LinkedProc == null) 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 proc = harv.LinkedProc;
var iao = proc.Trait<IAcceptResources>(); var iao = proc.Trait<IAcceptResources>();

View File

@@ -16,13 +16,13 @@ namespace OpenRA.Mods.Common.Activities
public class SpriteHarvesterDockSequence : HarvesterDockSequence public class SpriteHarvesterDockSequence : HarvesterDockSequence
{ {
readonly WithSpriteBody wsb; readonly WithSpriteBody wsb;
readonly WithDockingAnimation wda; readonly WithDockingAnimationInfo wda;
public SpriteHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength) public SpriteHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength) : base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
{ {
wsb = self.Trait<WithSpriteBody>(); wsb = self.Trait<WithSpriteBody>();
wda = self.Trait<WithDockingAnimation>(); wda = self.Info.Traits.Get<WithDockingAnimationInfo>();
} }
public override Activity OnStateDock(Actor self) public override Activity OnStateDock(Actor self)
@@ -30,14 +30,14 @@ namespace OpenRA.Mods.Common.Activities
foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>()) foreach (var trait in self.TraitsImplementing<INotifyHarvesterAction>())
trait.Docked(); 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; dockingState = State.Loop;
return this; return this;
} }
public override Activity OnStateUndock(Actor self) public override Activity OnStateUndock(Actor self)
{ {
wsb.PlayCustomAnimationBackwards(self, wda.Info.DockSequence, wsb.PlayCustomAnimationBackwards(self, wda.DockSequence,
() => () =>
{ {
dockingState = State.Complete; dockingState = State.Complete;

View File

@@ -137,10 +137,10 @@ namespace OpenRA.Mods.Common.Scripting
} }
else else
{ {
var heli = transport.TraitOrDefault<Helicopter>(); var heli = transport.Info.Traits.GetOrDefault<HelicopterInfo>();
if (heli != null) if (heli != null)
{ {
transport.QueueActivity(new Turn(transport, heli.Info.InitialFacing)); transport.QueueActivity(new Turn(transport, heli.InitialFacing));
transport.QueueActivity(new HeliLand(transport, true)); transport.QueueActivity(new HeliLand(transport, true));
transport.QueueActivity(new Wait(15)); transport.QueueActivity(new Wait(15));
} }

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
class Bridge : IRender, INotifyDamageStateChanged class Bridge : IRender, INotifyDamageStateChanged
{ {
readonly Building building; readonly BuildingInfo building;
readonly Bridge[] neighbours = new Bridge[2]; readonly Bridge[] neighbours = new Bridge[2];
readonly BridgeHut[] huts = new BridgeHut[2]; // Huts before this / first & after this / last readonly BridgeHut[] huts = new BridgeHut[2]; // Huts before this / first & after this / last
readonly Health health; readonly Health health;
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info; this.info = info;
type = self.Info.Name; type = self.Info.Name;
isDangling = new Lazy<bool>(() => huts[0] == huts[1] && (neighbours[0] == null || neighbours[1] == null)); isDangling = new Lazy<bool>(() => huts[0] == huts[1] && (neighbours[0] == null || neighbours[1] == null));
building = self.Trait<Building>(); building = self.Info.Traits.Get<BuildingInfo>();
} }
public Bridge Neighbour(int direction) { return neighbours[direction]; } public Bridge Neighbour(int direction) { return neighbours[direction]; }
@@ -173,7 +173,7 @@ namespace OpenRA.Mods.Common.Traits
IRenderable[] TemplateRenderables(WorldRenderer wr, PaletteReference palette, ushort template) IRenderable[] TemplateRenderables(WorldRenderer wr, PaletteReference palette, ushort template)
{ {
var offset = FootprintUtils.CenterOffset(self.World, building.Info).Y + 1024; var offset = FootprintUtils.CenterOffset(self.World, building).Y + 1024;
return footprint.Select(c => (IRenderable)(new SpriteRenderable( return footprint.Select(c => (IRenderable)(new SpriteRenderable(
wr.Theater.TileSprite(new TerrainTile(template, c.Value)), wr.Theater.TileSprite(new TerrainTile(template, c.Value)),

View File

@@ -31,22 +31,22 @@ namespace OpenRA.Mods.Common.Traits
world.ActorAdded += a => world.ActorAdded += a =>
{ {
var b = a.TraitOrDefault<Building>(); var b = a.Info.Traits.GetOrDefault<BuildingInfo>();
if (b == null) if (b == null)
return; return;
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location)) foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b, a.Location))
if (influence.Contains(u) && influence[u] == null) if (influence.Contains(u) && influence[u] == null)
influence[u] = a; influence[u] = a;
}; };
world.ActorRemoved += a => world.ActorRemoved += a =>
{ {
var b = a.TraitOrDefault<Building>(); var b = a.Info.Traits.GetOrDefault<BuildingInfo>();
if (b == null) if (b == null)
return; return;
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location)) foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b, a.Location))
if (influence.Contains(u) && influence[u] == a) if (influence.Contains(u) && influence[u] == a)
influence[u] = null; influence[u] = null;
}; };

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
public bool CanBeTargetedBy(Actor captor, Player owner) public bool CanBeTargetedBy(Actor captor, Player owner)
{ {
var c = captor.TraitOrDefault<Captures>(); var c = captor.Info.Traits.GetOrDefault<CapturesInfo>();
if (c == null) if (c == null)
return false; return false;
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
if (playerRelationship == Stance.Neutral && !AllowNeutral) if (playerRelationship == Stance.Neutral && !AllowNeutral)
return false; return false;
if (!c.Info.CaptureTypes.Contains(Type)) if (!c.CaptureTypes.Contains(Type))
return false; return false;
return true; return true;

View File

@@ -26,15 +26,15 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly DeveloperMode devMode; readonly DeveloperMode devMode;
readonly HealthInfo healthInfo;
Lazy<AttackBase> attack; Lazy<AttackBase> attack;
Lazy<BodyOrientation> coords; Lazy<BodyOrientation> coords;
Lazy<Health> health;
public CombatDebugOverlay(Actor self) public CombatDebugOverlay(Actor self)
{ {
healthInfo = self.Info.Traits.GetOrDefault<HealthInfo>();
attack = Exts.Lazy(() => self.TraitOrDefault<AttackBase>()); attack = Exts.Lazy(() => self.TraitOrDefault<AttackBase>());
coords = Exts.Lazy(() => self.Trait<BodyOrientation>()); coords = Exts.Lazy(() => self.Trait<BodyOrientation>());
health = Exts.Lazy(() => self.TraitOrDefault<Health>());
var localPlayer = self.World.LocalPlayer; var localPlayer = self.World.LocalPlayer;
devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null; devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null;
@@ -45,8 +45,8 @@ namespace OpenRA.Mods.Common.Traits
if (devMode == null || !devMode.ShowCombatGeometry) if (devMode == null || !devMode.ShowCombatGeometry)
return; return;
if (health.Value != null) if (healthInfo != null)
wr.DrawRangeCircle(self.CenterPosition, health.Value.Info.Radius, Color.Red); wr.DrawRangeCircle(self.CenterPosition, healthInfo.Radius, Color.Red);
// No armaments to draw // No armaments to draw
if (attack.Value == null) if (attack.Value == null)
@@ -96,11 +96,11 @@ namespace OpenRA.Mods.Common.Traits
if (devMode == null || !devMode.ShowCombatGeometry || e.Damage == 0) if (devMode == null || !devMode.ShowCombatGeometry || e.Damage == 0)
return; return;
var health = self.TraitOrDefault<Health>(); if (healthInfo == null)
if (health == null)
return; return;
var damageText = "{0} ({1}%)".F(-e.Damage, e.Damage * 100 / health.MaxHP); var maxHP = healthInfo.HP > 0 ? healthInfo.HP : 1;
var damageText = "{0} ({1}%)".F(-e.Damage, e.Damage * 100 / maxHP);
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color.RGB, damageText, 30))); self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color.RGB, damageText, 30)));
} }

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public bool CanBeTargetedBy(Actor captor, Player owner) public bool CanBeTargetedBy(Actor captor, Player owner)
{ {
var c = captor.TraitOrDefault<ExternalCaptures>(); var c = captor.Info.Traits.GetOrDefault<ExternalCapturesInfo>();
if (c == null) if (c == null)
return false; return false;
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
if (playerRelationship == Stance.Neutral && !AllowNeutral) if (playerRelationship == Stance.Neutral && !AllowNeutral)
return false; return false;
if (!c.Info.CaptureTypes.Contains(Type)) if (!c.CaptureTypes.Contains(Type))
return false; return false;
return true; return true;

View File

@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
IExplodeModifier, IOrderVoice, ISpeedModifier, ISync, INotifyCreated, IExplodeModifier, IOrderVoice, ISpeedModifier, ISync, INotifyCreated,
INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove, INotifyBuildComplete INotifyResourceClaimLost, INotifyIdle, INotifyBlockingMove, INotifyBuildComplete
{ {
readonly HarvesterInfo info; public readonly HarvesterInfo Info;
readonly Mobile mobile; readonly Mobile mobile;
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>(); Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
bool idleSmart = true; bool idleSmart = true;
@@ -92,20 +92,20 @@ namespace OpenRA.Mods.Common.Traits
public Harvester(Actor self, HarvesterInfo info) public Harvester(Actor self, HarvesterInfo info)
{ {
this.info = info; Info = info;
mobile = self.Trait<Mobile>(); mobile = self.Trait<Mobile>();
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null))); self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
} }
public void Created(Actor self) public void Created(Actor self)
{ {
if (info.SearchOnCreation) if (Info.SearchOnCreation)
self.QueueActivity(new FindResources(self)); self.QueueActivity(new FindResources(self));
} }
public void BuildingComplete(Actor self) public void BuildingComplete(Actor self)
{ {
if (info.SearchOnCreation) if (Info.SearchOnCreation)
self.QueueActivity(new FindResources(self)); self.QueueActivity(new FindResources(self));
} }
@@ -151,8 +151,8 @@ namespace OpenRA.Mods.Common.Traits
bool IsAcceptableProcType(Actor proc) bool IsAcceptableProcType(Actor proc)
{ {
return info.DeliveryBuildings.Count == 0 || return Info.DeliveryBuildings.Count == 0 ||
info.DeliveryBuildings.Contains(proc.Info.Name); Info.DeliveryBuildings.Contains(proc.Info.Name);
} }
public Actor ClosestProc(Actor self, Actor ignore) public Actor ClosestProc(Actor self, Actor ignore)
@@ -192,9 +192,9 @@ namespace OpenRA.Mods.Common.Traits
return null; return null;
} }
public bool IsFull { get { return contents.Values.Sum() == info.Capacity; } } public bool IsFull { get { return contents.Values.Sum() == Info.Capacity; } }
public bool IsEmpty { get { return contents.Values.Sum() == 0; } } public bool IsEmpty { get { return contents.Values.Sum() == 0; } }
public int Fullness { get { return contents.Values.Sum() * 100 / info.Capacity; } } public int Fullness { get { return contents.Values.Sum() * 100 / Info.Capacity; } }
public void AcceptResource(ResourceType type) public void AcceptResource(ResourceType type)
{ {
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
if (self.Location == deliveryLoc) if (self.Location == deliveryLoc)
{ {
// Get out of the way: // Get out of the way:
var unblockCell = LastHarvestedCell ?? (deliveryLoc + info.UnblockCell); var unblockCell = LastHarvestedCell ?? (deliveryLoc + Info.UnblockCell);
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5); var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
self.QueueActivity(mobile.MoveTo(moveTo, 1)); self.QueueActivity(mobile.MoveTo(moveTo, 1));
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false); self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
@@ -287,7 +287,7 @@ namespace OpenRA.Mods.Common.Traits
if (--contents[type] == 0) if (--contents[type] == 0)
contents.Remove(type); contents.Remove(type);
currentUnloadTicks = info.UnloadTicksPerBale; currentUnloadTicks = Info.UnloadTicksPerBale;
} }
return contents.Count == 0; return contents.Count == 0;
@@ -318,10 +318,10 @@ namespace OpenRA.Mods.Common.Traits
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
if (order.OrderString == "Harvest") if (order.OrderString == "Harvest")
return info.HarvestVoice; return Info.HarvestVoice;
if (order.OrderString == "Deliver" && !IsEmpty) if (order.OrderString == "Deliver" && !IsEmpty)
return info.DeliverVoice; return Info.DeliverVoice;
return null; return null;
} }
@@ -421,7 +421,7 @@ namespace OpenRA.Mods.Common.Traits
PipType GetPipAt(int i) PipType GetPipAt(int i)
{ {
var n = i * info.Capacity / info.PipCount; var n = i * Info.Capacity / Info.PipCount;
foreach (var rt in contents) foreach (var rt in contents)
if (n < rt.Value) if (n < rt.Value)
@@ -434,7 +434,7 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<PipType> GetPips(Actor self) public IEnumerable<PipType> GetPips(Actor self)
{ {
var numPips = info.PipCount; var numPips = Info.PipCount;
for (var i = 0; i < numPips; i++) for (var i = 0; i < numPips; i++)
yield return GetPipAt(i); yield return GetPipAt(i);
@@ -444,7 +444,7 @@ namespace OpenRA.Mods.Common.Traits
public int GetSpeedModifier() public int GetSpeedModifier()
{ {
return 100 - (100 - info.FullyLoadedSpeed) * contents.Values.Sum() / info.Capacity; return 100 - (100 - Info.FullyLoadedSpeed) * contents.Values.Sum() / Info.Capacity;
} }
class HarvestOrderTargeter : IOrderTargeter class HarvestOrderTargeter : IOrderTargeter

View File

@@ -15,22 +15,11 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Actor can capture ProximityCapturable actors.")] [Desc("Actor can capture ProximityCapturable actors.")]
public class ProximityCaptorInfo : ITraitInfo public class ProximityCaptorInfo : TraitInfo<ProximityCaptor>
{ {
[FieldLoader.Require] [FieldLoader.Require]
public readonly HashSet<string> Types = new HashSet<string>(); public readonly HashSet<string> Types = new HashSet<string>();
public object Create(ActorInitializer init) { return new ProximityCaptor(this); }
} }
public class ProximityCaptor public class ProximityCaptor { }
{
public readonly ProximityCaptorInfo Info;
public ProximityCaptor(ProximityCaptorInfo info) { Info = info; }
public bool HasAny(IEnumerable<string> typesList)
{
return Info.Types.Overlaps(typesList);
}
}
} }

View File

@@ -105,8 +105,8 @@ namespace OpenRA.Mods.Common.Traits
bool CanBeCapturedBy(Actor a) bool CanBeCapturedBy(Actor a)
{ {
var pc = a.TraitOrDefault<ProximityCaptor>(); var pc = a.Info.Traits.GetOrDefault<ProximityCaptorInfo>();
return pc != null && pc.HasAny(Info.CaptorTypes); return pc != null && pc.Types.Overlaps(Info.CaptorTypes);
} }
IEnumerable<Actor> UnitsInRange() IEnumerable<Actor> UnitsInRange()

View File

@@ -12,24 +12,14 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public class WithDockingAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<HarvesterInfo> public class WithDockingAnimationInfo : TraitInfo<WithDockingAnimation>, Requires<WithSpriteBodyInfo>, Requires<HarvesterInfo>
{ {
[Desc("Displayed when docking to refinery.")] [Desc("Displayed when docking to refinery.")]
[SequenceReference] public readonly string DockSequence = "dock"; [SequenceReference] public readonly string DockSequence = "dock";
[Desc("Looped while unloading at refinery.")] [Desc("Looped while unloading at refinery.")]
[SequenceReference] public readonly string DockLoopSequence = "dock-loop"; [SequenceReference] public readonly string DockLoopSequence = "dock-loop";
public object Create(ActorInitializer init) { return new WithDockingAnimation(init, this); }
} }
public class WithDockingAnimation public class WithDockingAnimation { }
{
public readonly WithDockingAnimationInfo Info;
public WithDockingAnimation(ActorInitializer init, WithDockingAnimationInfo info)
{
Info = info;
}
}
} }

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs()); var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
var sidebarTicker = playerWidgets.Get<LogicTickerWidget>("SIDEBAR_TICKER"); var sidebarTicker = playerWidgets.Get<LogicTickerWidget>("SIDEBAR_TICKER");
var objectives = world.LocalPlayer.PlayerActor.TraitOrDefault<MissionObjectives>(); var objectives = world.LocalPlayer.PlayerActor.Info.Traits.GetOrDefault<MissionObjectivesInfo>();
sidebarTicker.OnTick = () => sidebarTicker.OnTick = () =>
{ {
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (world.LocalPlayer.WinState != WinState.Undefined && !loadingObserverWidgets) if (world.LocalPlayer.WinState != WinState.Undefined && !loadingObserverWidgets)
{ {
loadingObserverWidgets = true; loadingObserverWidgets = true;
Game.RunAfterDelay(objectives != null ? objectives.Info.GameOverDelay : 0, () => Game.RunAfterDelay(objectives != null ? objectives.GameOverDelay : 0, () =>
{ {
playerRoot.RemoveChildren(); playerRoot.RemoveChildren();
Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs()); Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());

View File

@@ -50,7 +50,8 @@ namespace OpenRA.Mods.D2k.Traits
IsBusy = false; IsBusy = false;
IsCarrying = false; IsCarrying = false;
carryHeight = self.Trait<Helicopter>().Info.LandAltitude; var helicopter = self.Info.Traits.GetOrDefault<HelicopterInfo>();
carryHeight = helicopter != null ? helicopter.LandAltitude : WDist.Zero;
} }
public void OnBecomingIdle(Actor self) public void OnBecomingIdle(Actor self)