Document Player API
This commit is contained in:
parent
211c9c9c31
commit
5168bfbad7
1 changed files with 65 additions and 2 deletions
|
@ -7,11 +7,19 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI
|
namespace GamecraftModdingAPI
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An in-game player character. Any Leo you see is a player.
|
||||||
|
/// </summary>
|
||||||
public class Player
|
public class Player
|
||||||
{
|
{
|
||||||
// static functionality
|
// static functionality
|
||||||
private static PlayerEngine playerEngine = new PlayerEngine();
|
private static PlayerEngine playerEngine = new PlayerEngine();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the specified player exists.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether the player exists.</returns>
|
||||||
|
/// <param name="player">Player type.</param>
|
||||||
public static bool Exists(PlayerType player)
|
public static bool Exists(PlayerType player)
|
||||||
{
|
{
|
||||||
switch (player)
|
switch (player)
|
||||||
|
@ -24,11 +32,20 @@ namespace GamecraftModdingAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the specified player exists.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether the player exists.</returns>
|
||||||
|
/// <param name="player">The player's unique identifier.</param>
|
||||||
public static bool Exists(uint player)
|
public static bool Exists(uint player)
|
||||||
{
|
{
|
||||||
return playerEngine.ExistsById(player);
|
return playerEngine.ExistsById(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="T:GamecraftModdingAPI.Player"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The player's unique identifier.</param>
|
||||||
public Player(uint id)
|
public Player(uint id)
|
||||||
{
|
{
|
||||||
this.Id = id;
|
this.Id = id;
|
||||||
|
@ -39,6 +56,10 @@ namespace GamecraftModdingAPI
|
||||||
this.Type = playerEngine.GetLocalPlayer() == id ? PlayerType.Local : PlayerType.Remote;
|
this.Type = playerEngine.GetLocalPlayer() == id ? PlayerType.Local : PlayerType.Remote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="T:GamecraftModdingAPI.Player"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="player">The player type. Chooses the first available player matching the criteria.</param>
|
||||||
public Player(PlayerType player)
|
public Player(PlayerType player)
|
||||||
{
|
{
|
||||||
uint localId = playerEngine.GetLocalPlayer();
|
uint localId = playerEngine.GetLocalPlayer();
|
||||||
|
@ -60,10 +81,23 @@ namespace GamecraftModdingAPI
|
||||||
|
|
||||||
// object fields & properties
|
// object fields & properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's type.
|
||||||
|
/// The player type is always relative to the current client, not the game host.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The enumerated player type.</value>
|
||||||
public PlayerType Type { get; }
|
public PlayerType Type { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's unique identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The identifier.</value>
|
||||||
public uint Id { get; private set; }
|
public uint Id { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's current position.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The position.</value>
|
||||||
public float3 Position
|
public float3 Position
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -77,6 +111,10 @@ namespace GamecraftModdingAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's current rotation.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The rotation.</value>
|
||||||
public quaternion Rotation
|
public quaternion Rotation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -90,6 +128,10 @@ namespace GamecraftModdingAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's current velocity.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The velocity.</value>
|
||||||
public float3 Velocity
|
public float3 Velocity
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -103,6 +145,10 @@ namespace GamecraftModdingAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's current angular velocity.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The angular velocity.</value>
|
||||||
public float3 AngularVelocity
|
public float3 AngularVelocity
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -116,6 +162,10 @@ namespace GamecraftModdingAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's mass.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The mass.</value>
|
||||||
public float Mass
|
public float Mass
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -123,14 +173,19 @@ namespace GamecraftModdingAPI
|
||||||
return 1f / playerEngine.GetMass(Id).InverseMass;
|
return 1f / playerEngine.GetMass(Id).InverseMass;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
// FIXME: Setting mass doesn't do anything
|
||||||
|
/*set
|
||||||
{
|
{
|
||||||
playerEngine.SetInverseMass(Id, 1f / value);
|
playerEngine.SetInverseMass(Id, 1f / value);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private float _ping = -1f;
|
private float _ping = -1f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The player's latest network ping time.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The ping (s).</value>
|
||||||
public float Ping
|
public float Ping
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -146,6 +201,14 @@ namespace GamecraftModdingAPI
|
||||||
|
|
||||||
// object methods
|
// object methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Teleport the player to the specified coordinates.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">The x coordinate.</param>
|
||||||
|
/// <param name="y">The y coordinate.</param>
|
||||||
|
/// <param name="z">The z coordinate.</param>
|
||||||
|
/// <param name="relative">If set to <c>true</c> teleport relative to the player's current position.</param>
|
||||||
|
/// <param name="exitSeat">If set to <c>true</c> exit any seat the player is in.</param>
|
||||||
public void Teleport(float x, float y, float z, bool relative = true, bool exitSeat = true)
|
public void Teleport(float x, float y, float z, bool relative = true, bool exitSeat = true)
|
||||||
{
|
{
|
||||||
float3 location = new float3(x, y, z);
|
float3 location = new float3(x, y, z);
|
||||||
|
|
Loading…
Reference in a new issue