Techneck/code/source-c/entity/player.c

58 lines
1.7 KiB
C

#include "registration.h"
#include <state.h>
#include <stdlib.h>
tc_entity_type_s *tc_player_entity_type_g = NULL;
void tc_fn_create_player_entity(tc_entity_s *entity)
{
entity->type = tc_player_entity_type_g;
entity->location = tc_zero_location();
entity->specific = NULL;
}
void tc_fn_spawn_player_entity(tc_entity_s *entity, tc_location_s location)
{
if(entity->location.world != NULL) return;
entity->location = location;
}
void tc_fn_teleport_player_entity(tc_entity_s *entity, tc_location_s location)
{
tc_set_float_for_entity(tc_game_state_g.viewer, "pos_x", location.position.x);
tc_set_float_for_entity(tc_game_state_g.viewer, "pos_y", location.position.y);
tc_set_float_for_entity(tc_game_state_g.viewer, "pos_z", location.position.z);
}
void tc_fn_delete_player_entity(tc_entity_s *entity)
{
if(entity->specific != NULL) free(entity->specific);
tc_deallocate_entity(entity);
}
void tc_fn_send_event_player_entity(tc_entity_s *entity, tc_entity_event_s event)
{
}
void tc_register_player_entity()
{
tc_entity_type_s type;
type.internal_name = "player";
type.display_name = "Player";
type.instances_capacity = 8;
type.functions.fn_create = tc_fn_create_player_entity;
type.functions.fn_spawn = tc_fn_spawn_player_entity;
type.functions.fn_teleport = tc_fn_teleport_player_entity;
type.functions.fn_delete = tc_fn_delete_player_entity;
type.functions.fn_send_event = tc_fn_send_event_player_entity;
tc_register_entity_type(type);
tc_player_entity_type_g = tc_get_entity_type_with_name("player");
}