From 39df093327297181de5f9070eaf3dcf9da124eea Mon Sep 17 00:00:00 2001 From: TeslaRus Date: Tue, 21 Feb 2017 18:59:39 +0400 Subject: [PATCH] added state control functions setter; --- CMakeLists.txt | 1 + src/character_controller.cpp | 7 ++++--- src/entity.h | 1 + src/state_control/state_control.cpp | 23 +++++++++++++++++++++++ src/state_control/state_control.h | 6 +++--- src/world.cpp | 5 ++--- 6 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/state_control/state_control.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c1818fe24..57da61a7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,7 @@ set(OPENTOMB_SRCS src/vt/tr_types.h src/vt/tr_versions.h src/state_control/state_control.h + src/state_control/state_control.cpp src/state_control/state_control_Lara.h src/state_control/state_control_Lara.cpp src/audio.cpp diff --git a/src/character_controller.cpp b/src/character_controller.cpp index 06b004157..6c63ecf0f 100644 --- a/src/character_controller.cpp +++ b/src/character_controller.cpp @@ -45,11 +45,12 @@ void Character_Create(struct entity_s *ent) ret->weapon_current_state = 0x00; ret->current_weapon = 0; - ent->character->state.floor_collide = 0x00; - ent->character->state.ceiling_collide = 0x00; - ent->character->state.wall_collide = 0x00; + ret->state.floor_collide = 0x00; + ret->state.ceiling_collide = 0x00; + ret->state.wall_collide = 0x00; ret->state.slide = 0x00; ret->state.step_z = 0x00; + ret->state.uw_current = 0x00; ret->state.dead = 0x00; ret->state.burn = 0x00; ret->state.crouch = 0x00; diff --git a/src/entity.h b/src/entity.h index 1bc9974fe..5f1279cc1 100644 --- a/src/entity.h +++ b/src/entity.h @@ -3,6 +3,7 @@ #define ENTITY_H #include +#include struct room_sector_s; struct obb_s; diff --git a/src/state_control/state_control.cpp b/src/state_control/state_control.cpp new file mode 100644 index 000000000..7cfb59763 --- /dev/null +++ b/src/state_control/state_control.cpp @@ -0,0 +1,23 @@ + +#include "../skeletal_model.h" +#include "../entity.h" +#include "../character_controller.h" +#include "state_control.h" + +int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim); +void StateControl_LaraSetIdleAnim(struct entity_s *ent, int anim_type, int move_type); + + +void StateControl_SetStateFunctions(struct entity_s *ent, int functions_id) +{ + if(ent && ent->character) + { + switch(functions_id) + { + case STATE_FUNCTIONS_LARA: + ent->character->state_func = StateControl_Lara; + ent->character->set_idle_anim_func = StateControl_LaraSetIdleAnim; + break; + } + } +} \ No newline at end of file diff --git a/src/state_control/state_control.h b/src/state_control/state_control.h index ef2f57538..56425ba3c 100644 --- a/src/state_control/state_control.h +++ b/src/state_control/state_control.h @@ -2,11 +2,11 @@ #ifndef STATE_CONTROL_H #define STATE_CONTROL_H -struct ss_animation_s; struct entity_s; -int StateControl_Lara(struct entity_s *ent, struct ss_animation_s *ss_anim); -void StateControl_LaraSetIdleAnim(struct entity_s *ent, int anim_type, int move_type); +#define STATE_FUNCTIONS_LARA (0x01) + +void StateControl_SetStateFunctions(struct entity_s *ent, int functions_id); #endif diff --git a/src/world.cpp b/src/world.cpp index 271fdb019..2c47da70d 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -2288,15 +2288,14 @@ void World_GenEntities(class VT_Level *tr) entity->bf->bone_tags[j].mesh_skin = entity->bf->animations.model->mesh_tree[j].mesh_skin; entity->bf->bone_tags[j].mesh_slot = NULL; } - StateControl_LaraSetIdleAnim(global_world.Character, ANIM_TYPE_BASE, MOVE_ON_FLOOR); Physics_GenRigidBody(entity->physics, entity->bf); Entity_UpdateRigidBody(entity, 1); Character_Create(entity); + StateControl_SetStateFunctions(entity, STATE_FUNCTIONS_LARA); + entity->character->set_idle_anim_func(entity, ANIM_TYPE_BASE, MOVE_ON_FLOOR); Room_AddObject(entity->self->room, entity->self); entity->character->Height = 768.0; - entity->character->state_func = StateControl_Lara; - entity->character->set_idle_anim_func = StateControl_LaraSetIdleAnim; entity->character->height_info.leg_l_index = LEFT_LEG; entity->character->height_info.leg_r_index = RIGHT_LEG; //entity->character->height_info.hand_l_index = LEFT_HAND;