46 |
{ |
{ |
47 |
class RotatorStone : public Stone, public TimeHandler { |
class RotatorStone : public Stone, public TimeHandler { |
48 |
public: |
public: |
49 |
RotatorStone(bool clockwise) |
RotatorStone(bool clockwise_, bool movable_) |
50 |
: Stone(clockwise ? "st-rotator-right" : "st-rotator-left"), |
: Stone("st-rotator"), clockwise(clockwise_), movable(movable_) |
|
m_clockwise(clockwise) |
|
51 |
{} |
{} |
52 |
|
|
53 |
private: |
private: |
54 |
static const double RATE = 1.0; |
static const double RATE = 1.0; |
55 |
static const double IMPULSE_DELAY = 0.1; |
static const double IMPULSE_DELAY = 0.1; |
56 |
|
|
57 |
bool m_clockwise; |
bool clockwise; |
58 |
|
bool movable; |
59 |
|
|
60 |
Stone *clone() { return new RotatorStone(m_clockwise); } |
Stone *clone() { return new RotatorStone(clockwise, movable); } |
61 |
void dispose() { delete this; } |
void dispose() { delete this; } |
62 |
|
|
63 |
void on_creation() { |
void on_creation() { |
72 |
void alarm() { |
void alarm() { |
73 |
GridPos p = get_pos(); |
GridPos p = get_pos(); |
74 |
|
|
75 |
if (m_clockwise) { |
if (clockwise) { |
76 |
send_impulse (move(p, NORTH), EAST, IMPULSE_DELAY); |
send_impulse (move(p, NORTH), EAST, IMPULSE_DELAY); |
77 |
send_impulse (move(p, EAST), SOUTH, IMPULSE_DELAY); |
send_impulse (move(p, EAST), SOUTH, IMPULSE_DELAY); |
78 |
send_impulse (move(p, SOUTH), WEST, IMPULSE_DELAY); |
send_impulse (move(p, SOUTH), WEST, IMPULSE_DELAY); |
85 |
} |
} |
86 |
} |
} |
87 |
|
|
88 |
void actor_hit (const StoneContact &/*sc*/) { |
void init_model() { |
89 |
|
set_anim(clockwise ? "st-rotator-right" : "st-rotator-left"); |
90 |
|
} |
91 |
|
|
92 |
|
void actor_hit (const StoneContact &sc) { |
93 |
|
if (wielded_item_is(sc.actor, "it-wrench")) { |
94 |
|
clockwise = !clockwise; |
95 |
|
init_model(); |
96 |
|
} |
97 |
|
|
98 |
|
if (movable) |
99 |
|
maybe_push_stone(sc); |
100 |
|
} |
101 |
|
|
102 |
|
void on_impulse(const Impulse& impulse) { |
103 |
|
if (movable) |
104 |
|
move_stone(impulse.dir); |
105 |
} |
} |
106 |
}; |
}; |
107 |
} |
} |
583 |
if (state == FALLING) |
if (state == FALLING) |
584 |
return; |
return; |
585 |
|
|
586 |
if (impulse.sender && 0 == strncmp(impulse.sender->get_kind(), "st-rotator-", 11)) { |
// if (impulse.sender && 0 == strncmp(impulse.sender->get_kind(), "st-rotator-", 11)) { |
587 |
|
if (impulse.sender && impulse.sender->is_kind("st-rotator")) { |
588 |
set_dir(impulse.dir); |
set_dir(impulse.dir); |
589 |
} |
} |
590 |
init_model(); |
init_model(); |
2815 |
Register("st-bigbrick-esw", new BigBrick(8)); |
Register("st-bigbrick-esw", new BigBrick(8)); |
2816 |
Register("st-bigbrick-nesw", new BigBrick(16)); |
Register("st-bigbrick-nesw", new BigBrick(16)); |
2817 |
|
|
2818 |
Register (new RotatorStone (true)); |
Register ("st-rotator-right", new RotatorStone(true, false)); |
2819 |
Register (new RotatorStone (false)); |
Register ("st-rotator-left", new RotatorStone(false, false)); |
2820 |
|
Register ("st-rotator_move-right", new RotatorStone(true, true)); |
2821 |
|
Register ("st-rotator_move-left", new RotatorStone(false, true)); |
2822 |
|
|
2823 |
Register(new ShogunStone); |
Register(new ShogunStone); |
2824 |
Register("st-shogun-s", new ShogunStone(1)); |
Register("st-shogun-s", new ShogunStone(1)); |