Mercurial > molko
comparison libmlk-core/mlk/core/action.c @ 431:8f59201dc76b
core: cleanup hierarchy
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 15 Oct 2022 20:23:14 +0200 |
parents | src/libmlk-core/core/action.c@460c78706989 |
children | 31c1bbc33813 |
comparison
equal
deleted
inserted
replaced
430:1645433e008d | 431:8f59201dc76b |
---|---|
1 /* | |
2 * action.c -- action states | |
3 * | |
4 * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #include <assert.h> | |
20 | |
21 #include "action.h" | |
22 | |
23 void | |
24 action_handle(struct action *act, const union event *ev) | |
25 { | |
26 assert(act); | |
27 assert(ev); | |
28 | |
29 if (act->handle) | |
30 act->handle(act, ev); | |
31 } | |
32 | |
33 int | |
34 action_update(struct action *act, unsigned int ticks) | |
35 { | |
36 assert(act); | |
37 | |
38 if (act->update) | |
39 return act->update(act, ticks); | |
40 | |
41 /* No function means immortal action. */ | |
42 return 0; | |
43 } | |
44 | |
45 void | |
46 action_draw(struct action *act) | |
47 { | |
48 assert(act); | |
49 | |
50 if (act->draw) | |
51 act->draw(act); | |
52 } | |
53 | |
54 void | |
55 action_end(struct action *act) | |
56 { | |
57 assert(act); | |
58 | |
59 if (act->end) | |
60 act->end(act); | |
61 } | |
62 | |
63 void | |
64 action_finish(struct action *act) | |
65 { | |
66 assert(act); | |
67 | |
68 if (act->finish) | |
69 act->finish(act); | |
70 } |