39 void steer_controlled_ant(::
game& ctx)
61 float control_magnitude = 0.0f;
65 control_direction = control_vector / control_magnitude;
69 const auto clamped_control_magnitude =
std::min(1.0f, control_magnitude);
72 float locomotive_speed;
86 locomotive_speed = caste_phenome.legs->walking_speed;
90 locomotive_speed *= clamped_control_magnitude;
94 locomotive_speed *= rigid_body.get_scale().x();
96 locomotion.speed = locomotive_speed;
97 locomotion.angular_velocity = 0.0f;
107 const auto spring_arm_yaw_rotation =
math::angle_axis(spring_arm.angles_spring.get_value().y(), {0.0, 1.0, 0.0});
108 locomotion.target_direction =
math::fquat(
math::normalize(spring_arm.up_rotation * spring_arm_yaw_rotation)) *
math::fvec3{control_direction.
x(), 0.0f, (spring_arm.angles_spring.get_value().x() > 0.0) ? -control_direction.y() : control_direction.y()};
117 void turn_controlled_ant(::
game& ctx,
float scale)
142 [&](
const auto&
event)
144 steer_controlled_ant(ctx);
152 [&](
const auto&
event)
154 steer_controlled_ant(ctx);
164 [&](
const auto&
event)
166 steer_controlled_ant(ctx);
174 [&](
const auto&
event)
176 steer_controlled_ant(ctx);
186 [&](
const auto&
event)
188 steer_controlled_ant(ctx);
196 [&](
const auto&
event)
198 steer_controlled_ant(ctx);
208 [&](
const auto&
event)
210 steer_controlled_ant(ctx);
218 [&](
const auto&
event)
220 steer_controlled_ant(ctx);
230 [&](
const auto&
event)
232 if (ctx.active_camera_eid == entt::null)
239 camera_object.set_layer_mask(camera_object.get_layer_mask() == 1 ? 2 : 1);
249 [&](
const auto&
event)
251 if (ctx.controlled_ant_eid == entt::null)
258 ovary_component->ovipositing = true;
267 [&](
const auto&
event)
269 if (ctx.controlled_ant_eid == entt::null)
276 ovary_component->ovipositing = false;
void disable_ant_controls(::game &ctx)
void enable_ant_controls(::game &ctx)
void setup_ant_controls(::game &ctx)
input::action ant_move_fast_action
input::action ant_move_back_action
input::action ant_oviposit_action
entity::id active_camera_eid
input::action ant_interact_action
input::action_map ant_action_map
input::action ant_move_slow_action
std::vector< std::shared_ptr<::event::subscription > > event_subscriptions
input::action ant_move_right_action
input::action ant_move_forward_action
entity::id controlled_ant_eid
std::unique_ptr< entity::registry > entity_registry
input::action ant_move_left_action
Publish-subscribe messaging.
quat< float > fquat
Quaternion with single-precision floating-point scalars.
quaternion< T > normalize(const quaternion< T > &q)
Normalizes a quaternion.
quaternion< T > angle_axis(T angle, const vec3< T > &axis)
Creates a rotation from an angle and axis.
constexpr T radians(T degrees) noexcept
Converts an angle given in degrees to radians.
constexpr T sqr_length(const quaternion< T > &q) noexcept
Calculates the square length of a quaternion.
constexpr mat4< T > scale(const vec3< T > &v)
Constructs a scale matrix.
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
constexpr T lerp(const T &x, const T &y, S a) noexcept
Linearly interpolates between x and y.
constexpr vector< T, N > min(const vector< T, N > &x, const vector< T, N > &y)
Returns a vector containing the minimum elements of two vectors.
Legged terrestrial locomotion.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.
std::shared_ptr< scene::object_base > object
Attaches a camera to an entity using springs.