source: trunk/src/entity.cpp @ 1106

Last change on this file since 1106 was 1106, checked in by sam, 9 years ago

core: try to merge Ticker and Emcee. Still not very good.

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstdlib>
16
17#include "core.h"
18
19namespace lol
20{
21
22/*
23 * Public Entity class
24 */
25
26Entity::Entity() :
27    gamenext(0),
28    drawnext(0),
29    ref(0),
30    destroy(0)
31{
32#if !LOL_RELEASE
33    state = STATE_IDLE;
34#endif
35    gamegroup = GAMEGROUP_DEFAULT;
36    drawgroup = DRAWGROUP_DEFAULT;
37    Ticker::Register(this);
38}
39
40Entity::~Entity()
41{
42#if !LOL_RELEASE
43    if (!destroy)
44        Log::Error("entity destructor called directly\n");
45#endif
46}
47
48char const *Entity::GetName()
49{
50    return "<entity>";
51}
52
53void Entity::TickGame(float deltams)
54{
55#if !LOL_RELEASE
56    if (state != STATE_PRETICK_GAME)
57        Log::Error("invalid entity game tick\n");
58    state = STATE_POSTTICK_GAME;
59#endif
60}
61
62void Entity::TickDraw(float deltams)
63{
64#if !LOL_RELEASE
65    if (state != STATE_PRETICK_DRAW)
66        Log::Error("invalid entity draw tick\n");
67    state = STATE_POSTTICK_DRAW;
68#endif
69}
70
71void Entity::SetState(uint32_t state)
72{
73    Ticker::SetState(this, state);
74}
75
76void Entity::SetStateWhenMatch(uint32_t state,
77                               Entity *other_entity, uint32_t other_state)
78{
79    Ticker::SetStateWhenMatch(this, state, other_entity, other_state);
80}
81
82} /* namespace lol */
83
Note: See TracBrowser for help on using the repository browser.