Browse Source

Add `GetPlayer()` method to `EPawn`

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
7c3ce109b4
  1. 8
      sources/Gameplay/BaseClasses/Frontend/EPawn.uc
  2. 13
      sources/Gameplay/KF1Frontend/BaseImplementation/EKFPawn.uc

8
sources/Gameplay/BaseClasses/Frontend/EPawn.uc

@ -23,6 +23,14 @@
class EPawn extends EPlaceable
abstract;
/**
* If caller pawn is controlled by a player, this method returns that player.
*
* @return Player that controls caller pawn. `none` iff caller pawn is not
* controlled by a player.
*/
public function EPlayer GetPlayer();
/**
* Returns current amount of health caller `EPawn`'s referred entity has,
* assuming that entity has a health component.

13
sources/Gameplay/KF1Frontend/BaseImplementation/EKFPawn.uc

@ -117,6 +117,19 @@ public function Vector GetLocation()
return Vect(0.0, 0.0, 0.0);
}
public function EPlayer GetPlayer()
{
local Pawn pawnInstance;
pawnInstance = GetNativeInstance();
if (pawnInstance != none)
{
return _.players.FromController(
PlayerController(pawnInstance.controller));
}
return none;
}
public function int GetHealth()
{
local Pawn pawnInstance;

Loading…
Cancel
Save