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>())
|
||||
t.OnInfiltrate(target.Actor, self);
|
||||
|
||||
if (self.HasTrait<DontDestroyWhenInfiltrating>())
|
||||
self.World.AddFrameEndTask(w => { if (!self.Destroyed) w.Remove(self); });
|
||||
else
|
||||
self.Destroy();
|
||||
|
||||
if (target.Actor.HasTrait<Building>())
|
||||
Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class InfiltrateForCashInfo : ITraitInfo
|
||||
class InfiltrateForCashInfo : ITraitInfo, Requires<InfiltratableInfo>
|
||||
{
|
||||
public readonly int Percentage = 50;
|
||||
public readonly int Minimum = 500;
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class InfiltrateForExplorationInfo : TraitInfo<InfiltrateForExploration> {}
|
||||
class InfiltrateForExplorationInfo : TraitInfo<InfiltrateForExploration>, Requires<InfiltratableInfo> { }
|
||||
|
||||
class InfiltrateForExploration : IAcceptInfiltrator
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class InfiltrateForSupportPowerInfo : ITraitInfo
|
||||
class InfiltrateForSupportPowerInfo : ITraitInfo, Requires<InfiltratableInfo>
|
||||
{
|
||||
[ActorReference] public readonly string Proxy = null;
|
||||
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
|
||||
|
||||
@@ -13,16 +13,22 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Missions;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class InfiltratableInfo : TraitInfo<Infiltratable>
|
||||
{
|
||||
public string Type = null;
|
||||
}
|
||||
|
||||
class Infiltratable { }
|
||||
|
||||
class InfiltratesInfo : ITraitInfo
|
||||
{
|
||||
public string[] InfiltrateTypes = {"Cash", "SupportPower", "Exploration"};
|
||||
public string[] Types = { "Cash", "SupportPower", "Exploration" };
|
||||
|
||||
public object Create(ActorInitializer init) { return new Infiltrates(this); }
|
||||
}
|
||||
|
||||
@@ -33,14 +39,13 @@ namespace OpenRA.Mods.RA
|
||||
public Infiltrates(InfiltratesInfo info)
|
||||
{
|
||||
Info = info;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<IOrderTargeter> Orders
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (Info.InfiltrateTypes.Contains("Cash") && target.HasTrait<InfiltrateForCash>())
|
||||
return true;
|
||||
|
||||
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;
|
||||
var infiltratable = target.Info.Traits.GetOrDefault<InfiltratableInfo>();
|
||||
return infiltratable != null && Info.Types.Contains(infiltratable.Type);
|
||||
}
|
||||
|
||||
class InfiltratorOrderTargeter : UnitOrderTargeter
|
||||
|
||||
@@ -168,14 +168,34 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
BaseGuardTick();
|
||||
|
||||
if (allies1Spy.IsDead() || (allies2Spy != null && allies2Spy.IsDead()))
|
||||
if (world.FrameNumber == nextCivilianMove)
|
||||
{
|
||||
var civilians = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == creeps && a.HasTrait<Mobile>());
|
||||
if (civilians.Any())
|
||||
{
|
||||
var civilian = civilians.Random(world.SharedRandom);
|
||||
civilian.Trait<Mobile>().Nudge(civilian, civilian, true);
|
||||
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>()))
|
||||
{
|
||||
@@ -189,16 +209,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
OnObjectivesUpdated(true);
|
||||
MissionAccomplished("The Soviet research laboratory has been secured successfully.");
|
||||
}
|
||||
if (world.FrameNumber == nextCivilianMove)
|
||||
{
|
||||
var civilians = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == creeps && a.HasTrait<Mobile>());
|
||||
if (civilians.Any())
|
||||
{
|
||||
var civilian = civilians.Random(world.SharedRandom);
|
||||
civilian.Trait<Mobile>().Nudge(civilian, civilian, true);
|
||||
nextCivilianMove += world.SharedRandom.Next(1, 75);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool SovietBaseDestroyed()
|
||||
|
||||
@@ -142,7 +142,4 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> {}
|
||||
class IgnoresDisguise {}
|
||||
|
||||
class DontDestroyWhenInfiltratingInfo : TraitInfo<DontDestroyWhenInfiltrating> { }
|
||||
class DontDestroyWhenInfiltrating { }
|
||||
}
|
||||
|
||||
@@ -1817,6 +1817,8 @@ Rules:
|
||||
AutoTargetIgnore:
|
||||
Allies04TransformOnLabInfiltrate:
|
||||
ToActor: MISS
|
||||
Infiltratable:
|
||||
Type: Lab
|
||||
LST.Unselectable:
|
||||
Inherits: LST
|
||||
Buildable:
|
||||
@@ -1836,23 +1838,22 @@ Rules:
|
||||
Buildable:
|
||||
Owner: None
|
||||
SpyToolTip:
|
||||
Icon: SPY
|
||||
Icon: spyicon
|
||||
RenderSpy:
|
||||
Image: SPY
|
||||
Health:
|
||||
HP: 100
|
||||
DontDestroyWhenInfiltrating:
|
||||
RevealsShroud:
|
||||
Range: 6
|
||||
Spy:
|
||||
Infiltrates:
|
||||
InfiltrateTypes: MissionObjective
|
||||
Types: Lab, Truck
|
||||
DOG.Patrol:
|
||||
Inherits: DOG
|
||||
Buildable:
|
||||
Owner: None
|
||||
Tooltip:
|
||||
Icon: DOG
|
||||
Icon: dogicon
|
||||
Mobile:
|
||||
Speed: 4
|
||||
RenderInfantry:
|
||||
@@ -1866,6 +1867,8 @@ Rules:
|
||||
MaxWeight: 5
|
||||
PipCount: 5
|
||||
AutoTargetIgnore:
|
||||
Infiltratable:
|
||||
Type: Truck
|
||||
Allies04Hijackable:
|
||||
Allies04RenderHijacked:
|
||||
Image: TRUK
|
||||
|
||||
@@ -204,7 +204,7 @@ SPY:
|
||||
TakeCover:
|
||||
Spy:
|
||||
Infiltrates:
|
||||
InfiltrateTypes: Cash, SupportPower, Exploration
|
||||
Types: Cash, SupportPower, Exploration
|
||||
-AutoTarget:
|
||||
AttackMove:
|
||||
JustMove: true
|
||||
|
||||
@@ -71,6 +71,8 @@ GAP:
|
||||
|
||||
SPEN:
|
||||
Inherits: ^Building
|
||||
Infiltratable:
|
||||
Type: SupportPower
|
||||
InfiltrateForSupportPower:
|
||||
Proxy: powerproxy.sonarpulse
|
||||
Valued:
|
||||
@@ -126,6 +128,8 @@ SPEN:
|
||||
|
||||
SYRD:
|
||||
Inherits: ^Building
|
||||
Infiltratable:
|
||||
Type: SupportPower
|
||||
InfiltrateForSupportPower:
|
||||
Proxy: powerproxy.sonarpulse
|
||||
Buildable:
|
||||
@@ -369,6 +373,8 @@ DOME:
|
||||
Bib:
|
||||
ProvidesRadar:
|
||||
IronCurtainable:
|
||||
Infiltratable:
|
||||
Type: Exploration
|
||||
InfiltrateForExploration:
|
||||
|
||||
PBOX:
|
||||
@@ -972,6 +978,8 @@ PROC:
|
||||
InitialActivity: FindResources
|
||||
SpawnOffset: 1,2
|
||||
Facing: 64
|
||||
Infiltratable:
|
||||
Type: Cash
|
||||
InfiltrateForCash:
|
||||
Percentage: 50
|
||||
Minimum: 500
|
||||
|
||||
Reference in New Issue
Block a user