Merge pull request #7784 from reaperrr/fix-ctor-regressions

Fixes #7764, #7780...
This commit is contained in:
Oliver Brakmann
2015-03-31 00:06:01 +02:00
7 changed files with 13 additions and 18 deletions

View File

@@ -36,7 +36,6 @@ namespace OpenRA.Mods.Common.Traits
public class Helicopter : Aircraft, ITick, IResolveOrder, IMove
{
public readonly HelicopterInfo Info;
readonly bool fallsToEarth;
Actor self;
bool firstTick = true;
public bool IsMoving { get { return self.CenterPosition.Z > 0; } set { } }
@@ -46,7 +45,6 @@ namespace OpenRA.Mods.Common.Traits
{
self = init.Self;
Info = info;
fallsToEarth = self.HasTrait<FallsToEarth>();
}
public void ResolveOrder(Actor self, Order order)
@@ -132,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits
if (firstTick)
{
firstTick = false;
if (!fallsToEarth) // TODO: Aircraft husks don't properly unreserve.
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
ReserveSpawnBuilding();
var host = GetActorBelow();

View File

@@ -26,7 +26,6 @@ namespace OpenRA.Mods.Common.Traits
public class Plane : Aircraft, IResolveOrder, IMove, ITick, ISync
{
public readonly PlaneInfo Info;
readonly bool fallsToEarth;
[Sync] public WPos RTBPathHash;
Actor self;
public bool IsMoving { get { return self.CenterPosition.Z > 0; } set { } }
@@ -36,7 +35,6 @@ namespace OpenRA.Mods.Common.Traits
{
self = init.Self;
Info = info;
fallsToEarth = self.HasTrait<FallsToEarth>();
}
bool firstTick = true;
@@ -45,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
if (firstTick)
{
firstTick = false;
if (!fallsToEarth) // TODO: Aircraft husks don't properly unreserve.
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
ReserveSpawnBuilding();
var host = GetActorBelow();

View File

@@ -51,20 +51,21 @@ namespace OpenRA.Mods.Common.Traits
public class ExternalCapturable : ITick
{
readonly Building building;
[Sync] public int CaptureProgressTime = 0;
[Sync] public Actor Captor;
private Actor self;
public ExternalCapturableInfo Info;
public bool CaptureInProgress { get { return Captor != null; } }
public ExternalCapturable(Actor self, ExternalCapturableInfo info)
{
this.self = self;
Info = info;
building = self.TraitOrDefault<Building>();
}
public void BeginCapture(Actor captor)
{
var building = self.TraitOrDefault<Building>();
if (building != null)
building.Lock();
@@ -73,6 +74,7 @@ namespace OpenRA.Mods.Common.Traits
public void EndCapture()
{
var building = self.TraitOrDefault<Building>();
if (building != null)
building.Unlock();

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Makes the unit automatically run around when taking damage.")]
class ScaredyCatInfo : ITraitInfo
class ScaredyCatInfo : ITraitInfo, Requires<MobileInfo>
{
[Desc("How long (in ticks) the actor should panic for.")]
public readonly int PanicLength = 25 * 10;

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>
class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>, Requires<IMoveInfo>
{
[ActorReference] public readonly string[] Buildings = { "spen", "syrd" };
public readonly int CloseEnough = 4; /* cells */

View File

@@ -30,8 +30,6 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self;
readonly Lazy<Health> health;
readonly SellableInfo info;
readonly Building building;
readonly WithMakeAnimation makeAnimation;
public Sellable(Actor self, SellableInfo info)
: base(info)
@@ -39,8 +37,6 @@ namespace OpenRA.Mods.Common.Traits
this.self = self;
this.info = info;
health = Exts.Lazy(() => self.TraitOrDefault<Health>());
building = self.TraitOrDefault<Building>();
makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
}
public void ResolveOrder(Actor self, Order order)
@@ -54,6 +50,7 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled)
return;
var building = self.TraitOrDefault<Building>();
if (building != null && !building.Lock())
return;
@@ -65,6 +62,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Selling(self);
var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
if (makeAnimation != null)
makeAnimation.Reverse(self, new Sell(self), false);
else

View File

@@ -46,18 +46,14 @@ namespace OpenRA.Mods.Common.Traits
{
readonly Actor self;
readonly TransformsInfo info;
readonly Building building;
readonly BuildingInfo buildingInfo;
readonly string race;
readonly WithMakeAnimation makeAnimation;
public Transforms(ActorInitializer init, TransformsInfo info)
{
self = init.Self;
this.info = info;
buildingInfo = self.World.Map.Rules.Actors[info.IntoActor].Traits.GetOrDefault<BuildingInfo>();
building = self.TraitOrDefault<Building>();
makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
}
@@ -68,6 +64,7 @@ namespace OpenRA.Mods.Common.Traits
bool CanDeploy()
{
var building = self.TraitOrDefault<Building>();
if (building != null && building.Locked)
return false;
@@ -89,6 +86,7 @@ namespace OpenRA.Mods.Common.Traits
public void DeployTransform(bool queued)
{
var building = self.TraitOrDefault<Building>();
if (!CanDeploy() || (building != null && !building.Lock()))
{
foreach (var s in info.NoTransformSounds)
@@ -117,6 +115,7 @@ namespace OpenRA.Mods.Common.Traits
Race = race
};
var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
if (makeAnimation != null)
makeAnimation.Reverse(self, transform);
else