parent
2adcef4a1f
commit
a988bdea8a
@ -0,0 +1,115 @@ |
||||
Entity |
||||
{ |
||||
type : 10 |
||||
scale : 1.000 1.000 1.000 |
||||
door_state : 0 |
||||
door_open_position : -7.0000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
door_close_position : 0.0000 |
||||
active : true |
||||
door_speed : 6.0000 |
||||
position : -18.500 1.000 -30.000 |
||||
door_mask : 4 |
||||
name : Door |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 7.000 11.000 14.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 5.000 0.000 |
||||
trigger_type : 1 |
||||
name : Door_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 7 |
||||
scale : 1.000 1.000 1.000 |
||||
volume : 1.0000 |
||||
rolloff_factor : 0.9500 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
loop : false |
||||
sound_min_distance : 0.0000 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
source_filename : sounds/door_locked.wav |
||||
sound_type : 1 |
||||
sound_max_distance : 30.0000 |
||||
name : Door_Sound |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
sound_attenuation_type : 2 |
||||
paused : true |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 7.000 12.000 0.200 |
||||
material : 0 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.055 0.863 0.839 1.000 |
||||
geometry : cube.symbres |
||||
specular : 0.4000 |
||||
active : true |
||||
diffuse_texture : default.tga |
||||
diffuse : 1.0000 |
||||
position : 0.012 4.500 0.000 |
||||
specular_strength : 62.0000 |
||||
name : Door_Mesh |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.100 0.100 0.100 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 7.500 0.000 |
||||
name : Door_Key_Indicator_Red |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.100 0.100 0.100 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 5.500 0.000 |
||||
name : Door_Key_Indicator_Green |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.470 0.670 0.890 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 3.500 0.000 |
||||
name : Door_Key_Indicator_Blue |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
@ -0,0 +1,115 @@ |
||||
Entity |
||||
{ |
||||
type : 10 |
||||
scale : 1.000 1.000 1.000 |
||||
door_state : 0 |
||||
door_open_position : -7.0000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
door_close_position : 0.0000 |
||||
active : true |
||||
door_speed : 6.0000 |
||||
position : -18.500 1.000 -30.000 |
||||
door_mask : 2 |
||||
name : Door |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 7.000 11.000 14.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 5.000 0.000 |
||||
trigger_type : 1 |
||||
name : Door_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 7 |
||||
scale : 1.000 1.000 1.000 |
||||
volume : 1.0000 |
||||
rolloff_factor : 0.9500 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
loop : false |
||||
sound_min_distance : 0.0000 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
source_filename : sounds/door_locked.wav |
||||
sound_type : 1 |
||||
sound_max_distance : 30.0000 |
||||
name : Door_Sound |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
sound_attenuation_type : 2 |
||||
paused : true |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 7.000 12.000 0.200 |
||||
material : 0 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.055 0.863 0.839 1.000 |
||||
geometry : cube.symbres |
||||
specular : 0.4000 |
||||
active : true |
||||
diffuse_texture : default.tga |
||||
diffuse : 1.0000 |
||||
position : 0.012 4.500 0.000 |
||||
specular_strength : 62.0000 |
||||
name : Door_Mesh |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.100 0.100 0.100 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 7.500 0.000 |
||||
name : Door_Key_Indicator_Red |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.530 0.670 0.280 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 5.500 0.000 |
||||
name : Door_Key_Indicator_Green |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.100 0.100 0.100 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 3.500 0.000 |
||||
name : Door_Key_Indicator_Blue |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
@ -0,0 +1,115 @@ |
||||
Entity |
||||
{ |
||||
type : 10 |
||||
scale : 1.000 1.000 1.000 |
||||
door_state : 0 |
||||
door_open_position : -7.0000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
door_close_position : 0.0000 |
||||
active : true |
||||
door_speed : 6.0000 |
||||
position : -18.500 1.000 -30.000 |
||||
door_mask : 1 |
||||
name : Door |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 7.000 11.000 14.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 5.000 0.000 |
||||
trigger_type : 1 |
||||
name : Door_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 7 |
||||
scale : 1.000 1.000 1.000 |
||||
volume : 1.0000 |
||||
rolloff_factor : 0.9500 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
loop : false |
||||
sound_min_distance : 0.0000 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
source_filename : sounds/door_locked.wav |
||||
sound_type : 1 |
||||
sound_max_distance : 30.0000 |
||||
name : Door_Sound |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
sound_attenuation_type : 2 |
||||
paused : true |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 7.000 12.000 0.200 |
||||
material : 0 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.055 0.863 0.839 1.000 |
||||
geometry : cube.symbres |
||||
specular : 0.4000 |
||||
active : true |
||||
diffuse_texture : default.tga |
||||
diffuse : 1.0000 |
||||
position : 0.012 4.500 0.000 |
||||
specular_strength : 62.0000 |
||||
name : Door_Mesh |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.870 0.320 0.400 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 7.500 0.000 |
||||
name : Door_Key_Indicator_Red |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.100 0.100 0.100 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 5.500 0.000 |
||||
name : Door_Key_Indicator_Green |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.100 0.100 0.100 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 3.500 0.000 |
||||
name : Door_Key_Indicator_Blue |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
@ -0,0 +1,115 @@ |
||||
Entity |
||||
{ |
||||
type : 10 |
||||
scale : 1.000 1.000 1.000 |
||||
door_state : 0 |
||||
door_open_position : -7.0000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
door_close_position : 0.0000 |
||||
active : true |
||||
door_speed : 6.0000 |
||||
position : -18.500 1.000 -30.000 |
||||
door_mask : 7 |
||||
name : Door |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 7.000 11.000 14.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 5.000 0.000 |
||||
trigger_type : 1 |
||||
name : Door_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 7 |
||||
scale : 1.000 1.000 1.000 |
||||
volume : 1.0000 |
||||
rolloff_factor : 0.9500 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
loop : false |
||||
sound_min_distance : 0.0000 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
source_filename : sounds/door_locked.wav |
||||
sound_type : 1 |
||||
sound_max_distance : 30.0000 |
||||
name : Door_Sound |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
sound_attenuation_type : 2 |
||||
paused : true |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 7.000 12.000 0.200 |
||||
material : 0 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.055 0.863 0.839 1.000 |
||||
geometry : cube.symbres |
||||
specular : 0.4000 |
||||
active : true |
||||
diffuse_texture : default.tga |
||||
diffuse : 1.0000 |
||||
position : 0.012 4.500 0.000 |
||||
specular_strength : 62.0000 |
||||
name : Door_Mesh |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.870 0.320 0.400 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 7.500 0.000 |
||||
name : Door_Key_Indicator_Red |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.530 0.670 0.280 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 5.500 0.000 |
||||
name : Door_Key_Indicator_Green |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.470 0.670 0.890 |
||||
geometry : cube.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 4.000 3.500 0.000 |
||||
name : Door_Key_Indicator_Blue |
||||
uv_scale : 0.300 0.200 |
||||
} |
||||
|
@ -0,0 +1,44 @@ |
||||
Entity |
||||
{ |
||||
type : 11 |
||||
scale : 1.000 1.000 1.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
pickup_spin_speed : 45.0000 |
||||
active : true |
||||
position : 13.000 3.000 -13.000 |
||||
pickup_type : 1 |
||||
pickup_health : 25 |
||||
name : Pickup_Health |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 3.000 3.000 2.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
trigger_type : 0 |
||||
name : Pickup_Health_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.686 0.000 0.027 1.000 |
||||
geometry : pickup_health.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 0.000 0.000 0.000 |
||||
name : Pickup_Health_Mesh |
||||
uv_scale : 1.000 1.000 |
||||
} |
||||
|
@ -0,0 +1,44 @@ |
||||
Entity |
||||
{ |
||||
type : 11 |
||||
scale : 1.000 1.000 1.000 |
||||
pickup_key_type : 4 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
pickup_spin_speed : 40.0000 |
||||
active : true |
||||
position : -39.000 2.000 -56.000 |
||||
pickup_type : 0 |
||||
name : Pickup_Key_Blue |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 3.00 3 3 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
trigger_type : 0 |
||||
name : Pickup_Key_Blue_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.530 0.670 0.280 1.000 |
||||
geometry : pickup_key.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 0.000 0.000 0.000 |
||||
name : Pickup_Key_Blue_Mesh |
||||
uv_scale : 1.000 1.000 |
||||
} |
||||
|
@ -0,0 +1,44 @@ |
||||
Entity |
||||
{ |
||||
type : 11 |
||||
scale : 1.000 1.000 1.000 |
||||
pickup_key_type : 2 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
pickup_spin_speed : 5.0000 |
||||
active : true |
||||
position : -37.000 2.000 -74.000 |
||||
pickup_type : 0 |
||||
name : Pickup_Key_Green |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 1.000 1.000 1.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
trigger_type : 0 |
||||
name : Pickup_Key_Green_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 0.870 0.320 0.400 1.000 |
||||
geometry : pickup_key.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 0.000 0.000 0.000 |
||||
name : Pickup_Key_Green_Mesh |
||||
uv_scale : 1.000 1.000 |
||||
} |
||||
|
@ -0,0 +1,41 @@ |
||||
Entity |
||||
{ |
||||
type : 11 |
||||
scale : 1.000 1.000 1.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
name : Pickup_Key_Red |
||||
pickup_type : 0 |
||||
pickup_key_type : 1 |
||||
pickup_spin_speed : 5.000 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 9 |
||||
scale : 1.000 1.000 1.000 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
trigger_mask : 1 |
||||
active : true |
||||
position : 0.000 0.000 0.000 |
||||
trigger_type : 0 |
||||
name : Pickup_Key_Red_Trigger |
||||
bounding_box_min : -0.500 -0.500 -0.500 |
||||
bounding_box_max : 0.500 0.500 0.500 |
||||
} |
||||
|
||||
Entity |
||||
{ |
||||
type : 6 |
||||
scale : 1.000 1.000 1.000 |
||||
material : 1 |
||||
rotation : 0.000 0.000 0.000 1.000 |
||||
diffuse_color : 1.000 1.000 1.000 1.000 |
||||
geometry : pickup_key.symbres |
||||
active : true |
||||
diffuse_texture : white.tga |
||||
position : 0.000 0.000 0.000 |
||||
name : Pickup_Key_Red_Mesh |
||||
uv_scale : 1.000 1.000 |
||||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,122 @@ |
||||
#include "pickup.h" |
||||
#include "entity.h" |
||||
#include "game.h" |
||||
#include "event.h" |
||||
#include "../common/hashmap.h" |
||||
#include "../common/parser.h" |
||||
#include "scene.h" |
||||
#include "../common/log.h" |
||||
#include "material.h" |
||||
#include "door.h" |
||||
#include "transform.h" |
||||
|
||||
static void pickup_on_scene_loaded(struct Event* event, void* pickup_ptr); |
||||
static void pickup_on_trigger(struct Event* event, void* pickup_ptr, void* trigger_ptr); |
||||
|
||||
void pickup_init(struct Pickup* pickup, int type) |
||||
{ |
||||
pickup->base.type = ET_PICKUP; |
||||
pickup->type = type; |
||||
pickup->spin_speed = 5.f; |
||||
switch(type) |
||||
{ |
||||
case PICKUP_KEY: pickup->key_type = DOOR_KEY_MASK_NONE; break; |
||||
case PICKUP_HEALTH: pickup->health = 0; break; |
||||
} |
||||
|
||||
struct Game_State* game_state = game_state_get(); |
||||
event_manager_subscribe_with_subscriber(game_state->event_manager, EVT_SCENE_LOADED, &pickup_on_scene_loaded, (void*)pickup); |
||||
} |
||||
|
||||
void pickup_reset(struct Pickup* pickup) |
||||
{ |
||||
struct Game_State* game_state = game_state_get(); |
||||
event_manager_unsubscribe_with_subscriber(game_state->event_manager, EVT_SCENE_LOADED, &pickup_on_scene_loaded, (void*)pickup); |
||||
event_manager_unsubscribe_with_subscriber_sender(game_state->event_manager, EVT_TRIGGER, &pickup_on_trigger, (void*)pickup, (void*)pickup->trigger); |
||||
} |
||||
|
||||
struct Pickup* pickup_read(struct Parser_Object* parser_object, const char* name, struct Entity* parent_entity) |
||||
{ |
||||
struct Pickup* new_pickup = NULL; |
||||
struct Scene* scene = game_state_get()->scene; |
||||
|
||||
new_pickup = scene_pickup_create(scene, name, parent_entity, PICKUP_HEALTH); |
||||
if(hashmap_value_exists(parser_object->data, "pickup_type")) new_pickup->type = hashmap_int_get(parser_object->data, "pickup_type"); |
||||
if(hashmap_value_exists(parser_object->data, "pickup_spin_speed")) new_pickup->spin_speed = hashmap_float_get(parser_object->data, "pickup_spin_speed"); |
||||
switch(new_pickup->type) |
||||
{ |
||||
case PICKUP_KEY: if(hashmap_value_exists(parser_object->data, "pickup_key_type")) new_pickup->key_type = hashmap_int_get(parser_object->data, "pickup_key_type"); break; |
||||
case PICKUP_HEALTH: if(hashmap_value_exists(parser_object->data, "pickup_health")) new_pickup->health = hashmap_int_get(parser_object->data, "pickup_health"); break; |
||||
} |
||||
return new_pickup; |
||||
} |
||||
|
||||
void pickup_write(struct Pickup* pickup, struct Hashmap* pickup_data) |
||||
{ |
||||
hashmap_int_set(pickup_data, "pickup_type", pickup->type); |
||||
hashmap_float_set(pickup_data, "pickup_spin_speed", pickup->spin_speed); |
||||
|
||||
switch(pickup->type) |
||||
{ |
||||
case PICKUP_KEY: hashmap_int_set(pickup_data, "pickup_key_type", pickup->key_type); break; |
||||
case PICKUP_HEALTH: hashmap_int_set(pickup_data, "pickup_health", pickup->health); break; |
||||
} |
||||
} |
||||
|
||||
void pickup_on_scene_loaded(struct Event* event, void* pickup_ptr) |
||||
{ |
||||
struct Pickup* pickup = (struct Pickup*)pickup_ptr; |
||||
struct Trigger* pickup_trigger[1] = { NULL }; |
||||
struct Static_Mesh* pickup_mesh[1] = { NULL }; |
||||
|
||||
if(entity_get_num_children_of_type(pickup, ET_TRIGGER, &pickup_trigger, 1) == 1) |
||||
{ |
||||
pickup->trigger = pickup_trigger[0]; |
||||
struct Event_Manager* event_manager = game_state_get()->event_manager; |
||||
event_manager_subscribe_with_subscriber_sender(event_manager, EVT_TRIGGER, &pickup_on_trigger, (void*)pickup, pickup->trigger); |
||||
} |
||||
else |
||||
{ |
||||
log_error("pickup:on_scene_loaded", "Could not find trigger for pickup %s", pickup->base.name); |
||||
} |
||||
|
||||
if(entity_get_num_children_of_type(pickup, ET_STATIC_MESH, &pickup_mesh, 1) == 1) |
||||
{ |
||||
pickup->mesh = pickup_mesh[0]; |
||||
if(pickup->type == PICKUP_KEY) |
||||
{ |
||||
switch(pickup->key_type) |
||||
{ |
||||
case DOOR_KEY_MASK_RED: vec4_assign(&pickup->mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_RED); break; |
||||
case DOOR_KEY_MASK_GREEN: vec4_assign(&pickup->mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_GREEN); break; |
||||
case DOOR_KEY_MASK_BLUE: vec4_assign(&pickup->mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_BLUE); break; |
||||
} |
||||
} |
||||
else if(pickup->type == PICKUP_HEALTH) |
||||
{ |
||||
log_message("Break"); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
log_error("pickup:on_scene_loaded", "Could not find mesh for pickup %s", pickup->base.name); |
||||
} |
||||
} |
||||
|
||||
void pickup_update(struct Pickup* pickup, float dt) |
||||
{ |
||||
transform_rotate(pickup->mesh, &UNIT_Y, pickup->spin_speed * dt, TS_WORLD); |
||||
} |
||||
|
||||
void pickup_on_trigger(struct Event* event, void* pickup_ptr, void* trigger_ptr) |
||||
{ |
||||
struct Pickup* pickup = (struct Pickup*) pickup_ptr; |
||||
switch(event->trigger.triggering_entity->type) |
||||
{ |
||||
case ET_PLAYER: player_on_pickup(event->trigger.triggering_entity, pickup); break; |
||||
case ET_ENEMY: |
||||
break; |
||||
} |
||||
|
||||
scene_pickup_remove(game_state_get()->scene, pickup); |
||||
} |
@ -0,0 +1,15 @@ |
||||
#ifndef PICKUP_H |
||||
#define PICKUP_H |
||||
|
||||
struct Pickup; |
||||
struct Entity; |
||||
struct Parser_Object; |
||||
struct Hashmap; |
||||
|
||||
void pickup_init(struct Pickup* pickup, int type); |
||||
void pickup_reset(struct Pickup* pickup); |
||||
struct Pickup* pickup_read(struct Parser_Object* parser_object, const char* name, struct Entity* parent_entity); |
||||
void pickup_write(struct Pickup* pickup, struct Hashmap* pickup_data); |
||||
void pickup_update(struct Pickup* pickup, float dt); |
||||
|
||||
#endif |
Loading…
Reference in new issue