Uncloak during resupply when "UncloakOn: Dock" is defined
This commit is contained in:
@@ -29,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly RepairableNear repairableNear;
|
readonly RepairableNear repairableNear;
|
||||||
readonly Rearmable rearmable;
|
readonly Rearmable rearmable;
|
||||||
readonly INotifyResupply[] notifyResupplies;
|
readonly INotifyResupply[] notifyResupplies;
|
||||||
|
readonly INotifyBeingResupplied[] notifyBeingResupplied;
|
||||||
readonly ICallForTransport[] transportCallers;
|
readonly ICallForTransport[] transportCallers;
|
||||||
readonly IMove move;
|
readonly IMove move;
|
||||||
readonly Aircraft aircraft;
|
readonly Aircraft aircraft;
|
||||||
@@ -53,6 +54,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
repairableNear = self.TraitOrDefault<RepairableNear>();
|
repairableNear = self.TraitOrDefault<RepairableNear>();
|
||||||
rearmable = self.TraitOrDefault<Rearmable>();
|
rearmable = self.TraitOrDefault<Rearmable>();
|
||||||
notifyResupplies = host.TraitsImplementing<INotifyResupply>().ToArray();
|
notifyResupplies = host.TraitsImplementing<INotifyResupply>().ToArray();
|
||||||
|
notifyBeingResupplied = self.TraitsImplementing<INotifyBeingResupplied>().ToArray();
|
||||||
transportCallers = self.TraitsImplementing<ICallForTransport>().ToArray();
|
transportCallers = self.TraitsImplementing<ICallForTransport>().ToArray();
|
||||||
move = self.Trait<IMove>();
|
move = self.Trait<IMove>();
|
||||||
aircraft = move as Aircraft;
|
aircraft = move as Aircraft;
|
||||||
@@ -149,6 +151,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
actualResupplyStarted = true;
|
actualResupplyStarted = true;
|
||||||
foreach (var notifyResupply in notifyResupplies)
|
foreach (var notifyResupply in notifyResupplies)
|
||||||
notifyResupply.BeforeResupply(host.Actor, self, activeResupplyTypes);
|
notifyResupply.BeforeResupply(host.Actor, self, activeResupplyTypes);
|
||||||
|
|
||||||
|
foreach (var br in notifyBeingResupplied)
|
||||||
|
br.StartingResupply(self, host.Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeResupplyTypes.HasFlag(ResupplyType.Repair))
|
if (activeResupplyTypes.HasFlag(ResupplyType.Repair))
|
||||||
@@ -237,6 +242,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
else if (repairableNear == null && !(self.CurrentActivity.NextActivity is Move))
|
else if (repairableNear == null && !(self.CurrentActivity.NextActivity is Move))
|
||||||
QueueChild(move.MoveToTarget(self, host));
|
QueueChild(move.MoveToTarget(self, host));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var br in notifyBeingResupplied)
|
||||||
|
br.StoppingResupply(self, isHostInvalid ? null : host.Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepairTick(Actor self)
|
void RepairTick(Actor self)
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Measured in game ticks.")]
|
[Desc("Measured in game ticks.")]
|
||||||
public readonly int CloakDelay = 30;
|
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
|
public readonly UncloakType UncloakOn = UncloakType.Attack
|
||||||
| UncloakType.Unload | UncloakType.Infiltrate | UncloakType.Demolish | UncloakType.Dock;
|
| 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,
|
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
|
||||||
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction
|
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction, INotifyBeingResupplied
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
int remainingTime;
|
int remainingTime;
|
||||||
@@ -246,5 +247,20 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (Info.UncloakOn.HasFlag(UncloakType.Infiltrate))
|
if (Info.UncloakOn.HasFlag(UncloakType.Infiltrate))
|
||||||
Uncloak();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void ResupplyTick(Actor host, Actor target, ResupplyType types);
|
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]
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyPowerLevelChanged { void PowerLevelChanged(Actor self); }
|
public interface INotifyPowerLevelChanged { void PowerLevelChanged(Actor self); }
|
||||||
public interface INotifySupportPower { void Charged(Actor self); void Activated(Actor self); }
|
public interface INotifySupportPower { void Charged(Actor self); void Activated(Actor self); }
|
||||||
|
|||||||
Reference in New Issue
Block a user