2
* Copyright (C) 2002,2003,2004 Daniel Heck
4
* This program is free software; you can redistribute it and/ or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18
* $Id: stones_internal.hh,v 1.9 2004/03/18 18:09:24 dheck Exp $
20
#ifndef STONES_INTERNAL_HH_INCLUDED
21
#define STONES_INTERNAL_HH_INCLUDED
26
static StoneTraits traits; \
27
const StoneTraits &get_traits() const { return traits; }
29
#define DECL_TRAITS_ARRAY(n, subtype_expr) \
30
static StoneTraits traits[n]; \
31
const StoneTraits &get_traits() const { return traits[subtype_expr]; }
33
#define DEF_TRAITS(classname, name, id) \
34
StoneTraits classname::traits = { name, id, stf_none, material_stone, 1.0 }
40
using namespace world;
46
/* -------------------- Auxiliary Functions -------------------- */
48
Direction get_push_direction (const StoneContact &sc);
50
/* Move a stone (by sending an impulse) Called when actor hits a
52
bool maybe_push_stone (const StoneContact &sc);
54
/* -------------------- YieldedGridStone -------------------- */
56
// allows to completely remove a Stone and its model
59
// - "delays" animation
61
// @@@ FIXME: alarms have to be disabled as well
63
class YieldedGridStone {
65
display::Model *model;
67
YieldedGridStone(const YieldedGridStone&);
68
YieldedGridStone& operator = (const YieldedGridStone&);
71
YieldedGridStone(Stone *st);
74
void set_stone(enigma::GridPos pos);
78
/* -------------------- OnOffStone -------------------- */
80
/*! Base class for all stones that can be on and off. Understands
81
the messages "on", "off", and "onoff". Whenever the "on"
82
attribute changes, the object's init_model() method is invoked */
83
class OnOffStone : public Stone {
85
OnOffStone(const char *kind)
88
set_attrib("on", 0.0);
92
return int_attrib("on") == 1;
95
virtual void set_on(bool newon) {
96
if (newon != is_on()) {
97
set_attrib("on", enigma::Value(newon));
103
virtual void notify_onoff(bool /*on*/) {}
105
void on_message(const world::Message &msg)
107
const std::string &m = msg.message;
110
else if (m=="signal")
111
set_on (to_int(msg.value) != 0);