Initial commit: OpenRA game engine
Some checks failed
Continuous Integration / Linux (.NET 8.0) (push) Has been cancelled
Continuous Integration / Windows (.NET 8.0) (push) Has been cancelled

Fork from OpenRA/OpenRA with one-click launch script (start-ra.cmd)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
let5sne.win10
2026-01-10 21:46:54 +08:00
commit 9cf6ebb986
4065 changed files with 635973 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
[Desc("Funds are transferred from the owner to the infiltrator.")]
sealed class InfiltrateForCashInfo : TraitInfo
{
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Percentage of the victim's resources that will be stolen.")]
public readonly int Percentage = 100;
[Desc("Amount of guaranteed funds to claim when the victim does not have enough resources.",
"When negative, the production price of the infiltrating actor will be used instead.")]
public readonly int Minimum = -1;
[Desc("Maximum amount of funds which will be stolen.")]
public readonly int Maximum = int.MaxValue;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[Desc("Experience to grant to the infiltrating player based on cash stolen.")]
public readonly int PlayerExperiencePercentage = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get robbed.")]
public readonly string InfiltratedNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the victim will see when they get robbed.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
[Desc("Whether to show the cash tick indicators rising from the actor.")]
public readonly bool ShowTicks = true;
public override object Create(ActorInitializer init) { return new InfiltrateForCash(this); }
}
sealed class InfiltrateForCash : INotifyInfiltrated
{
readonly InfiltrateForCashInfo info;
public InfiltrateForCash(InfiltrateForCashInfo info) { this.info = info; }
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
var targetResources = self.Owner.PlayerActor.Trait<PlayerResources>();
var spyResources = infiltrator.Owner.PlayerActor.Trait<PlayerResources>();
var spyValue = infiltrator.Info.TraitInfoOrDefault<ValuedInfo>();
var toTake = Math.Min(info.Maximum, (targetResources.Cash + targetResources.Resources) * info.Percentage / 100);
var toGive = Math.Max(toTake, info.Minimum >= 0 ? info.Minimum : spyValue != null ? spyValue.Cost : 0);
targetResources.TakeCash(toTake);
spyResources.GiveCash(toGive);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience + toTake * info.PlayerExperiencePercentage / 100);
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(self.Owner, info.InfiltratedTextNotification);
TextNotificationsManager.AddTransientLine(infiltrator.Owner, info.InfiltrationTextNotification);
if (info.ShowTicks)
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.OwnerColor(), FloatingText.FormatCashTick(toGive), 30)));
}
}
}

View File

@@ -0,0 +1,59 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Traits.Render;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
[Desc("Reveals a decoration sprite to the indicated players when infiltrated.")]
sealed class InfiltrateForDecorationInfo : WithDecorationInfo
{
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
public override object Create(ActorInitializer init) { return new InfiltrateForDecoration(init.Self, this); }
}
sealed class InfiltrateForDecoration : WithDecoration, INotifyInfiltrated
{
readonly HashSet<Player> infiltrators = [];
readonly InfiltrateForDecorationInfo info;
public InfiltrateForDecoration(Actor self, InfiltrateForDecorationInfo info)
: base(self, info)
{
this.info = info;
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
infiltrators.Add(infiltrator.Owner);
}
protected override bool ShouldRender(Actor self)
{
return infiltrators.Any(i => Info.ValidRelationships.HasRelationship(i.RelationshipWith(self.World.RenderPlayer)));
}
}
}

View File

@@ -0,0 +1,79 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
[Desc("Steal and reset the owner's exploration.")]
sealed class InfiltrateForExplorationInfo : TraitInfo
{
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForExploration(this); }
}
sealed class InfiltrateForExploration : INotifyInfiltrated
{
readonly InfiltrateForExplorationInfo info;
public InfiltrateForExploration(InfiltrateForExplorationInfo info)
{
this.info = info;
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(self.Owner, info.InfiltratedTextNotification);
TextNotificationsManager.AddTransientLine(infiltrator.Owner, info.InfiltrationTextNotification);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
.Any(p => p.PreventShroudReset(self));
if (!preventReset)
self.Owner.Shroud.ResetExploration();
}
}
}

