Tramway SDK
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tram::ControllerComponent Class Reference

#include <controller.h>

Inheritance diagram for tram::ControllerComponent:
tram::EntityComponent

Public Member Functions

void Start ()
 
void EventHandler (Event &event)
 
void Move (vec3 local_direction)
 
void Run ()
 
void Crouch ()
 
void Jump ()
 
void TurnLeft ()
 
void TurnRight ()
 
void Push (vec3 direction)
 
void SetLookDirection (quat direction)
 
quat GetLookDirection () const
 
void SetCollisionSize (float width, float height, float crouch_height)
 
void SetStepHeight (float height, float crouch_height)
 
void SetWallCollisionCallback (void(*callback)(ControllerComponent *, Physics::Collision))
 
void SetWalkSpeed (float walk_speed)
 
void SetRunSpeed (float run_speed)
 
void SetCrouchSpeed (float crouch_speed)
 
void SetFriction (float friction)
 
void SetCollisionGroup (uint32_t group)
 
- Public Member Functions inherited from tram::EntityComponent
 EntityComponent ()
 
virtual ~EntityComponent ()
 
virtual void Init ()
 
bool IsReady ()
 
bool IsInit ()
 
EntityGetParent ()
 
void SetParent (Entity *parent)
 

Static Public Member Functions

static void Update ()
 Updates the ControllerComponents. More...
 

Protected Member Functions

 ControllerComponent ()=default
 
 ~ControllerComponent ()=default
 
void ApplyDynamics ()
 
void RecoverFromCollisions ()
 
void ResetMove ()
 
- Protected Member Functions inherited from tram::EntityComponent
void ResourceReady ()
 

Protected Attributes

Component< TriggerComponentwalk_collision
 
Component< TriggerComponentcrouch_collision
 
Component< PhysicsComponentphysics_body
 
vec3 velocity = {0.0f, 0.0f, 0.0f}
 
vec3 move_direction = {0.0f, 0.0f, 0.0f}
 
quat look_direction = {1.0f, 0.0f, 0.0f, 0.0f}
 
bool is_in_air = false
 
float collision_width = 0.35f
 
float collision_height = 1.85f
 
float collision_height_crouch = 0.5f
 
float step_height = 0.35f
 
float step_height_crouch = 0.15f
 
float walk_speed = 0.1f
 
float run_speed = 0.2f
 
float crouch_speed = 0.05f
 
float friction = 0.89f
 
bool crouching = false
 
bool running = false
 
id_t standing_on = 0
 
id_t standing_on_prev = 0
 
vec3 standing_pos
 
uint32_t collision_group = Physics::COLL_PLAYER
 
- Protected Attributes inherited from tram::EntityComponent
size_t resources_waiting = 0
 
bool is_ready = false
 
bool is_init = false
 
Entityparent = nullptr
 

Constructor & Destructor Documentation

◆ ControllerComponent()

tram::ControllerComponent::ControllerComponent ( )
protecteddefault

◆ ~ControllerComponent()

tram::ControllerComponent::~ControllerComponent ( )
protecteddefault

Member Function Documentation

◆ ApplyDynamics()

void tram::ControllerComponent::ApplyDynamics ( )
protected

◆ Crouch()

void tram::ControllerComponent::Crouch ( )

◆ EventHandler()

void tram::ControllerComponent::EventHandler ( Event event)
inlinevirtual

Implements tram::EntityComponent.

◆ GetLookDirection()

quat tram::ControllerComponent::GetLookDirection ( ) const
inline

◆ Jump()

void tram::ControllerComponent::Jump ( )

◆ Move()

void tram::ControllerComponent::Move ( vec3  local_direction)

◆ Push()

void tram::ControllerComponent::Push ( vec3  direction)

◆ RecoverFromCollisions()

void tram::ControllerComponent::RecoverFromCollisions ( )
protected

◆ ResetMove()

void tram::ControllerComponent::ResetMove ( )
protected

◆ Run()

void tram::ControllerComponent::Run ( )

◆ SetCollisionGroup()

void tram::ControllerComponent::SetCollisionGroup ( uint32_t  group)
inline

◆ SetCollisionSize()

void tram::ControllerComponent::SetCollisionSize ( float  width,
float  height,
float  crouch_height 
)
inline

◆ SetCrouchSpeed()

void tram::ControllerComponent::SetCrouchSpeed ( float  crouch_speed)
inline

◆ SetFriction()

void tram::ControllerComponent::SetFriction ( float  friction)
inline

◆ SetLookDirection()

void tram::ControllerComponent::SetLookDirection ( quat  direction)
inline

◆ SetRunSpeed()

void tram::ControllerComponent::SetRunSpeed ( float  run_speed)
inline

◆ SetStepHeight()

void tram::ControllerComponent::SetStepHeight ( float  height,
float  crouch_height 
)
inline

◆ SetWalkSpeed()

void tram::ControllerComponent::SetWalkSpeed ( float  walk_speed)
inline

◆ SetWallCollisionCallback()

void tram::ControllerComponent::SetWallCollisionCallback ( void(*)(ControllerComponent *, Physics::Collision callback)
inline

◆ Start()

void tram::ControllerComponent::Start ( )
virtual

Implements tram::EntityComponent.

◆ TurnLeft()

void tram::ControllerComponent::TurnLeft ( )

◆ TurnRight()

void tram::ControllerComponent::TurnRight ( )

◆ Update()

void tram::ControllerComponent::Update ( )
static

Updates the ControllerComponents.

Updates all of the ControllerComponents. Should be called once per update cycle.

Member Data Documentation

◆ collision_group

uint32_t tram::ControllerComponent::collision_group = Physics::COLL_PLAYER
protected

◆ collision_height

float tram::ControllerComponent::collision_height = 1.85f
protected

◆ collision_height_crouch

float tram::ControllerComponent::collision_height_crouch = 0.5f
protected

◆ collision_width

float tram::ControllerComponent::collision_width = 0.35f
protected

◆ crouch_collision

Component<TriggerComponent> tram::ControllerComponent::crouch_collision
protected

◆ crouch_speed

float tram::ControllerComponent::crouch_speed = 0.05f
protected

◆ crouching

bool tram::ControllerComponent::crouching = false
protected

◆ friction

float tram::ControllerComponent::friction = 0.89f
protected

◆ is_in_air

bool tram::ControllerComponent::is_in_air = false
protected

◆ look_direction

quat tram::ControllerComponent::look_direction = {1.0f, 0.0f, 0.0f, 0.0f}
protected

◆ move_direction

vec3 tram::ControllerComponent::move_direction = {0.0f, 0.0f, 0.0f}
protected

◆ physics_body

Component<PhysicsComponent> tram::ControllerComponent::physics_body
protected

◆ run_speed

float tram::ControllerComponent::run_speed = 0.2f
protected

◆ running

bool tram::ControllerComponent::running = false
protected

◆ standing_on

id_t tram::ControllerComponent::standing_on = 0
protected

◆ standing_on_prev

id_t tram::ControllerComponent::standing_on_prev = 0
protected

◆ standing_pos

vec3 tram::ControllerComponent::standing_pos
protected

◆ step_height

float tram::ControllerComponent::step_height = 0.35f
protected

◆ step_height_crouch

float tram::ControllerComponent::step_height_crouch = 0.15f
protected

◆ velocity

vec3 tram::ControllerComponent::velocity = {0.0f, 0.0f, 0.0f}
protected

◆ walk_collision

Component<TriggerComponent> tram::ControllerComponent::walk_collision
protected

◆ walk_speed

float tram::ControllerComponent::walk_speed = 0.1f
protected

The documentation for this class was generated from the following files: