From e7372c8b6d774100e12c68db577053ab24e41fde Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 12 Sep 2022 02:27:15 +0700 Subject: [PATCH] Add `FindInstance()` method for `MutatorAPI` --- .../Unreal/MutatorAPI/KF1_MutatorAPI.uc | 20 +++++++++++++++++++ .../API/Unreal/MutatorsAPI/MutatorAPI.uc | 12 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/sources/KFRealm/Server/Unreal/MutatorAPI/KF1_MutatorAPI.uc b/sources/KFRealm/Server/Unreal/MutatorAPI/KF1_MutatorAPI.uc index 43c5da1..72d9dcf 100644 --- a/sources/KFRealm/Server/Unreal/MutatorAPI/KF1_MutatorAPI.uc +++ b/sources/KFRealm/Server/Unreal/MutatorAPI/KF1_MutatorAPI.uc @@ -55,6 +55,26 @@ public function Mutator_OnModifyLogin_Slot OnModifyLogin( return Mutator_OnModifyLogin_Slot(signal.NewSlot(receiver)); } +public function Mutator FindInstance(class mutatorClass) +{ + local GameInfo gameInfo; + local Mutator result; + + gameInfo = _server.unreal.GetGameType(); + if (gameInfo == none) { + return none; + } + result = gameInfo.baseMutator; + while (result != none) + { + if (result.class == mutatorClass) { + return result; + } + result = result.nextMutator; + } + return none; +} + defaultproperties { } \ No newline at end of file diff --git a/sources/ServerRealm/API/Unreal/MutatorsAPI/MutatorAPI.uc b/sources/ServerRealm/API/Unreal/MutatorsAPI/MutatorAPI.uc index 02303a4..8328feb 100644 --- a/sources/ServerRealm/API/Unreal/MutatorsAPI/MutatorAPI.uc +++ b/sources/ServerRealm/API/Unreal/MutatorsAPI/MutatorAPI.uc @@ -91,6 +91,18 @@ public function Mutator_OnMutate_Slot OnMutate(AcediaObject receiver); /* SIGNAL */ public function Mutator_OnModifyLogin_Slot OnModifyLogin(AcediaObject receiver); +/** + * Method for finding a `Mutator` instance of a given class. + * Note only once instance of `Mutator` class is supposed to be created. + * + * @param mutatorClass Class of the `Mutator`, which instance method should + * find. + * @return Instance of `Mutator` of the given class. Guaranteed to be of class + * `mutatorClass`. `none` iff there is no such instance added into + * the game. + */ +public function Mutator FindInstance(class mutatorClass); + defaultproperties { } \ No newline at end of file