@@ -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();
|
||||
self.World.AddFrameEndTask(w => { if (!self.Destroyed) w.Remove(self); });
|
||||
|
||||
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,27 +168,6 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
@@ -142,7 +142,4 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> {}
|
||||
class IgnoresDisguise {}
|
||||
|
||||
class DontDestroyWhenInfiltratingInfo : TraitInfo<DontDestroyWhenInfiltrating> { }
|
||||
class DontDestroyWhenInfiltrating { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user