Infiltration code cleanup
This commit is contained in:
@@ -27,10 +27,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
foreach (var t in target.Actor.TraitsImplementing<IAcceptInfiltrator>())
|
foreach (var t in target.Actor.TraitsImplementing<IAcceptInfiltrator>())
|
||||||
t.OnInfiltrate(target.Actor, self);
|
t.OnInfiltrate(target.Actor, self);
|
||||||
|
|
||||||
if (self.HasTrait<DontDestroyWhenInfiltrating>())
|
self.World.AddFrameEndTask(w => { if (!self.Destroyed) w.Remove(self); });
|
||||||
self.World.AddFrameEndTask(w => { if (!self.Destroyed) w.Remove(self); });
|
|
||||||
else
|
|
||||||
self.Destroy();
|
|
||||||
|
|
||||||
if (target.Actor.HasTrait<Building>())
|
if (target.Actor.HasTrait<Building>())
|
||||||
Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
|
Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Effects;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class InfiltrateForCashInfo : ITraitInfo
|
class InfiltrateForCashInfo : ITraitInfo, Requires<InfiltratableInfo>
|
||||||
{
|
{
|
||||||
public readonly int Percentage = 50;
|
public readonly int Percentage = 50;
|
||||||
public readonly int Minimum = 500;
|
public readonly int Minimum = 500;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using OpenRA.FileFormats;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class InfiltrateForExplorationInfo : TraitInfo<InfiltrateForExploration> {}
|
class InfiltrateForExplorationInfo : TraitInfo<InfiltrateForExploration>, Requires<InfiltratableInfo> { }
|
||||||
|
|
||||||
class InfiltrateForExploration : IAcceptInfiltrator
|
class InfiltrateForExploration : IAcceptInfiltrator
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using OpenRA.FileFormats;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class InfiltrateForSupportPowerInfo : ITraitInfo
|
class InfiltrateForSupportPowerInfo : ITraitInfo, Requires<InfiltratableInfo>
|
||||||
{
|
{
|
||||||
[ActorReference] public readonly string Proxy = null;
|
[ActorReference] public readonly string Proxy = null;
|
||||||
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
|
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
|
||||||
|
|||||||
@@ -13,16 +13,22 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
|
||||||
using OpenRA.Mods.RA.Orders;
|
using OpenRA.Mods.RA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Mods.RA.Missions;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
|
class InfiltratableInfo : TraitInfo<Infiltratable>
|
||||||
|
{
|
||||||
|
public string Type = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Infiltratable { }
|
||||||
|
|
||||||
class InfiltratesInfo : ITraitInfo
|
class InfiltratesInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public string[] InfiltrateTypes = {"Cash", "SupportPower", "Exploration"};
|
public string[] Types = { "Cash", "SupportPower", "Exploration" };
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Infiltrates(this); }
|
public object Create(ActorInitializer init) { return new Infiltrates(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,14 +39,13 @@ namespace OpenRA.Mods.RA
|
|||||||
public Infiltrates(InfiltratesInfo info)
|
public Infiltrates(InfiltratesInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
yield return new InfiltratorOrderTargeter(target => CanInfiltrate(target));
|
yield return new InfiltratorOrderTargeter(CanInfiltrate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,19 +78,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
bool CanInfiltrate(Actor target)
|
bool CanInfiltrate(Actor target)
|
||||||
{
|
{
|
||||||
if (Info.InfiltrateTypes.Contains("Cash") && target.HasTrait<InfiltrateForCash>())
|
var infiltratable = target.Info.Traits.GetOrDefault<InfiltratableInfo>();
|
||||||
return true;
|
return infiltratable != null && Info.Types.Contains(infiltratable.Type);
|
||||||
|
|
||||||
if (Info.InfiltrateTypes.Contains("SupportPower") && target.HasTrait<InfiltrateForSupportPower>())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Info.InfiltrateTypes.Contains("Exploration") && target.HasTrait<InfiltrateForExploration>())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Info.InfiltrateTypes.Contains("MissionObjective") && target.HasTrait<InfiltrateAction>())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfiltratorOrderTargeter : UnitOrderTargeter
|
class InfiltratorOrderTargeter : UnitOrderTargeter
|
||||||
|
|||||||
@@ -168,27 +168,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
BaseGuardTick();
|
BaseGuardTick();
|
||||||
|
|
||||||
if (allies1Spy.IsDead() || (allies2Spy != null && allies2Spy.IsDead()))
|
|
||||||
{
|
|
||||||
infiltrateLab.Status = ObjectiveStatus.Failed;
|
|
||||||
OnObjectivesUpdated(true);
|
|
||||||
MissionFailed("{0} spy was killed.".F(allies1 != allies2 ? "A" : "The"));
|
|
||||||
}
|
|
||||||
else if (lab.IsDead())
|
|
||||||
MissionFailed("The Soviet research laboratory was destroyed.");
|
|
||||||
else if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead()
|
|
||||||
&& (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))
|
|
||||||
{
|
|
||||||
destroyBase.Status = ObjectiveStatus.Failed;
|
|
||||||
OnObjectivesUpdated(true);
|
|
||||||
MissionFailed("The remaining Allied forces in the area have been wiped out.");
|
|
||||||
}
|
|
||||||
else if (SovietBaseDestroyed() && infiltrateLab.Status == ObjectiveStatus.Completed)
|
|
||||||
{
|
|
||||||
destroyBase.Status = ObjectiveStatus.Completed;
|
|
||||||
OnObjectivesUpdated(true);
|
|
||||||
MissionAccomplished("The Soviet research laboratory has been secured successfully.");
|
|
||||||
}
|
|
||||||
if (world.FrameNumber == nextCivilianMove)
|
if (world.FrameNumber == nextCivilianMove)
|
||||||
{
|
{
|
||||||
var civilians = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == creeps && a.HasTrait<Mobile>());
|
var civilians = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == creeps && a.HasTrait<Mobile>());
|
||||||
@@ -199,6 +178,38 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
nextCivilianMove += world.SharedRandom.Next(1, 75);
|
nextCivilianMove += world.SharedRandom.Next(1, 75);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.AddFrameEndTask(w =>
|
||||||
|
{
|
||||||
|
if ((allies1Spy.IsDead() && !allies1SpyInfiltratedLab) || (allies2Spy != null && allies2Spy.IsDead() && !allies2SpyInfiltratedLab))
|
||||||
|
{
|
||||||
|
infiltrateLab.Status = ObjectiveStatus.Failed;
|
||||||
|
OnObjectivesUpdated(true);
|
||||||
|
MissionFailed("{0} spy was killed.".F(allies1 != allies2 ? "A" : "The"));
|
||||||
|
}
|
||||||
|
else if (lab.IsDead())
|
||||||
|
{
|
||||||
|
if (infiltrateLab.Status == ObjectiveStatus.InProgress)
|
||||||
|
infiltrateLab.Status = ObjectiveStatus.Failed;
|
||||||
|
else if (destroyBase.Status == ObjectiveStatus.InProgress)
|
||||||
|
destroyBase.Status = ObjectiveStatus.Failed;
|
||||||
|
OnObjectivesUpdated(true);
|
||||||
|
MissionFailed("The Soviet research laboratory was destroyed.");
|
||||||
|
}
|
||||||
|
else if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead()
|
||||||
|
&& (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))
|
||||||
|
{
|
||||||
|
destroyBase.Status = ObjectiveStatus.Failed;
|
||||||
|
OnObjectivesUpdated(true);
|
||||||
|
MissionFailed("The remaining Allied forces in the area have been wiped out.");
|
||||||
|
}
|
||||||
|
else if (SovietBaseDestroyed() && infiltrateLab.Status == ObjectiveStatus.Completed)
|
||||||
|
{
|
||||||
|
destroyBase.Status = ObjectiveStatus.Completed;
|
||||||
|
OnObjectivesUpdated(true);
|
||||||
|
MissionAccomplished("The Soviet research laboratory has been secured successfully.");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SovietBaseDestroyed()
|
bool SovietBaseDestroyed()
|
||||||
|
|||||||
@@ -142,7 +142,4 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> {}
|
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> {}
|
||||||
class IgnoresDisguise {}
|
class IgnoresDisguise {}
|
||||||
|
|
||||||
class DontDestroyWhenInfiltratingInfo : TraitInfo<DontDestroyWhenInfiltrating> { }
|
|
||||||
class DontDestroyWhenInfiltrating { }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1817,6 +1817,8 @@ Rules:
|
|||||||
AutoTargetIgnore:
|
AutoTargetIgnore:
|
||||||
Allies04TransformOnLabInfiltrate:
|
Allies04TransformOnLabInfiltrate:
|
||||||
ToActor: MISS
|
ToActor: MISS
|
||||||
|
Infiltratable:
|
||||||
|
Type: Lab
|
||||||
LST.Unselectable:
|
LST.Unselectable:
|
||||||
Inherits: LST
|
Inherits: LST
|
||||||
Buildable:
|
Buildable:
|
||||||
@@ -1836,23 +1838,22 @@ Rules:
|
|||||||
Buildable:
|
Buildable:
|
||||||
Owner: None
|
Owner: None
|
||||||
SpyToolTip:
|
SpyToolTip:
|
||||||
Icon: SPY
|
Icon: spyicon
|
||||||
RenderSpy:
|
RenderSpy:
|
||||||
Image: SPY
|
Image: SPY
|
||||||
Health:
|
Health:
|
||||||
HP: 100
|
HP: 100
|
||||||
DontDestroyWhenInfiltrating:
|
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 6
|
Range: 6
|
||||||
Spy:
|
Spy:
|
||||||
Infiltrates:
|
Infiltrates:
|
||||||
InfiltrateTypes: MissionObjective
|
Types: Lab, Truck
|
||||||
DOG.Patrol:
|
DOG.Patrol:
|
||||||
Inherits: DOG
|
Inherits: DOG
|
||||||
Buildable:
|
Buildable:
|
||||||
Owner: None
|
Owner: None
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Icon: DOG
|
Icon: dogicon
|
||||||
Mobile:
|
Mobile:
|
||||||
Speed: 4
|
Speed: 4
|
||||||
RenderInfantry:
|
RenderInfantry:
|
||||||
@@ -1866,6 +1867,8 @@ Rules:
|
|||||||
MaxWeight: 5
|
MaxWeight: 5
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
AutoTargetIgnore:
|
AutoTargetIgnore:
|
||||||
|
Infiltratable:
|
||||||
|
Type: Truck
|
||||||
Allies04Hijackable:
|
Allies04Hijackable:
|
||||||
Allies04RenderHijacked:
|
Allies04RenderHijacked:
|
||||||
Image: TRUK
|
Image: TRUK
|
||||||
@@ -1875,7 +1878,7 @@ Rules:
|
|||||||
-RenderUnit:
|
-RenderUnit:
|
||||||
Selectable:
|
Selectable:
|
||||||
Voice: SpyVoice
|
Voice: SpyVoice
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 6
|
Range: 6
|
||||||
BARL:
|
BARL:
|
||||||
Allies04TrivialBuilding:
|
Allies04TrivialBuilding:
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ SPY:
|
|||||||
TakeCover:
|
TakeCover:
|
||||||
Spy:
|
Spy:
|
||||||
Infiltrates:
|
Infiltrates:
|
||||||
InfiltrateTypes: Cash, SupportPower, Exploration
|
Types: Cash, SupportPower, Exploration
|
||||||
-AutoTarget:
|
-AutoTarget:
|
||||||
AttackMove:
|
AttackMove:
|
||||||
JustMove: true
|
JustMove: true
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ GAP:
|
|||||||
|
|
||||||
SPEN:
|
SPEN:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
Infiltratable:
|
||||||
|
Type: SupportPower
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: powerproxy.sonarpulse
|
Proxy: powerproxy.sonarpulse
|
||||||
Valued:
|
Valued:
|
||||||
@@ -126,6 +128,8 @@ SPEN:
|
|||||||
|
|
||||||
SYRD:
|
SYRD:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
Infiltratable:
|
||||||
|
Type: SupportPower
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: powerproxy.sonarpulse
|
Proxy: powerproxy.sonarpulse
|
||||||
Buildable:
|
Buildable:
|
||||||
@@ -369,6 +373,8 @@ DOME:
|
|||||||
Bib:
|
Bib:
|
||||||
ProvidesRadar:
|
ProvidesRadar:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
Infiltratable:
|
||||||
|
Type: Exploration
|
||||||
InfiltrateForExploration:
|
InfiltrateForExploration:
|
||||||
|
|
||||||
PBOX:
|
PBOX:
|
||||||
@@ -972,6 +978,8 @@ PROC:
|
|||||||
InitialActivity: FindResources
|
InitialActivity: FindResources
|
||||||
SpawnOffset: 1,2
|
SpawnOffset: 1,2
|
||||||
Facing: 64
|
Facing: 64
|
||||||
|
Infiltratable:
|
||||||
|
Type: Cash
|
||||||
InfiltrateForCash:
|
InfiltrateForCash:
|
||||||
Percentage: 50
|
Percentage: 50
|
||||||
Minimum: 500
|
Minimum: 500
|
||||||
|
|||||||
Reference in New Issue
Block a user