Browse Source

Add `FindActorInstance()` method to UnrealAPI

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
3133b17068
  1. 1
      docs/API/unreal.md
  2. 22
      sources/Unreal/UnrealAPI.uc

1
docs/API/unreal.md

@ -49,6 +49,7 @@ any regular `Service`:
|`GetKFGameRI()` | Returns current game's `GameReplicationInfo` as `KFGameReplicationInfo`. | |`GetKFGameRI()` | Returns current game's `GameReplicationInfo` as `KFGameReplicationInfo`. |
|`GetGameType()` | Returns current game's `GameInfo`. | |`GetGameType()` | Returns current game's `GameInfo`. |
|`GetKFGameType()` | Returns current game's `GameInfo` as `KFGameType`. | |`GetKFGameType()` | Returns current game's `GameInfo` as `KFGameType`. |
|`FindActorInstance(class<Actor>)` | Searches all `Actor`s on the level for an instance of specific class and returns it. |
|`GetLocalPlayer()` | Returns current local player's `Controller`. | |`GetLocalPlayer()` | Returns current local player's `Controller`. |
|`GetInventoryFrom(class<Inventory>, Inventory, optional bool)` | Convenience method for finding a first inventory entry of the given class in the given inventory chain. | |`GetInventoryFrom(class<Inventory>, Inventory, optional bool)` | Convenience method for finding a first inventory entry of the given class in the given inventory chain. |
|`GetAllInventoryFrom(class<Inventory>, Inventory, optional bool)` | Convenience method for finding a all inventory entries of the given class in the given inventory chain. | |`GetAllInventoryFrom(class<Inventory>, Inventory, optional bool)` | Convenience method for finding a all inventory entries of the given class in the given inventory chain. |

22
sources/Unreal/UnrealAPI.uc

@ -164,6 +164,28 @@ public final function KFGameType GetKFGameType()
return KFGameType(GetGameType()); return KFGameType(GetGameType());
} }
/**
* Searches all `Actor`s on the level for an instance of specific class and
* returns it.
*
* @param classToFind Class we want to find an instance of.
* @result A pre-existing instance of class `classToFind`, `none` if
* no instances exist at the moment of this method's call.
*/
public final function Actor FindActorInstance(class<Actor> classToFind)
{
local Actor result;
local Service service;
service = class'CoreService'.static.Require();
foreach service.AllActors(classToFind, result)
{
if (result != none) {
break;
}
}
return result;
}
/** /**
* Returns current local player's `Controller`. Useful because `level` * Returns current local player's `Controller`. Useful because `level`
* is not accessible inside objects. * is not accessible inside objects.

Loading…
Cancel
Save