View File

@@ -0,0 +1,83 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
sealed class InfiltrateForPowerOutageInfo : TraitInfo
{
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Measured in ticks.")]
public readonly int Duration = 500;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForPowerOutage(init.Self, this); }
}
sealed class InfiltrateForPowerOutage : INotifyOwnerChanged, INotifyInfiltrated
{
readonly InfiltrateForPowerOutageInfo info;
PowerManager playerPower;
public InfiltrateForPowerOutage(Actor self, InfiltrateForPowerOutageInfo info)
{
this.info = info;
playerPower = self.Owner.PlayerActor.Trait<PowerManager>();
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(self.Owner, info.InfiltratedTextNotification);
TextNotificationsManager.AddTransientLine(infiltrator.Owner, info.InfiltrationTextNotification);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
playerPower.TriggerPowerOutage(info.Duration);
}
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
playerPower = self.Owner.PlayerActor.Trait<PowerManager>();
}
}
}

View File

@@ -0,0 +1,80 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
sealed class InfiltrateForSupportPowerInfo : TraitInfo
{
[ActorReference]
[FieldLoader.Require]
public readonly string Proxy = null;
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when technology gets stolen.")]
public readonly string InfiltratedNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the victim will see when technology gets stolen.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
}
sealed class InfiltrateForSupportPower : INotifyInfiltrated
{
readonly InfiltrateForSupportPowerInfo info;
public InfiltrateForSupportPower(InfiltrateForSupportPowerInfo info)
{
this.info = info;
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(self.Owner, info.InfiltratedTextNotification);
TextNotificationsManager.AddTransientLine(infiltrator.Owner, info.InfiltrationTextNotification);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy,
[
new OwnerInit(infiltrator.Owner)
]));
}
}
}

View File

@@ -0,0 +1,77 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
sealed class InfiltrateForSupportPowerResetInfo : TraitInfo
{
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[FluentReference(optional: true)]
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[FluentReference(optional: true)]
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForSupportPowerReset(this); }
}
sealed class InfiltrateForSupportPowerReset : INotifyInfiltrated
{
readonly InfiltrateForSupportPowerResetInfo info;
public InfiltrateForSupportPowerReset(InfiltrateForSupportPowerResetInfo info)
{
this.info = info;
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(self.Owner, info.InfiltratedTextNotification);
TextNotificationsManager.AddTransientLine(infiltrator.Owner, info.InfiltrationTextNotification);
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
var manager = self.Owner.PlayerActor.Trait<SupportPowerManager>();
var powers = manager.GetPowersForActor(self).Where(sp => !sp.Disabled);
foreach (var power in powers)
power.ResetTimer();
}
}
}

View File

@@ -0,0 +1,72 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
[Desc("Transform into a different actor type.")]
sealed class InfiltrateForTransformInfo : TraitInfo
{
[ActorReference]
[FieldLoader.Require]
public readonly string IntoActor = null;
public readonly int ForceHealthPercentage = 0;
public readonly bool SkipMakeAnims = true;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
public override object Create(ActorInitializer init) { return new InfiltrateForTransform(init, this); }
}
sealed class InfiltrateForTransform : INotifyInfiltrated
{
readonly InfiltrateForTransformInfo info;
readonly string faction;
public InfiltrateForTransform(ActorInitializer init, InfiltrateForTransformInfo info)
{
this.info = info;
faction = init.GetValue<FactionInit, string>(init.Self.Owner.Faction.InternalName);
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, BitSet<TargetableType> types)
{
if (!info.Types.Overlaps(types))
return;
var transform = new Transform(info.IntoActor)
{
ForceHealthPercentage = info.ForceHealthPercentage,
Faction = faction,
SkipMakeAnims = info.SkipMakeAnims
};
var facing = self.TraitOrDefault<IFacing>();
if (facing != null)
transform.Facing = facing.Facing;
infiltrator.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(info.PlayerExperience);
self.QueueActivity(false, transform);
}
}
}

