Uncloak during resupply when "UncloakOn: Dock" is defined

This commit is contained in:
abcdefg30
2020-05-18 17:19:27 +02:00
committed by teinarss
parent dbe824d4e5
commit dd99fc93e4
3 changed files with 33 additions and 2 deletions

View File

@@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
readonly RepairableNear repairableNear;
readonly Rearmable rearmable;
readonly INotifyResupply[] notifyResupplies;
readonly INotifyBeingResupplied[] notifyBeingResupplied;
readonly ICallForTransport[] transportCallers;
readonly IMove move;
readonly Aircraft aircraft;
@@ -53,6 +54,7 @@ namespace OpenRA.Mods.Common.Activities
repairableNear = self.TraitOrDefault<RepairableNear>();
rearmable = self.TraitOrDefault<Rearmable>();
notifyResupplies = host.TraitsImplementing<INotifyResupply>().ToArray();
notifyBeingResupplied = self.TraitsImplementing<INotifyBeingResupplied>().ToArray();
transportCallers = self.TraitsImplementing<ICallForTransport>().ToArray();
move = self.Trait<IMove>();
aircraft = move as Aircraft;
@@ -149,6 +151,9 @@ namespace OpenRA.Mods.Common.Activities
actualResupplyStarted = true;
foreach (var notifyResupply in notifyResupplies)
notifyResupply.BeforeResupply(host.Actor, self, activeResupplyTypes);
foreach (var br in notifyBeingResupplied)
br.StartingResupply(self, host.Actor);
}
if (activeResupplyTypes.HasFlag(ResupplyType.Repair))
@@ -237,6 +242,9 @@ namespace OpenRA.Mods.Common.Activities
else if (repairableNear == null && !(self.CurrentActivity.NextActivity is Move))
QueueChild(move.MoveToTarget(self, host));
}
foreach (var br in notifyBeingResupplied)
br.StoppingResupply(self, isHostInvalid ? null : host.Actor);
}
void RepairTick(Actor self)

View File

@@ -45,7 +45,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Measured in game ticks.")]
public readonly int CloakDelay = 30;
[Desc("Events leading to the actor getting uncloaked. Possible values are: Attack, Move, Unload, Infiltrate, Demolish, Dock, Damage, Heal and SelfHeal.")]
[Desc("Events leading to the actor getting uncloaked. Possible values are: Attack, Move, Unload, Infiltrate, Demolish, Dock, Damage, Heal and SelfHeal.",
"'Dock' is triggered when docking to a refinery or resupplying.")]
public readonly UncloakType UncloakOn = UncloakType.Attack
| UncloakType.Unload | UncloakType.Infiltrate | UncloakType.Demolish | UncloakType.Dock;
@@ -66,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
}
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction, INotifyBeingResupplied
{
[Sync]
int remainingTime;
@@ -246,5 +247,20 @@ namespace OpenRA.Mods.Common.Traits
if (Info.UncloakOn.HasFlag(UncloakType.Infiltrate))
Uncloak();
}
void INotifyBeingResupplied.StartingResupply(Actor self, Actor host)
{
if (Info.UncloakOn.HasFlag(UncloakType.Dock))
{
isDocking = true;
Uncloak();
}
}
void INotifyBeingResupplied.StoppingResupply(Actor self, Actor host)
{
if (Info.UncloakOn.HasFlag(UncloakType.Dock))
isDocking = false;
}
}
}

View File

@@ -131,6 +131,13 @@ namespace OpenRA.Mods.Common.Traits
void ResupplyTick(Actor host, Actor target, ResupplyType types);
}
[RequireExplicitImplementation]
public interface INotifyBeingResupplied
{
void StartingResupply(Actor self, Actor host);
void StoppingResupply(Actor self, Actor host);
}
[RequireExplicitImplementation]
public interface INotifyPowerLevelChanged { void PowerLevelChanged(Actor self); }
public interface INotifySupportPower { void Charged(Actor self); void Activated(Actor self); }