source: trunk/src/entity.cpp @ 2817

Last change on this file since 2817 was 2817, checked in by sam, 8 years ago

ticker: replace linked lists wih dynamic arrays for entity groups.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 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://www.wtfpl.net/ 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    m_initstate(InitState::Ready),
28    m_ref(0),
29    m_destroy(0)
30{
31#if !LOL_BUILD_RELEASE
32    m_tickstate = STATE_IDLE;
33#endif
34    m_gamegroup = GAMEGROUP_DEFAULT;
35    m_drawgroup = DRAWGROUP_DEFAULT;
36    Ticker::Register(this);
37}
38
39Entity::~Entity()
40{
41#if !LOL_BUILD_RELEASE
42    if (!m_destroy)
43        Log::Error("entity destructor called directly\n");
44#endif
45}
46
47char const *Entity::GetName()
48{
49    return "<entity>";
50}
51
52void Entity::InitGame()
53{
54}
55
56void Entity::InitDraw()
57{
58}
59
60void Entity::TickGame(float seconds)
61{
62    UNUSED(seconds);
63#if !LOL_BUILD_RELEASE
64    if (m_tickstate != STATE_PRETICK_GAME)
65        Log::Error("invalid entity game tick\n");
66    m_tickstate = STATE_POSTTICK_GAME;
67#endif
68}
69
70void Entity::TickDraw(float seconds)
71{
72    (void)seconds;
73#if !LOL_BUILD_RELEASE
74    if (m_tickstate != STATE_PRETICK_DRAW)
75        Log::Error("invalid entity draw tick\n");
76    m_tickstate = STATE_POSTTICK_DRAW;
77#endif
78}
79
80void Entity::SetState(uint32_t state)
81{
82    Ticker::SetState(this, state);
83}
84
85void Entity::SetStateWhenMatch(uint32_t state,
86                               Entity *other_entity, uint32_t other_state)
87{
88    Ticker::SetStateWhenMatch(this, state, other_entity, other_state);
89}
90
91} /* namespace lol */
92
Note: See TracBrowser for help on using the repository browser.