Skip to content

Commit

Permalink
added state control functions setter;
Browse files Browse the repository at this point in the history
  • Loading branch information
TeslaRus committed Feb 21, 2017
1 parent c29c273 commit 39df093
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/character_controller.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/entity.h
Expand Up @@ -3,6 +3,7 @@
#define ENTITY_H

#include <stdint.h>
#include <stdlib.h>

struct room_sector_s;
struct obb_s;
Expand Down
23 changes: 23 additions & 0 deletions 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;
}
}
}
6 changes: 3 additions & 3 deletions src/state_control/state_control.h
Expand Up @@ -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

5 changes: 2 additions & 3 deletions src/world.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 39df093

Please sign in to comment.