View File

@@ -0,0 +1,156 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.Mods.Cnc.Activities;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Orders;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
public class InfiltratesInfo : ConditionalTraitInfo
{
[Desc("The `TargetTypes` from `Targetable` that are allowed to enter.")]
public readonly BitSet<TargetableType> Types = default;
[VoiceReference]
public readonly string Voice = "Action";
[Desc("Color to use for the target line.")]
public readonly Color TargetLineColor = Color.Crimson;
[Desc("Player relationships the owner of the infiltration target needs.")]
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
[Desc("Behaviour when entering the target.",
"Possible values are Exit, Suicide, Dispose.")]
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Dispose;
[NotificationReference("Speech")]
[Desc("Notification to play when a target is infiltrated.")]
public readonly string Notification = null;
[FluentReference(optional: true)]
[Desc("Text notification to display when a target is infiltrated.")]
public readonly string TextNotification = null;
[CursorReference]
[Desc("Cursor to display when able to infiltrate the target actor.")]
public readonly string EnterCursor = "enter";
public override object Create(ActorInitializer init) { return new Infiltrates(this); }
}
public class Infiltrates : ConditionalTrait<InfiltratesInfo>, IIssueOrder, IResolveOrder, IOrderVoice
{
public Infiltrates(InfiltratesInfo info)
: base(info) { }
public IEnumerable<IOrderTargeter> Orders
{
get
{
if (IsTraitDisabled)
yield break;
yield return new InfiltrationOrderTargeter(Info);
}
}
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
{
if (order.OrderID != "Infiltrate")
return null;
return new Order(order.OrderID, self, target, queued);
}
bool IsValidOrder(Order order)
{
if (IsTraitDisabled)
return false;
var targetTypes = default(BitSet<TargetableType>);
if (order.Target.Type == TargetType.FrozenActor)
targetTypes = order.Target.FrozenActor.TargetTypes;
if (order.Target.Type == TargetType.Actor)
targetTypes = order.Target.Actor.GetEnabledTargetTypes();
return Info.Types.Overlaps(targetTypes);
}
public string VoicePhraseForOrder(Actor self, Order order)
{
return order.OrderString == "Infiltrate" && IsValidOrder(order)
? Info.Voice : null;
}
public bool CanInfiltrateTarget(Actor self, in Target target)
{
switch (target.Type)
{
case TargetType.Actor:
return Info.Types.Overlaps(target.Actor.GetEnabledTargetTypes()) &&
Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(target.Actor.Owner));
case TargetType.FrozenActor:
return target.FrozenActor.IsValid && Info.Types.Overlaps(target.FrozenActor.TargetTypes) &&
Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(target.FrozenActor.Owner));
default:
return false;
}
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString != "Infiltrate" || !IsValidOrder(order) || IsTraitDisabled)
return;
if (!CanInfiltrateTarget(self, order.Target))
return;
self.QueueActivity(order.Queued, new Infiltrate(self, order.Target, this, Info.TargetLineColor));
self.ShowTargetLines();
}
}
sealed class InfiltrationOrderTargeter : UnitOrderTargeter
{
readonly InfiltratesInfo info;
public InfiltrationOrderTargeter(InfiltratesInfo info)
: base("Infiltrate", 7, info.EnterCursor, true, true)
{
this.info = info;
}
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
var stance = self.Owner.RelationshipWith(target.Owner);
if (!info.ValidRelationships.HasRelationship(stance))
return false;
return info.Types.Overlaps(target.GetAllTargetTypes());
}
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{
var stance = self.Owner.RelationshipWith(target.Owner);
if (!info.ValidRelationships.HasRelationship(stance))
return false;
return info.Types.Overlaps(target.Info.GetAllTargetTypes());
}
}
}