2019-07-21 08:51:47 +02:00
|
|
|
/*
|
2019-10-04 05:04:12 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2019-07-21 08:51:47 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
|
|
|
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
|
|
|
|
*/
|
|
|
|
|
2021-08-12 23:09:01 +02:00
|
|
|
#pragma once
|
2019-07-21 08:51:47 +02:00
|
|
|
#include "taisei.h"
|
|
|
|
|
|
|
|
#include "coroutine.h"
|
|
|
|
#include "item.h"
|
2019-09-01 02:23:36 +02:00
|
|
|
#include "move.h"
|
|
|
|
#include "entity.h"
|
2019-10-28 16:16:16 +01:00
|
|
|
#include "global.h"
|
2021-01-30 20:27:14 +01:00
|
|
|
#include "util/glm.h"
|
2019-07-21 08:51:47 +02:00
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_drop_items,
|
2019-12-18 15:19:13 +01:00
|
|
|
{ cmplx *pos; ItemCounts items; }
|
2019-07-21 08:51:47 +02:00
|
|
|
);
|
|
|
|
|
2019-09-01 02:23:36 +02:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_move,
|
2019-12-18 15:19:13 +01:00
|
|
|
{ cmplx *pos; MoveParams move_params; BoxedEntity ent; }
|
2019-09-01 02:23:36 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_move_ext,
|
2019-12-18 15:19:13 +01:00
|
|
|
{ cmplx *pos; MoveParams *move_params; BoxedEntity ent; }
|
2019-09-01 02:23:36 +02:00
|
|
|
);
|
|
|
|
|
2019-12-05 17:45:32 +01:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_call_func,
|
|
|
|
{ void (*func)(void); }
|
|
|
|
);
|
|
|
|
|
2020-01-23 01:23:35 +01:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_start_bgm,
|
|
|
|
{ const char *bgm; }
|
|
|
|
);
|
|
|
|
|
2020-09-30 02:44:58 +02:00
|
|
|
#define COMMON_CHARGE_SOUND_CHARGE "charge_generic"
|
|
|
|
#define COMMON_CHARGE_SOUND_DISCHARGE "discharge"
|
|
|
|
#define COMMON_CHARGE_SOUNDS { COMMON_CHARGE_SOUND_CHARGE, COMMON_CHARGE_SOUND_DISCHARGE }
|
|
|
|
|
2020-03-01 17:38:54 +01:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_charge,
|
|
|
|
{
|
|
|
|
cmplx pos;
|
|
|
|
const Color *color;
|
|
|
|
int time;
|
|
|
|
BoxedEntity bind_to_entity;
|
|
|
|
const cmplx *anchor;
|
|
|
|
const Color *color_ref;
|
2020-03-02 17:38:53 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
const char *charge;
|
|
|
|
const char *discharge;
|
|
|
|
} sound;
|
2020-03-01 17:38:54 +01:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-05-06 20:31:56 +02:00
|
|
|
void common_drop_items(cmplx pos, const ItemCounts *items)
|
|
|
|
attr_nonnull(2);
|
|
|
|
|
2020-09-30 02:44:58 +02:00
|
|
|
int common_charge(int time, const cmplx *anchor, cmplx offset, const Color *color)
|
|
|
|
attr_nonnull(2, 4);
|
|
|
|
|
|
|
|
int common_charge_static(int time, cmplx pos, const Color *color)
|
|
|
|
attr_nonnull(3);
|
|
|
|
|
|
|
|
int common_charge_custom(
|
|
|
|
int time,
|
|
|
|
const cmplx *anchor,
|
|
|
|
cmplx offset,
|
|
|
|
const Color *color,
|
|
|
|
const char *snd_charge,
|
|
|
|
const char *snd_discharge
|
|
|
|
) attr_nonnull(4);
|
2020-03-02 17:38:53 +01:00
|
|
|
|
2019-12-05 17:45:32 +01:00
|
|
|
void common_move_loop(cmplx *restrict pos, MoveParams *restrict mp);
|
2019-09-01 02:23:36 +02:00
|
|
|
|
2019-09-02 18:09:09 +02:00
|
|
|
INLINE Rect viewport_bounds(double margin) {
|
|
|
|
return (Rect) {
|
|
|
|
.top_left = CMPLX(margin, margin),
|
|
|
|
.bottom_right = CMPLX(VIEWPORT_W - margin, VIEWPORT_H - margin),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-18 15:19:13 +01:00
|
|
|
cmplx common_wander(cmplx origin, double dist, Rect bounds);
|
2022-09-24 02:22:40 +02:00
|
|
|
void common_rotate_velocity(MoveParams *move, real angle, int duration);
|
2019-09-02 18:09:09 +02:00
|
|
|
|
2020-04-06 03:29:11 +02:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_set_bitflags,
|
|
|
|
{
|
|
|
|
uint *pflags;
|
|
|
|
uint mask;
|
|
|
|
uint set;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-12-01 18:25:00 +01:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_kill_projectile,
|
|
|
|
{
|
|
|
|
BoxedProjectile proj;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_kill_enemy,
|
|
|
|
{
|
|
|
|
BoxedEnemy enemy;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-01-30 20:27:14 +01:00
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_easing_animate,
|
2021-10-20 22:49:09 +02:00
|
|
|
{
|
2021-01-30 20:27:14 +01:00
|
|
|
float *value;
|
|
|
|
float to;
|
|
|
|
int duration;
|
|
|
|
glm_ease_t ease;
|
|
|
|
}
|
|
|
|
);
|
2021-10-20 22:49:09 +02:00
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_easing_animate_vec3,
|
|
|
|
{
|
|
|
|
vec3 *value;
|
|
|
|
vec3 to;
|
|
|
|
int duration;
|
|
|
|
glm_ease_t ease;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_easing_animate_vec4,
|
|
|
|
{
|
|
|
|
vec4 *value;
|
|
|
|
vec4 to;
|
|
|
|
int duration;
|
|
|
|
glm_ease_t ease;
|
|
|
|
}
|
|
|
|
);
|
2022-09-24 02:22:40 +02:00
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_rotate_velocity,
|
|
|
|
{
|
|
|
|
MoveParams *move;
|
|
|
|
real angle;
|
|
|
|
int duration;
|
|
|
|
}
|
|
|
|
);
|
2023-02-06 07:40:24 +01:00
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(
|
|
|
|
common_easing_animated,
|
|
|
|
{
|
|
|
|
double *value;
|
|
|
|
double to;
|
|
|
|
int duration;
|
|
|
|
glm_ease_t ease;
|
|
|
|
}
|
|
|
|
);
|
2023-05-25 03:53:49 +02:00
|
|
|
|
|
|
|
DECLARE_EXTERN_TASK(common_play_sfx, { const char *name; });
|
2023-08-20 15:44:11 +02:00
|
|
|
|
|
|
|
// TODO: move this elsewhere?
|
|
|
|
|
|
|
|
typedef struct RadialLoop {
|
|
|
|
cmplx dir, turn;
|
|
|
|
int cnt, i;
|
|
|
|
} RadialLoop;
|
|
|
|
|
|
|
|
INLINE RadialLoop _radial_loop_init(int cnt, cmplx dir) {
|
|
|
|
return (RadialLoop) {
|
|
|
|
.dir = dir,
|
|
|
|
.cnt = abs(cnt),
|
|
|
|
.turn = cdir(M_TAU/cnt),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RADIAL_LOOP(_loop_var, _cnt_init, _dir_init) \
|
|
|
|
for( \
|
|
|
|
RadialLoop _loop_var = _radial_loop_init(_cnt_init, _dir_init); \
|
|
|
|
_loop_var.i < _loop_var.cnt; \
|
|
|
|
++_loop_var.i, _loop_var.dir *= _loop_var.turn)
|