taisei/src/common_tasks.h

189 lines
3.4 KiB
C
Raw Normal View History

/*
2019-10-04 05:04:12 +02:00
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#pragma once
#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"
DECLARE_EXTERN_TASK(
common_drop_items,
2019-12-18 15:19:13 +01:00
{ cmplx *pos; ItemCounts items; }
);
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); }
);
DECLARE_EXTERN_TASK(
common_start_bgm,
{ const char *bgm; }
);
#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
}
);
void common_drop_items(cmplx pos, const ItemCounts *items)
attr_nonnull(2);
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);
void common_rotate_velocity(MoveParams *move, real angle, int duration);
2019-09-02 18:09:09 +02:00
DECLARE_EXTERN_TASK(
common_set_bitflags,
{
uint *pflags;
uint mask;
uint set;
}
);
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-01-30 20:27:14 +01:00
float *value;
float to;
int duration;
glm_ease_t ease;
}
);
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;
}
);
DECLARE_EXTERN_TASK(
common_rotate_velocity,
{
MoveParams *move;
real angle;
int duration;
}
);
stage6: port to coroutine system (WIP) Closes #323 Mostly faithful to the original with a few changes. Needs a design iteration. Squashed commit of the following: commit 17232ad79789b12d115847f838ad6206b7224ec3 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 07:14:12 2023 +0100 stage6: fix uninitialized variable commit 46f7345d005b8eeb5fb77e3baaf5495209a7b9c3 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 06:57:10 2023 +0100 stage6: fix warnings commit 2c5ebc1f6c290bda34050b4a49cde88968667374 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 06:49:07 2023 +0100 stage6: fix ricci grace period commit f43e1069d565cdc427ae5e0e8c8f5cce4aa85544 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 06:48:56 2023 +0100 stage6: formatting (ricci) commit d6c21a7e457ba13a622d7e87cb36b70aff0c32ba Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 06:38:41 2023 +0100 stage6: remove dead code commit 8cc8bc33588c747eb4a1d6c0854aa2b5f5b54169 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 06:38:27 2023 +0100 stage6: fix spell practice background commit 555feafccf82c175ca78c32e3db8126ff9b20a5b Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 01:59:43 2023 +0100 stage6: adjust elly's pre-ToE movement commit c0e71ccf92ef0b56b48852fc00ec62fa2180cb09 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 01:55:58 2023 +0100 stage6: enable pre-ToE dialogue commit 0902897b5ac1bc686f3cec9c10a9f6fc35eb4701 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 01:24:49 2023 +0100 stage6: fix spell practice commit b4bd0c590226c5a1dbe36c24275a2fd53b31f59a Author: Andrei Alexeyev <akari@taisei-project.org> Date: Mon Feb 6 01:24:33 2023 +0100 stage6: fix broglie issues commit 115c90273f1e600efd1e6796019c7adb50b27fb6 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sun Feb 5 03:49:00 2023 +0100 stage6: formatting commit f0b564a2903d3b485e6358ba6c7a69a75df9033c Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sun Feb 5 03:47:16 2023 +0100 stage6: fix a bunch of scythe-related issues commit 8fcfb57080622155d2fb71da990369f14802cd33 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sun Feb 5 03:47:46 2023 +0100 stage6: define MAX_BARYON_PARTICLES commit ff68532f9f43f2459eb0952e1d17046cf450bb34 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sat Feb 4 07:00:50 2023 +0100 stage6: reset baryon target pos after attack commit bb49d60a794161f5aa8bd07321c20b103e7db8b0 Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sat Feb 4 06:32:55 2023 +0100 stage6: more optimal draw order for baryon effect commit 3230d378c1758abeeee11430c7b22d2881705fff Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sat Feb 4 06:19:00 2023 +0100 stage6: port baryon background effect commit bf3df74eda0bb0ad8c9471196d3d5848b45ba5ba Author: Andrei Alexeyev <akari@taisei-project.org> Date: Sat Feb 4 04:35:49 2023 +0100 stage6: fix scythe and baryon visuals not spinning commit 2492711a00529c9af335b96fea6a5c1369318421 Author: Alice D <alice@starwitch.productions> Date: Sat Feb 12 18:38:55 2022 -0500 fix merge and compile issues, make stage end correctly commit 4b04855932651526edd5b092b5e78a70a1149652 Author: laochailan <laochailan@web.de> Date: Sat Sep 25 08:40:47 2021 +0200 kepler: remove shadowing commit 657345cce6eebf732c3b575f1b224d6f6409357d Author: laochailan <laochailan@web.de> Date: Sat Sep 25 08:39:24 2021 +0200 move and rename scythe_nonspell_common task commit 6a58fea71851385678aa28b93775ac870b08d101 Author: laochailan <laochailan@web.de> Date: Sat Sep 25 08:34:33 2021 +0200 solve strange bug commit 54df567170919dd06b9e9aab6513d4605f4ea89e Author: laochailan <laochailan@web.de> Date: Sat Sep 25 08:21:36 2021 +0200 trigger weird bug in collision code by accident commit 0bd3ceb9ac2c4c19ab87be8c48439d177d6116e6 Author: laochailan <laochailan@web.de> Date: Sat Sep 25 08:06:08 2021 +0200 scythe and baryon logic loose ends commit b4596a773e43b23573290ec6026479267d7a1c03 Author: laochailan <laochailan@web.de> Date: Fri Sep 24 18:01:45 2021 +0200 toe port commit bc9137393c2fdbe8d464cb728188e7cd263c6054 Author: laochailan <laochailan@web.de> Date: Fri Sep 24 16:23:29 2021 +0200 wip toe port: pretty much all but the lasers commit 60fd678d631cecf509b9f5bd6c8228ac4708af88 Author: laochailan <laochailan@web.de> Date: Thu Sep 23 20:37:32 2021 +0200 wip toe port (only top level) commit e14a35ed0545f07cd4bb1da4e60d116abaebc48a Author: laochailan <laochailan@web.de> Date: Thu Sep 23 17:04:18 2021 +0200 forgotten port commit 0cb56aee4c23b60d0396a9ae5ecf009d213998c0 Author: laochailan <laochailan@web.de> Date: Thu Sep 23 14:34:51 2021 +0200 baryons_explode port commit c589a79bbf82d3a3694ca0b289cb9991c4e11f89 Author: laochailan <laochailan@web.de> Date: Thu Sep 23 09:04:01 2021 +0200 nonspell 5 port commit aac688112fcaf4849b5bf3df1f1bac9c5ca23c7f Author: laochailan <laochailan@web.de> Date: Thu Sep 23 08:46:27 2021 +0200 ricci: remove obsolete commandments commit 146d591b4c4146d3be3562941d29ed31fdbcd08f Author: laochailan <laochailan@web.de> Date: Thu Sep 23 08:43:29 2021 +0200 lhc port commit 2146ca342dfadf5e34f0b2d4323bc85e266d7b04 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 22:00:39 2021 +0200 broglie: implement Akari comments commit 0222c67f60ef6e9271916ad57ce35ec4b674dbf5 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 20:24:58 2021 +0200 make ricci thicc commit a04f122e99ae9b9c8c237abcd2ffe1817ea08d55 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 20:12:13 2021 +0200 fix ricci timing and improve laser looks commit d3330ecd215a37f4b32310c177cf66d1904e59b5 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 18:19:29 2021 +0200 wip: ricci but timing still wrong commit 6c2129607ab9b2c4a2c0f25efff3092b113a67af Author: laochailan <laochailan@web.de> Date: Wed Sep 22 16:53:42 2021 +0200 wip: ricci commit 96d6e4499cc4b6908651f3eb4d94cc8e37b5e916 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 16:53:09 2021 +0200 make circle laser turn speed rad/frame commit d943e7ab8828a81312195947587dc932a6a9978e Author: laochailan <laochailan@web.de> Date: Wed Sep 22 16:52:27 2021 +0200 remove smoothreclamp commit 7fbcd8fb43c8dc5e870ea04d1d0d33565ea63491 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 12:17:36 2021 +0200 remove unused code commit a6c8979107414636c58868738416f46931bdf812 Author: laochailan <laochailan@web.de> Date: Wed Sep 22 12:16:06 2021 +0200 modernize broglie sign commit 278bd104d31a31c2fdaf6cf87652d48bce8bc44a Author: laochailan <laochailan@web.de> Date: Wed Sep 1 19:54:00 2021 +0200 first baryon non commit 20a7193de367e66ed01253afee9df61610a2c436 Author: laochailan <laochailan@web.de> Date: Tue Aug 31 22:03:54 2021 +0200 elly eigenstate commit c64ae7c792c9ad16b91b5f76ba9a0686578e5021 Author: laochailan <laochailan@web.de> Date: Sat Aug 28 21:52:09 2021 +0200 elly until baryons spawn commit 3d1a1eae9c8d192ee6c932c5782471bdbbd63433 Author: laochailan <laochailan@web.de> Date: Sun Aug 22 14:54:02 2021 +0200 add double version of common_easing_animate commit 16e6d51851bebb140fb77b06e47f0c3bcef6f06d Author: laochailan <laochailan@web.de> Date: Sat Aug 7 21:52:58 2021 +0200 kepler sign + tweaks commit c460627e41e4568c613bae91010dd86dc20a0a00 Author: laochailan <laochailan@web.de> Date: Thu Aug 5 20:31:15 2021 +0200 newton difficulty scaling commit be97924a536c3ca53ceb6aa366ebc3e649140ed7 Author: laochailan <laochailan@web.de> Date: Wed Aug 4 22:06:30 2021 +0200 newton sign redesign commit 20a4f3b4c74006b6bf7770eef2d2e181b0811f8a Author: laochailan <laochailan@web.de> Date: Mon Aug 2 08:51:36 2021 +0200 first elly non wip commit a2a5fb6ada66b75a27e4e77b842be29c0034998c Author: laochailan <laochailan@web.de> Date: Mon Jul 26 20:23:09 2021 +0200 scythe wip commit ae0eeec1ad293f76f82f2583f35f53222016d9da Author: laochailan <laochailan@web.de> Date: Mon Jul 26 18:16:59 2021 +0200 scythe wip commit f215d330d903da15ccfdb039ee84ef21c1bb5bf8 Author: laochailan <laochailan@web.de> Date: Fri Jul 23 22:18:51 2021 +0200 wip entity scythe commit 66ccf18c634608e8ff5dc209b8abec3a5379c178 Author: laochailan <laochailan@web.de> Date: Sun May 9 14:33:02 2021 +0200 wip spawn elly commit c947f0c3f9208653fb950d43ab99d53acb473039 Author: laochailan <laochailan@web.de> Date: Thu May 6 07:30:53 2021 +0200 modernize scythe mid commit bfae46ed2461415c45297b78f2febe0838269f8f Author: laochailan <laochailan@web.de> Date: Sun May 2 18:15:45 2021 +0200 more or less port flowermine fairy commit 98370ed44b46b5f70d0882ecfc6097a5328d22db Author: laochailan <laochailan@web.de> Date: Sun May 2 15:42:49 2021 +0200 modernized side fairy commit ece28c70f022cb160086ffeac4d9b474d0661faf Author: laochailan <laochailan@web.de> Date: Sun May 2 15:14:08 2021 +0200 modernize hacker fairy Co-authored-by: Andrei Alexeyev <akari@taisei-project.org> Co-authored-by: Alice D <alice@starwitch.productions>
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; });
// 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)