Browse Source

Add twig tool

master
C. J. Howard 4 years ago
parent
commit
bf72a69bd0
7 changed files with 22 additions and 3 deletions
  1. +0
    -1
      src/application.cpp
  2. +9
    -0
      src/game/bootloader.cpp
  3. +1
    -0
      src/game/game-context.hpp
  4. +3
    -0
      src/game/states/play-state.cpp
  5. +1
    -0
      src/game/systems/control-system.cpp
  6. +6
    -0
      src/game/systems/control-system.hpp
  7. +2
    -2
      src/game/systems/tool-system.cpp

+ 0
- 1
src/application.cpp View File

@ -17,7 +17,6 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "animation/frame-scheduler.hpp"
#include "application.hpp"
#include "debug/logger.hpp"

+ 9
- 0
src/game/bootloader.cpp View File

@ -770,6 +770,7 @@ void setup_entities(game_context* ctx)
ctx->lens_entity = ctx->ecs_registry->create();
ctx->marker_entity = ctx->ecs_registry->create();
ctx->container_entity = ctx->ecs_registry->create();
ctx->twig_entity = ctx->ecs_registry->create();
ctx->focal_point_entity = ctx->ecs_registry->create();
}
@ -1015,6 +1016,7 @@ void setup_controls(game_context* ctx)
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_lens_control(), nullptr, scancode::three));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_marker_control(), nullptr, scancode::four));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_container_control(), nullptr, scancode::five));
ctx->input_event_router->add_mapping(key_mapping(ctx->control_system->get_equip_twig_control(), nullptr, scancode::six));
ctx->input_event_router->add_mapping(mouse_button_mapping(ctx->control_system->get_use_tool_control(), nullptr, 1));
ctx->control_system->get_use_tool_control()->set_activated_callback
@ -1067,6 +1069,13 @@ void setup_controls(game_context* ctx)
ctx->tool_system->set_active_tool(ctx->container_entity);
}
);
ctx->control_system->get_equip_twig_control()->set_activated_callback
(
[ctx]()
{
ctx->tool_system->set_active_tool(ctx->twig_entity);
}
);
event_dispatcher->subscribe<mouse_moved_event>(ctx->control_system);
event_dispatcher->subscribe<mouse_moved_event>(ctx->camera_system);

+ 1
- 0
src/game/game-context.hpp View File

@ -214,6 +214,7 @@ struct game_context
entt::entity lens_entity;
entt::entity marker_entity;
entt::entity container_entity;
entt::entity twig_entity;
entt::entity focal_point_entity;
// Systems

+ 3
- 0
src/game/states/play-state.cpp View File

@ -82,6 +82,7 @@ void play_state_enter(game_context* ctx)
ecs::archetype* brush_archetype = resource_manager->load<ecs::archetype>("brush.ent");
ecs::archetype* marker_archetype = resource_manager->load<ecs::archetype>("marker.ent");
ecs::archetype* container_archetype = resource_manager->load<ecs::archetype>("container.ent");
ecs::archetype* twig_archetype = resource_manager->load<ecs::archetype>("twig.ent");
ecs::archetype* larva_archetype = resource_manager->load<ecs::archetype>("larva.ent");
ecs::archetype* pebble_archetype = resource_manager->load<ecs::archetype>("pebble.ent");
ecs::archetype* flashlight_archetype = resource_manager->load<ecs::archetype>("flashlight.ent");
@ -94,6 +95,7 @@ void play_state_enter(game_context* ctx)
brush_archetype->assign(ecs_registry, ctx->brush_entity);
marker_archetype->assign(ecs_registry, ctx->marker_entity);
container_archetype->assign(ecs_registry, ctx->container_entity);
twig_archetype->assign(ecs_registry, ctx->twig_entity);
// Create flashlight and light cone, set light cone parent to flashlight, and move both to underworld scene
flashlight_archetype->assign(ecs_registry, ctx->flashlight_entity);
@ -121,6 +123,7 @@ void play_state_enter(game_context* ctx)
ec::assign_render_layers(ecs_registry, ctx->lens_entity, 0);
ec::assign_render_layers(ecs_registry, ctx->marker_entity, 0);
ec::assign_render_layers(ecs_registry, ctx->container_entity, 0);
ec::assign_render_layers(ecs_registry, ctx->twig_entity, 0);
// Activate lens tool
ctx->tool_system->set_active_tool(ctx->lens_entity);

+ 1
- 0
src/game/systems/control-system.cpp View File

@ -56,6 +56,7 @@ control_system::control_system(entt::registry& registry):
control_set.add_control(&equip_forceps_control);
control_set.add_control(&equip_marker_control);
control_set.add_control(&equip_container_control);
control_set.add_control(&equip_twig_control);
control_set.add_control(&use_tool_control);
// Set deadzone at 15% for all controls

+ 6
- 0
src/game/systems/control-system.hpp View File

@ -76,6 +76,7 @@ public:
control* get_equip_forceps_control();
control* get_equip_marker_control();
control* get_equip_container_control();
control* get_equip_twig_control();
control* get_use_tool_control();
private:
@ -103,6 +104,7 @@ private:
control equip_forceps_control;
control equip_marker_control;
control equip_container_control;
control equip_twig_control;
control use_tool_control;
float zoom_speed;
@ -243,6 +245,10 @@ inline control* control_system::get_equip_container_control()
return &equip_container_control;
}
inline control* control_system::get_equip_twig_control()
{
return &equip_twig_control;
}
inline control* control_system::get_use_tool_control()
{

+ 2
- 2
src/game/systems/tool-system.cpp View File

@ -146,7 +146,7 @@ void tool_system::update(double t, double dt)
}
// Determine target hand angle
hand_angle_spring.x1 = math::pi<float> - std::min<float>(0.5f, std::max<float>(-0.5f, ((mouse_position[0] / viewport[2]) - 0.5f) * 1.0f)) * (math::pi<float>);
hand_angle_spring.x1 = -std::min<float>(0.5f, std::max<float>(-0.5f, ((mouse_position[0] / viewport[2]) - 0.5f) * 1.0f)) * (math::pi<float>);
// Solve springs
solve_numeric_spring<float, float>(hand_angle_spring, dt);
@ -176,7 +176,7 @@ void tool_system::update(double t, double dt)
// Interpolate between left and right hand
math::quaternion<float> hand_rotation = math::angle_axis(orbit_cam->get_azimuth() + hand_angle_spring.x0, float3{0, 1, 0});
math::quaternion<float> tilt_rotation = math::angle_axis(-orbit_cam->get_elevation(), float3{-1.0f, 0.0f, 0.0f});
math::quaternion<float> tilt_rotation = math::angle_axis(orbit_cam->get_elevation(), float3{-1.0f, 0.0f, 0.0f});
if (tool.heliotropic)
{

Loading…
Cancel
Save