Make phase transport uncloak on loading cargo

This commit is contained in:
Gustas
2023-07-10 15:18:13 +03:00
committed by Matthias Mailänder
parent 7f37454666
commit 659ec5e335
6 changed files with 43 additions and 20 deletions

View File

@@ -57,10 +57,11 @@ namespace OpenRA.Mods.Cnc.Traits
None = 0, None = 0,
Attack = 1, Attack = 1,
Damaged = 2, Damaged = 2,
Unload = 4, Load = 4,
Infiltrate = 8, Unload = 8,
Demolish = 16, Infiltrate = 16,
Move = 32 Demolish = 32,
Move = 64,
} }
[Desc("Provides access to the disguise command, which makes the actor appear to be another player's actor.")] [Desc("Provides access to the disguise command, which makes the actor appear to be another player's actor.")]
@@ -99,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Traits
} }
sealed class Disguise : IEffectiveOwner, IIssueOrder, IResolveOrder, IOrderVoice, IRadarColorModifier, INotifyAttack, sealed class Disguise : IEffectiveOwner, IIssueOrder, IResolveOrder, IOrderVoice, IRadarColorModifier, INotifyAttack,
INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration, ITick INotifyDamage, INotifyLoadCargo, INotifyUnloadCargo, INotifyDemolition, INotifyInfiltration, ITick
{ {
public ActorInfo AsActor { get; private set; } public ActorInfo AsActor { get; private set; }
public Player AsPlayer { get; private set; } public Player AsPlayer { get; private set; }
@@ -253,7 +254,13 @@ namespace OpenRA.Mods.Cnc.Traits
DisguiseAs(null); DisguiseAs(null);
} }
void INotifyUnload.Unloading(Actor self) void INotifyLoadCargo.Loading(Actor self)
{
if (info.RevealDisguiseOn.HasFlag(RevealDisguiseType.Load))
DisguiseAs(null);
}
void INotifyUnloadCargo.Unloading(Actor self)
{ {
if (info.RevealDisguiseOn.HasFlag(RevealDisguiseType.Unload)) if (info.RevealDisguiseOn.HasFlag(RevealDisguiseType.Unload))
DisguiseAs(null); DisguiseAs(null);

View File

@@ -64,6 +64,9 @@ namespace OpenRA.Mods.Common.Activities
if (!enterCargo.CanLoad(self)) if (!enterCargo.CanLoad(self))
return; return;
foreach (var inl in targetActor.TraitsImplementing<INotifyLoadCargo>())
inl.Loading(self);
enterCargo.Load(enterActor, self); enterCargo.Load(enterActor, self);
w.Remove(self); w.Remove(self);
}); });

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly Actor self; readonly Actor self;
readonly Cargo cargo; readonly Cargo cargo;
readonly INotifyUnload[] notifiers; readonly INotifyUnloadCargo[] notifiers;
readonly bool unloadAll; readonly bool unloadAll;
readonly Aircraft aircraft; readonly Aircraft aircraft;
readonly Mobile mobile; readonly Mobile mobile;
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
this.self = self; this.self = self;
cargo = self.Trait<Cargo>(); cargo = self.Trait<Cargo>();
notifiers = self.TraitsImplementing<INotifyUnload>().ToArray(); notifiers = self.TraitsImplementing<INotifyUnloadCargo>().ToArray();
this.unloadAll = unloadAll; this.unloadAll = unloadAll;
aircraft = self.TraitOrDefault<Aircraft>(); aircraft = self.TraitOrDefault<Aircraft>();
mobile = self.TraitOrDefault<Mobile>(); mobile = self.TraitOrDefault<Mobile>();

View File

@@ -25,14 +25,15 @@ namespace OpenRA.Mods.Common.Traits
None = 0, None = 0,
Attack = 1, Attack = 1,
Move = 2, Move = 2,
Unload = 4, Load = 4,
Infiltrate = 8, Unload = 8,
Demolish = 16, Infiltrate = 16,
Damage = 32, Demolish = 32,
Heal = 64, Damage = 64,
SelfHeal = 128, Heal = 128,
Dock = 256, SelfHeal = 256,
SupportPower = 512, Dock = 512,
SupportPower = 1024,
} }
// Type tag for DetectionTypes // Type tag for DetectionTypes
@@ -93,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Cloak(this); } public override object Create(ActorInitializer init) { return new Cloak(this); }
} }
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration, public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnloadCargo, INotifyLoadCargo, INotifyDemolition, INotifyInfiltration,
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyDockClient, INotifySupportPower INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyDockClient, INotifySupportPower
{ {
[Sync] [Sync]
@@ -287,7 +288,13 @@ namespace OpenRA.Mods.Common.Traits
isDocking = false; isDocking = false;
} }
void INotifyUnload.Unloading(Actor self) void INotifyLoadCargo.Loading(Actor self)
{
if (Info.UncloakOn.HasFlag(UncloakType.Load))
Uncloak();
}
void INotifyUnloadCargo.Unloading(Actor self)
{ {
if (Info.UncloakOn.HasFlag(UncloakType.Unload)) if (Info.UncloakOn.HasFlag(UncloakType.Unload))
Uncloak(); Uncloak();

View File

@@ -207,7 +207,13 @@ namespace OpenRA.Mods.Common.Traits
} }
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifyUnload public interface INotifyLoadCargo
{
void Loading(Actor self);
}
[RequireExplicitImplementation]
public interface INotifyUnloadCargo
{ {
void Unloading(Actor self); void Unloading(Actor self);
} }

View File

@@ -922,7 +922,7 @@ STNK:
UncloakSound: appear1.aud UncloakSound: appear1.aud
IsPlayerPalette: true IsPlayerPalette: true
PauseOnCondition: cloak-force-disabled PauseOnCondition: cloak-force-disabled
UncloakOn: Attack, Unload, Heal, Dock UncloakOn: Attack, Load, Unload, Heal, Dock
GrantConditionOnDamageState@UNCLOAK: GrantConditionOnDamageState@UNCLOAK:
Condition: cloak-force-disabled Condition: cloak-force-disabled
ValidDamageStates: Critical ValidDamageStates: Critical