Class Player
- Namespace
- AO
- Assembly
- CoreAssembly.dll
The Player component. You may extend this class to add your own functionality to the player.
public class Player : Component
- Inheritance
-
Player
- Inherited Members
- Extension Methods
Examples
public class MyPlayer : Player
{
public override void Awake() {}
public override void Update() {}
}
Fields
AbilityInstances
public List<Ability> AbilityInstances
Field Value
Agent
public Movement_Agent Agent
Field Value
BlockEmoteReasons
public List<string> BlockEmoteReasons
Field Value
CurrentTargettingAbility
public Ability CurrentTargettingAbility
Field Value
CurrentTargettingAbilityIndex
public int CurrentTargettingAbilityIndex
Field Value
CurrentTargettingCurrentlySelections
public List<Player> CurrentTargettingCurrentlySelections
Field Value
CurrentTargettingDirection
public Vector2 CurrentTargettingDirection
Field Value
CurrentTargettingMagnitude
public float CurrentTargettingMagnitude
Field Value
DefaultInventory
public Inventory DefaultInventory
Field Value
Effects
public List<AEffect> Effects
Field Value
FootstepOverride
public string[] FootstepOverride
Field Value
- string[]
FrameEventWriter
public StreamWriter FrameEventWriter
Field Value
MaxAbilitiesInDefaultUI
public const int MaxAbilitiesInDefaultUI = 6
Field Value
TargettingEffect
public AEffect TargettingEffect
Field Value
Properties
ActiveEffect
The current ActiveEffect on the player, if any. There may only be one active effect on a player, adding another will cancel the existing one.
public AEffect ActiveEffect { get; }
Property Value
ColorIndex
public CrewchsiaColor ColorIndex { get; }
Property Value
DisableDirectionalFlipping
Override this if you would like to disable the directional flipping of the player
public virtual bool DisableDirectionalFlipping { get; }
Property Value
DoOverrideStateMachineMovingVariable
public bool DoOverrideStateMachineMovingVariable { get; set; }
Property Value
EmoteMenuOpen
public bool EmoteMenuOpen { get; }
Property Value
FinalNameRect
public Rect FinalNameRect { get; set; }
Property Value
FullNameplateRect
public Rect FullNameplateRect { get; set; }
Property Value
HasActiveEffect
public bool HasActiveEffect { get; }
Property Value
InputOverride
public Vector2 InputOverride { get; set; }
Property Value
InputThisFrame
public Vector2 InputThisFrame { get; set; }
Property Value
IsAdmin
public bool IsAdmin { get; }
Property Value
IsLocal
public bool IsLocal { get; set; }
Property Value
IsModerator
public bool IsModerator { get; }
Property Value
IsVIP
public bool IsVIP { get; }
Property Value
IsValidTarget
Checks player effects for any IsValidTarget == false.
public bool IsValidTarget { get; }
Property Value
IsYouTuber
public bool IsYouTuber { get; }
Property Value
LastInputs
public Vector2 LastInputs { get; set; }
Property Value
MovementKind
The movement kind of the player. Override this to change how the player moves. Kinds: Default: WASD movement MoveToMouse: Constantly move towards the mouse
public virtual Player.PlayerMovementKind MovementKind { get; }
Property Value
Name
The name of the player
public string Name { get; }
Property Value
NameOffset
[Obsolete("Use UserNameOffset instead. This will be removed in proto 41.", false)]
public float NameOffset { get; set; }
Property Value
SpineAnimator
The animator of the player. Lovingly referred to as the "Schleem"
public Spine_Animator SpineAnimator { get; }
Property Value
StateMachineMovingVariableValue
public bool StateMachineMovingVariableValue { get; set; }
Property Value
UserId
The user id of the player
public string UserId { get; }
Property Value
UserNameOffset
public float UserNameOffset { get; set; }
Property Value
VolumeForLocalPlayer
public float VolumeForLocalPlayer { get; set; }
Property Value
Methods
ActivateAbility(Type, int)
public bool ActivateAbility(Type abilityType, int abilityIndex)
Parameters
Returns
ActivateAbility<T>(int)
public bool ActivateAbility<T>(int abilityIndex)
Parameters
abilityIndexint
Returns
Type Parameters
T
AddDisableMovementInputReason(string)
Add a reason to disable movement input for the player. The players controls will be disabled if there are one or more reasons.
public void AddDisableMovementInputReason(string reason)
Parameters
reasonstring
AddEffectCommon(Player, Type, float?, Action<AEffect>)
Adds an effect to the player.
public AEffect AddEffectCommon(Player caster, Type effectType, float? duration = null, Action<AEffect> preInit = null)
Parameters
casterPlayer[Optional] The player who cast the effect.
effectTypeTypeThe type of effect to add.
durationfloat?[Optional] The duration of the effect. If null, the effect's default duration will be used, and if that is not set then the effect will be permanent.
preInitAction<AEffect>[Optional] A callback to run before the effect is initialized.
Returns
- AEffect
The added effect.
AddEffectWithNoCeremony(Type)
public AEffect AddEffectWithNoCeremony(Type effectType)
Parameters
effectTypeType
Returns
AddEffect<T>(Player, float?, Action<T>)
Adds an effect to the player. If the effect is an active effect, it will cancel the existing active effect.
public T AddEffect<T>(Player caster = null, float? duration = null, Action<T> preInit = null) where T : AEffect
Parameters
casterPlayer[Optional] The player who cast the effect.
durationfloat?[Optional] The duration of the effect. If null, the effect's default duration will be used, and if that is not set then the effect will be permanent.
preInitAction<T>[Optional] A callback to run before the effect is initialized.
Returns
- T
The added effect.
Type Parameters
TThe type of effect to add.
AddEmoteBlockReason(string)
Add a reason that disallow emoting.
public void AddEmoteBlockReason(string reason)
Parameters
reasonstring
AddFreezeReason(string)
Add a reason to freeze the players movement. The player will not be able to move if there are one or move freeze reasons.
public void AddFreezeReason(string reason)
Parameters
reasonstring
AddInvisibilityReason(string)
Add a reason to make the player invisible. The player will not be visible if there are one or more invisibility reasons.
public void AddInvisibilityReason(string reason)
Parameters
reasonstring
AddJoystickDisableReason(string)
Hides the joystick.
public void AddJoystickDisableReason(string reason)
Parameters
reasonstring
AddNameInvisibilityReason(string)
Add a reason to make the players name invisible. The players name will not be visible if there are one or more name invisibility reasons.
public void AddNameInvisibilityReason(string reason)
Parameters
reasonstring
AddStat(string, long, Texture)
public void AddStat(string name, long startingValue, Texture icon)
Parameters
BeginFrameEvent(int)
public StreamWriterPosition<int> BeginFrameEvent(int evt)
Parameters
evtint
Returns
CalculatePlayerVelocity(Vector2, Vector2, float)
Override this to change how player velocity is calculated. This is called every frame as a Movement_Agent.CustomVelocityCallback and the return value is remembered and taken into account during resimulations (client-side prediction).
public virtual Vector2 CalculatePlayerVelocity(Vector2 currentVelocity, Vector2 input, float deltaTime)
Parameters
Returns
CanUseAbility(Ability)
Returns whether a player is allowed to use an ability. Used in conjunction with Ability.CanUse().
public virtual bool CanUseAbility(Ability ability)
Parameters
abilityAbility
Returns
ClearAllEffects()
Removes all effects from the player, including the active effect.
public void ClearAllEffects()
DefaultPlayerVelocityCalculation(Vector2, Vector2, float, float)
This is the default function used to calculare player velocity. Useful to use if you want to retain default movement in some cases when overriding AO.Player.CalculatePlayerVelocity
public Vector2 DefaultPlayerVelocityCalculation(Vector2 currentVelocity, Vector2 input, float deltaTime, float accelerationMultiplier)
Parameters
Returns
DrawCircleAimingIndicator(Vector2)
public static void DrawCircleAimingIndicator(Vector2 position)
Parameters
positionVector2
DrawDefaultAbilityUI(AbilityDrawOptions)
public Player.AbilityDrawResult DrawDefaultAbilityUI(Player.AbilityDrawOptions opt)
Parameters
Returns
DrawLineAimingIndicator(Vector2)
public void DrawLineAimingIndicator(Vector2 dir)
Parameters
dirVector2
DrawLineAimingIndicator(Vector2, Vector2)
public static void DrawLineAimingIndicator(Vector2 dir, Vector2 worldPosition)
Parameters
DrawMovingArrows(Rect, int, float, float)
public static void DrawMovingArrows(Rect rect, int arrowCount, float fadePercent, float fadeOutEnd)
Parameters
EndFrameEvent(StreamWriterPosition<int>)
public void EndFrameEvent(StreamWriterPosition<int> lengthPosition)
Parameters
lengthPositionStreamWriterPosition<int>
GetAbility(Type)
public Ability GetAbility(Type abilityType)
Parameters
abilityTypeType
Returns
GetAbility<T>()
public T GetAbility<T>() where T : Ability
Returns
- T
Type Parameters
T
GetDisableDirectionalFlipping()
Get the name of the player
public bool GetDisableDirectionalFlipping()
Returns
GetEffect(Type)
public AEffect GetEffect(Type type)
Parameters
typeType
Returns
GetEffect<T>()
Returns the effect of the given type or null if the player does not have an effect of that type.
public T GetEffect<T>() where T : AEffect
Returns
- T
Type Parameters
T
GetFacingDirection()
Gets the direction the player is currently facing. True = Right. False = Left.
public bool GetFacingDirection()
Returns
GetFriends()
public Friend[] GetFriends()
Returns
- Friend[]
GetFriends_Internal(ulong)
public static extern Friend[] GetFriends_Internal(ulong player_entity_id)
Parameters
player_entity_idulong
Returns
- Friend[]
GetKeybindDown(Keybind)
public bool GetKeybindDown(Keybind id)
Parameters
idKeybind
Returns
GetKeybindHeld(Keybind)
public bool GetKeybindHeld(Keybind id)
Parameters
idKeybind
Returns
GetKeybindSprite(Keybind)
public Texture GetKeybindSprite(Keybind id)
Parameters
idKeybind
Returns
GetKeybindString(Keybind)
public string GetKeybindString(Keybind id)
Parameters
idKeybind
Returns
GetKeybindUp(Keybind)
public bool GetKeybindUp(Keybind id)
Parameters
idKeybind
Returns
GetMousePosition()
Get the mouse position in world space. This may be called on the client and the server.
public Vector2 GetMousePosition()
Returns
GetMovementKind()
Get the movement kind of the player
public int GetMovementKind()
Returns
GetSortedTargetsForAbility(Ability)
public List<Player> GetSortedTargetsForAbility(Ability ability)
Parameters
abilityAbility
Returns
GetSpineInstanceForPlayerList()
public SpineInstance GetSpineInstanceForPlayerList()
Returns
GetStat(string)
public long GetStat(string name)
Parameters
namestring
Returns
GetWorldRect()
The world rect of the player positioned at their feet.
public Rect GetWorldRect()
Returns
GetZOffset()
public float GetZOffset()
Returns
HandleFrameEvent(int, StreamReader)
public virtual bool HandleFrameEvent(int evt, StreamReader reader)
Parameters
evtintreaderStreamReader
Returns
HasDisableMovementInputReason(string)
If the player has a particular disable movement input reason
public bool HasDisableMovementInputReason(string reason)
Parameters
reasonstring
Returns
HasDisableMovementInputReasons()
If the player has any disable movement input reasons
public bool HasDisableMovementInputReasons()
Returns
HasEffect(Type)
Returns true if the player has an active effect of the given type, or if the player has an effect of the given type.
public bool HasEffect(Type type)
Parameters
typeType
Returns
HasEffect<T>()
Returns true if the player has an active effect of the given type, or if the player has an effect of the given type.
public bool HasEffect<T>() where T : AEffect
Returns
Type Parameters
T
HasFreezeReason(string)
If the player has a particular freeze reason
public bool HasFreezeReason(string reason)
Parameters
reasonstring
Returns
HasFreezeReasons()
If the player has any freeze reasons
public bool HasFreezeReasons()
Returns
HasInvisibilityReason(string)
If the player has a particular invisibility reason
public bool HasInvisibilityReason(string reason)
Parameters
reasonstring
Returns
HasInvisibilityReasons()
If the player has any invisibility reasons
public bool HasInvisibilityReasons()
Returns
HasJoystickDisableReason(string)
If the player has a particular joystick disable reason
public bool HasJoystickDisableReason(string reason)
Parameters
reasonstring
Returns
HasJoystickDisableReasons()
If the player has any joystick disable reasons
public bool HasJoystickDisableReasons()
Returns
HasNameInvisibilityReason(string)
If the player has a particular name invisibility reason
public bool HasNameInvisibilityReason(string reason)
Parameters
reasonstring
Returns
HasNameInvisibilityReasons()
If the player has any name invisibility reasons
public bool HasNameInvisibilityReasons()
Returns
IsInputDown(UnifiedInput)
Check if an input is down this frame. This may be called on the client and the server.
public bool IsInputDown(Input.UnifiedInput input)
Parameters
inputInput.UnifiedInput
Returns
IsInputHeld(UnifiedInput)
Check if an input is held. This may be called on the client and the server.
public bool IsInputHeld(Input.UnifiedInput input)
Parameters
inputInput.UnifiedInput
Returns
IsInputRepeat(UnifiedInput)
Check if an input is repeating. This may be called on the client and the server.
public bool IsInputRepeat(Input.UnifiedInput input)
Parameters
inputInput.UnifiedInput
Returns
IsInputUp(UnifiedInput)
Check if an input is up this frame. This may be called on the client and the server.
public bool IsInputUp(Input.UnifiedInput input)
Parameters
inputInput.UnifiedInput
Returns
OnActivatedAbility(Ability)
public virtual void OnActivatedAbility(Ability ability)
Parameters
abilityAbility
PlayRandomFootstep()
public void PlayRandomFootstep()
ReadFrameData(StreamReader)
public virtual void ReadFrameData(StreamReader reader)
Parameters
readerStreamReader
RemoveDisableMovementInputReason(string)
Remove a reason to disable movement input.
public bool RemoveDisableMovementInputReason(string reason)
Parameters
reasonstring
Returns
RemoveEffect(AEffect, bool)
Removes an effect from the player. This will remove the active effect if it matches the given effect.
public bool RemoveEffect(AEffect effect, bool interrupt)
Parameters
Returns
RemoveEffect(Type, bool)
Removes an effect from the player. This will remove the active effect if it matches the given type.
public bool RemoveEffect(Type effectType, bool interrupt)
Parameters
effectTypeTypeThe type of effect to remove.
interruptboolIf true, the effect will be interrupted and its OnEffectEnd method will be called with interrupt=true.
Returns
- bool
True if the effect was removed, false if it was not found.
RemoveEffect<T>(bool)
Removes an effect from the player. This will remove the active effect if it matches the given type.
public bool RemoveEffect<T>(bool interrupt) where T : AEffect
Parameters
interruptbool
Returns
Type Parameters
T
RemoveEmoteBlockReason(string)
Remove a reason that disallow emoting.
public void RemoveEmoteBlockReason(string reason)
Parameters
reasonstring
RemoveFreezeReason(string)
Remove a reason to freeze the players movement
public bool RemoveFreezeReason(string reason)
Parameters
reasonstring
Returns
RemoveInvisibilityReason(string)
Remove a reason to make the player invisible
public bool RemoveInvisibilityReason(string reason)
Parameters
reasonstring
Returns
RemoveJoystickDisableReason(string)
Un-hides the joystick.
public bool RemoveJoystickDisableReason(string reason)
Parameters
reasonstring
Returns
RemoveNameInvisibilityReason(string)
Remove a reason to make the players name invisible
public bool RemoveNameInvisibilityReason(string reason)
Parameters
reasonstring
Returns
RemoveStat(string)
public void RemoveStat(string name)
Parameters
namestring
SetAimTarget(Vector2)
public void SetAimTarget(Vector2 target)
Parameters
targetVector2
SetChatChannel(int)
public void SetChatChannel(int channel)
Parameters
channelint
SetFacingDirection(bool)
Sets the direction you want the player to face. Should be paired with DisableDirectionalFlipping
public void SetFacingDirection(bool faceRight)
Parameters
faceRightbool
SetMouseIKEnabled(bool)
Set the mouse IK enabled.
public void SetMouseIKEnabled(bool enabled)
Parameters
enabledbool
StopActiveEffect(bool)
Stops the active effect on the player, if any.
public void StopActiveEffect(bool interrupt)
Parameters
interruptboolIf true, the effect will be interrupted and its OnEffectEnd method will be called with interrupt=true.
StopEffect(AEffect, int, bool)
public void StopEffect(AEffect effect, int index, bool interrupt)
Parameters
Teleport(Vector2)
Teleport the player to a position
public void Teleport(Vector2 position)
Parameters
positionVector2
TryGetEffect<T>(out T)
Returns the effect of the given type or null if the player does not have an effect of that type.
public bool TryGetEffect<T>(out T effect) where T : AEffect
Parameters
effectT
Returns
Type Parameters
T
TryLocalSetCurrentTargettingAbility(Ability, int)
public bool TryLocalSetCurrentTargettingAbility(Ability ability, int index)
Parameters
Returns
UpdateStat(string, long)
public void UpdateStat(string name, long val)
Parameters
WriteFrameData(StreamWriter)
public virtual void WriteFrameData(StreamWriter writer)
Parameters
writerStreamWriter