From 659ec5e33562559be75f9b427eeff60c6dcd0efb Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:18:13 +0300 Subject: [PATCH] Make phase transport uncloak on loading cargo --- OpenRA.Mods.Cnc/Traits/Disguise.cs | 19 ++++++++----- .../Activities/RideTransport.cs | 3 +++ OpenRA.Mods.Common/Activities/UnloadCargo.cs | 4 +-- OpenRA.Mods.Common/Traits/Cloak.cs | 27 ++++++++++++------- OpenRA.Mods.Common/TraitsInterfaces.cs | 8 +++++- mods/ra/rules/vehicles.yaml | 2 +- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/Disguise.cs b/OpenRA.Mods.Cnc/Traits/Disguise.cs index eed1c0e603..3649c62c6b 100644 --- a/OpenRA.Mods.Cnc/Traits/Disguise.cs +++ b/OpenRA.Mods.Cnc/Traits/Disguise.cs @@ -57,10 +57,11 @@ namespace OpenRA.Mods.Cnc.Traits None = 0, Attack = 1, Damaged = 2, - Unload = 4, - Infiltrate = 8, - Demolish = 16, - Move = 32 + Load = 4, + Unload = 8, + Infiltrate = 16, + Demolish = 32, + Move = 64, } [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, - INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration, ITick + INotifyDamage, INotifyLoadCargo, INotifyUnloadCargo, INotifyDemolition, INotifyInfiltration, ITick { public ActorInfo AsActor { get; private set; } public Player AsPlayer { get; private set; } @@ -253,7 +254,13 @@ namespace OpenRA.Mods.Cnc.Traits 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)) DisguiseAs(null); diff --git a/OpenRA.Mods.Common/Activities/RideTransport.cs b/OpenRA.Mods.Common/Activities/RideTransport.cs index 1bf6ec2fff..d9ae9d1c7f 100644 --- a/OpenRA.Mods.Common/Activities/RideTransport.cs +++ b/OpenRA.Mods.Common/Activities/RideTransport.cs @@ -64,6 +64,9 @@ namespace OpenRA.Mods.Common.Activities if (!enterCargo.CanLoad(self)) return; + foreach (var inl in targetActor.TraitsImplementing()) + inl.Loading(self); + enterCargo.Load(enterActor, self); w.Remove(self); }); diff --git a/OpenRA.Mods.Common/Activities/UnloadCargo.cs b/OpenRA.Mods.Common/Activities/UnloadCargo.cs index feadf52a26..14308d2ae6 100644 --- a/OpenRA.Mods.Common/Activities/UnloadCargo.cs +++ b/OpenRA.Mods.Common/Activities/UnloadCargo.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities { readonly Actor self; readonly Cargo cargo; - readonly INotifyUnload[] notifiers; + readonly INotifyUnloadCargo[] notifiers; readonly bool unloadAll; readonly Aircraft aircraft; readonly Mobile mobile; @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Activities { this.self = self; cargo = self.Trait(); - notifiers = self.TraitsImplementing().ToArray(); + notifiers = self.TraitsImplementing().ToArray(); this.unloadAll = unloadAll; aircraft = self.TraitOrDefault(); mobile = self.TraitOrDefault(); diff --git a/OpenRA.Mods.Common/Traits/Cloak.cs b/OpenRA.Mods.Common/Traits/Cloak.cs index 1567b1e7f6..b1eb988ca1 100644 --- a/OpenRA.Mods.Common/Traits/Cloak.cs +++ b/OpenRA.Mods.Common/Traits/Cloak.cs @@ -25,14 +25,15 @@ namespace OpenRA.Mods.Common.Traits None = 0, Attack = 1, Move = 2, - Unload = 4, - Infiltrate = 8, - Demolish = 16, - Damage = 32, - Heal = 64, - SelfHeal = 128, - Dock = 256, - SupportPower = 512, + Load = 4, + Unload = 8, + Infiltrate = 16, + Demolish = 32, + Damage = 64, + Heal = 128, + SelfHeal = 256, + Dock = 512, + SupportPower = 1024, } // Type tag for DetectionTypes @@ -93,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new Cloak(this); } } - public class Cloak : PausableConditionalTrait, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration, + public class Cloak : PausableConditionalTrait, IRenderModifier, INotifyDamage, INotifyUnloadCargo, INotifyLoadCargo, INotifyDemolition, INotifyInfiltration, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyDockClient, INotifySupportPower { [Sync] @@ -287,7 +288,13 @@ namespace OpenRA.Mods.Common.Traits 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)) Uncloak(); diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 95641c303d..af39012be5 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -207,7 +207,13 @@ namespace OpenRA.Mods.Common.Traits } [RequireExplicitImplementation] - public interface INotifyUnload + public interface INotifyLoadCargo + { + void Loading(Actor self); + } + + [RequireExplicitImplementation] + public interface INotifyUnloadCargo { void Unloading(Actor self); } diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index b9f1d0d135..bb43ebad6f 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -922,7 +922,7 @@ STNK: UncloakSound: appear1.aud IsPlayerPalette: true PauseOnCondition: cloak-force-disabled - UncloakOn: Attack, Unload, Heal, Dock + UncloakOn: Attack, Load, Unload, Heal, Dock GrantConditionOnDamageState@UNCLOAK: Condition: cloak-force-disabled ValidDamageStates: Critical