671 |
{ |
{ |
672 |
class OneWayBase : public Stone { |
class OneWayBase : public Stone { |
673 |
protected: |
protected: |
674 |
OneWayBase(const char *kind) : Stone(kind) |
OneWayBase(const char *kind, Direction dir) : Stone(kind) |
675 |
{ |
{ |
676 |
set_orientation(SOUTH); |
set_orientation(dir); |
677 |
} |
} |
678 |
Direction get_orientation() const { |
Direction get_orientation() const { |
679 |
return Direction(int_attrib("orientation")); |
return Direction(int_attrib("orientation")); |
725 |
{ |
{ |
726 |
class OneWayStone : public OneWayBase { |
class OneWayStone : public OneWayBase { |
727 |
public: |
public: |
728 |
OneWayStone() : OneWayBase("st-oneway") {} |
OneWayStone(Direction dir=SOUTH) : OneWayBase("st-oneway", dir) {} |
729 |
private: |
private: |
730 |
CLONEOBJ(OneWayStone); |
CLONEOBJ(OneWayStone); |
731 |
virtual bool actor_may_pass (Actor *a) { return true; } |
virtual bool actor_may_pass (Actor *a) { return true; } |
734 |
|
|
735 |
class OneWayStone_black : public OneWayBase { |
class OneWayStone_black : public OneWayBase { |
736 |
public: |
public: |
737 |
OneWayStone_black() : OneWayBase("st-oneway_black") {} |
OneWayStone_black(Direction dir=SOUTH) |
738 |
|
: OneWayBase("st-oneway_black",dir) {} |
739 |
private: |
private: |
740 |
CLONEOBJ(OneWayStone_black); |
CLONEOBJ(OneWayStone_black); |
741 |
virtual bool actor_may_pass (Actor *a) { |
virtual bool actor_may_pass (Actor *a) { |
745 |
|
|
746 |
class OneWayStone_white : public OneWayBase { |
class OneWayStone_white : public OneWayBase { |
747 |
public: |
public: |
748 |
OneWayStone_white() : OneWayBase("st-oneway_white") {} |
OneWayStone_white(Direction dir=SOUTH) |
749 |
|
: OneWayBase("st-oneway_white", dir) {} |
750 |
private: |
private: |
751 |
CLONEOBJ(OneWayStone_white); |
CLONEOBJ(OneWayStone_white); |
752 |
virtual bool actor_may_pass (Actor *a) { |
virtual bool actor_may_pass (Actor *a) { |
2749 |
//---------------------------------------- |
//---------------------------------------- |
2750 |
namespace |
namespace |
2751 |
{ |
{ |
2752 |
class StoneImpulseStone : public Stone { |
class StoneImpulse_Base : public Stone { |
2753 |
CLONEOBJ(StoneImpulseStone); |
protected: |
2754 |
public: |
StoneImpulse_Base(const char *kind) : Stone(kind), state(IDLE) |
2755 |
StoneImpulseStone() : Stone("st-stoneimpulse"), state(IDLE) {} |
{} |
2756 |
private: |
|
2757 |
enum State { IDLE, PULSING, CLOSING, BROKEN }; |
enum State { IDLE, PULSING, CLOSING }; |
2758 |
State state; |
State state; |
2759 |
|
|
2760 |
void stoneimpulse() { |
void change_state(State st); |
|
if (state == IDLE) { |
|
|
play_sound("impulse"); |
|
|
set_anim("st-stoneimpulse-anim1"); |
|
|
state = PULSING; |
|
|
} |
|
|
} |
|
|
void animcb() { |
|
|
if (state == PULSING) { |
|
|
state = CLOSING; |
|
|
GridPos p = get_pos(); |
|
2761 |
|
|
2762 |
MaybeMoveStone (move(p,NORTH), NORTH); |
private: |
|
MaybeMoveStone (move(p,EAST), EAST); |
|
|
MaybeMoveStone (move(p,SOUTH), SOUTH); |
|
|
MaybeMoveStone (move(p,WEST), WEST); |
|
|
|
|
|
SendMessage(GetStone(move(p, NORTH)), "stoneimpulse"); |
|
|
SendMessage(GetStone(move(p, EAST)), "stoneimpulse"); |
|
|
SendMessage(GetStone(move(p, SOUTH)), "stoneimpulse"); |
|
|
SendMessage(GetStone(move(p, WEST)), "stoneimpulse"); |
|
|
set_anim ("st-stoneimpulse-anim2"); |
|
|
} else if (state == CLOSING) { |
|
|
state = IDLE; |
|
|
init_model(); |
|
|
} |
|
|
} |
|
2763 |
|
|
2764 |
void actor_hit(const StoneContact &sc) { |
virtual void notify_state(State st) = 0; |
|
stoneimpulse(); |
|
|
} |
|
|
|
|
|
bool on_laserhit(Direction) { |
|
|
stoneimpulse(); |
|
|
return false; |
|
|
} |
|
2765 |
|
|
2766 |
void message(const string &m, const Value &) { |
void message(const string &m, const Value &) { |
2767 |
if (m=="trigger" || m=="stoneimpulse") |
if (m=="trigger" || m=="stoneimpulse") |
2768 |
stoneimpulse(); |
change_state(PULSING); |
2769 |
|
} |
2770 |
|
|
2771 |
|
void animcb() { |
2772 |
|
if (state == PULSING) |
2773 |
|
change_state (CLOSING); |
2774 |
|
else if (state == CLOSING) |
2775 |
|
change_state (IDLE); |
2776 |
} |
} |
2777 |
}; |
}; |
2778 |
|
|
2779 |
|
} |
2780 |
|
|
2781 |
|
void |
2782 |
|
StoneImpulse_Base::change_state(State st) |
2783 |
|
{ |
2784 |
|
if (st == state) |
2785 |
|
return; |
2786 |
|
|
2787 |
|
GridPos p = get_pos(); |
2788 |
|
switch (st) { |
2789 |
|
case PULSING: |
2790 |
|
play_sound("impulse"); |
2791 |
|
break; |
2792 |
|
case CLOSING: |
2793 |
|
MaybeMoveStone( move( p, NORTH), NORTH); |
2794 |
|
MaybeMoveStone( move( p, EAST), EAST); |
2795 |
|
MaybeMoveStone( move( p, SOUTH), SOUTH); |
2796 |
|
MaybeMoveStone( move( p, WEST), WEST); |
2797 |
|
SendMessage (GetStone(move(p, NORTH)), "stoneimpulse"); |
2798 |
|
SendMessage (GetStone(move(p, EAST)), "stoneimpulse"); |
2799 |
|
SendMessage (GetStone(move(p, SOUTH)), "stoneimpulse"); |
2800 |
|
SendMessage (GetStone(move(p, WEST)), "stoneimpulse"); |
2801 |
|
break; |
2802 |
|
case IDLE: |
2803 |
|
init_model(); |
2804 |
|
break; |
2805 |
|
} |
2806 |
|
state = st; |
2807 |
|
|
2808 |
|
notify_state(state); |
2809 |
} |
} |
2810 |
|
|
2811 |
|
|
2812 |
//---------------------------------------- |
//---------------------------------------- |
2813 |
// Hollow StoneImpulseStone |
// StoneImpulseStone (regular and hollow) |
2814 |
// |
// |
2815 |
// Messages: |
// Messages: |
2816 |
// |
// |
2818 |
//---------------------------------------- |
//---------------------------------------- |
2819 |
namespace |
namespace |
2820 |
{ |
{ |
2821 |
class HollowStoneImpulseStone : public Stone { |
class StoneImpulseStone : public StoneImpulse_Base { |
2822 |
CLONEOBJ(HollowStoneImpulseStone); |
CLONEOBJ(StoneImpulseStone); |
2823 |
public: |
public: |
2824 |
HollowStoneImpulseStone() : Stone("st-stoneimpulse-hollow"), state(IDLE) {} |
StoneImpulseStone() : StoneImpulse_Base("st-stoneimpulse") |
2825 |
|
{} |
2826 |
|
|
2827 |
private: |
private: |
2828 |
enum State { IDLE, PULSING, CLOSING, BROKEN }; |
void notify_state(State st) { |
2829 |
State state; |
if (st == PULSING) set_anim("st-stoneimpulse-anim1"); |
2830 |
|
else if (st==CLOSING) set_anim("st-stoneimpulse-anim2"); |
2831 |
|
} |
2832 |
|
|
2833 |
void stoneimpulse() { |
void actor_hit(const StoneContact &sc) {change_state(PULSING);} |
2834 |
if (state == IDLE) { |
|
2835 |
play_sound("impulse"); |
bool on_laserhit(Direction) { |
2836 |
|
change_state(PULSING); |
2837 |
|
return false; |
2838 |
|
} |
2839 |
|
}; |
2840 |
|
|
2841 |
|
class HollowStoneImpulseStone : public StoneImpulse_Base { |
2842 |
|
CLONEOBJ(HollowStoneImpulseStone); |
2843 |
|
public: |
2844 |
|
HollowStoneImpulseStone() |
2845 |
|
: StoneImpulse_Base("st-stoneimpulse-hollow") {} |
2846 |
|
private: |
2847 |
|
void notify_state(State st) { |
2848 |
|
if (st == PULSING) { |
2849 |
|
laser::MaybeRecalcLight(get_pos()); |
2850 |
set_anim("st-stoneimpulse-hollow-anim1"); |
set_anim("st-stoneimpulse-hollow-anim1"); |
|
state = PULSING; |
|
|
GridPos p = get_pos(); |
|
|
MaybeMoveStone( move( p, NORTH), NORTH); |
|
|
MaybeMoveStone( move( p, EAST), EAST); |
|
|
MaybeMoveStone( move( p, SOUTH), SOUTH); |
|
|
MaybeMoveStone( move( p, WEST), WEST); |
|
2851 |
} |
} |
2852 |
} |
else if (st==CLOSING) |
|
void animcb() { |
|
|
if (state == PULSING) { |
|
|
state = CLOSING; |
|
|
GridPos p = get_pos(); |
|
|
SendMessage(GetStone(move(p, NORTH)), "stoneimpulse"); |
|
|
SendMessage(GetStone(move(p, EAST)), "stoneimpulse"); |
|
|
SendMessage(GetStone(move(p, SOUTH)), "stoneimpulse"); |
|
|
SendMessage(GetStone(move(p, WEST)), "stoneimpulse"); |
|
2853 |
set_anim("st-stoneimpulse-hollow-anim2"); |
set_anim("st-stoneimpulse-hollow-anim2"); |
2854 |
} else if (state == CLOSING) { |
else if (st == IDLE) { |
2855 |
state = IDLE; |
laser::MaybeRecalcLight(get_pos()); |
|
init_model(); |
|
2856 |
} |
} |
2857 |
} |
} |
2858 |
|
|
2859 |
StoneResponse collision_response(const StoneContact &sc) { |
StoneResponse collision_response(const StoneContact &sc) { |
2860 |
if( state == IDLE) |
return (state == IDLE) ? STONE_PASS : STONE_REBOUND; |
|
return STONE_PASS; |
|
|
return STONE_REBOUND; |
|
|
} |
|
|
void message(const string &m, const Value &) { |
|
|
if (m=="trigger") |
|
|
stoneimpulse(); |
|
|
if (m=="stoneimpulse") |
|
|
stoneimpulse(); |
|
2861 |
} |
} |
|
|
|
2862 |
void actor_inside(Actor *a) { |
void actor_inside(Actor *a) { |
2863 |
if( state == PULSING || state == CLOSING) |
if( state == PULSING || state == CLOSING) |
2864 |
SendMessage(a, "shatter"); |
SendMessage(a, "shatter"); |
2865 |
} |
} |
2866 |
|
|
2867 |
bool on_laserhit(Direction) { return true; } |
bool on_laserhit(Direction) { |
2868 |
|
return (state==IDLE); // only let light pass if idle |
2869 |
|
} |
2870 |
}; |
}; |
2871 |
} |
} |
2872 |
|
|
3619 |
bool no_stone (int xoff, int yoff); |
bool no_stone (int xoff, int yoff); |
3620 |
void remove_arms (DirectionBits arms); |
void remove_arms (DirectionBits arms); |
3621 |
void set_arm (Direction dir); |
void set_arm (Direction dir); |
|
// void animcb(); |
|
3622 |
public: |
public: |
3623 |
Turnstile_Pivot() : Stone ("st-turnstile") {} |
Turnstile_Pivot() : Stone ("st-turnstile") {} |
3624 |
bool rotate_right(); |
bool rotate_right(); |
3630 |
void animcb() { |
void animcb() { |
3631 |
set_model("st-turnstile"); |
set_model("st-turnstile"); |
3632 |
} |
} |
3633 |
}; |
}; |
3634 |
|
|
3635 |
/* |
/* |
3636 |
** The base class for any of the four arms of the turnstile |
** The base class for any of the four arms of the turnstile |
3872 |
return can_rotate; |
return can_rotate; |
3873 |
} |
} |
3874 |
|
|
3875 |
|
//---------------------------------------- |
3876 |
|
// EasyModeStone |
3877 |
|
// |
3878 |
|
// I'm not quite sure what this one is supposed to do, but a stone |
3879 |
|
// like this appears in all Per.Oxyd landscapes that look different in |
3880 |
|
// easy mode. For now, this stone simply does nothing. |
3881 |
|
//---------------------------------------- |
3882 |
|
namespace |
3883 |
|
{ |
3884 |
|
class EasyModeStone : public Stone { |
3885 |
|
SINGLETONOBJ(EasyModeStone); |
3886 |
|
public: |
3887 |
|
EasyModeStone() : Stone("st-easymode") {} |
3888 |
|
|
3889 |
|
StoneResponse collision_response(const StoneContact &sc) { |
3890 |
|
return STONE_PASS; |
3891 |
|
} |
3892 |
|
}; |
3893 |
|
} |
3894 |
|
|
3895 |
|
|
3896 |
//---------------------------------------------------------------------- |
//---------------------------------------------------------------------- |
3897 |
// OBJECT REPOSITORY |
// OBJECT REPOSITORY |
3962 |
add_templ(new Door); |
add_templ(new Door); |
3963 |
add_templ("st-door-h", new Door("h")); |
add_templ("st-door-h", new Door("h")); |
3964 |
add_templ("st-door-v", new Door("v")); |
add_templ("st-door-v", new Door("v")); |
|
|
|
3965 |
add_templ(new Door_a); |
add_templ(new Door_a); |
3966 |
add_templ(new Door_b); |
add_templ(new Door_b); |
3967 |
add_templ(new Door_c); |
add_templ(new Door_c); |
3968 |
|
add_templ(new EasyModeStone); |
3969 |
add_templ(new FakeOxydStone); |
add_templ(new FakeOxydStone); |
3970 |
add_templ(new FartStone); |
add_templ(new FartStone); |
3971 |
add_templ(new FloppyStone); |
add_templ(new FloppyStone); |
3976 |
add_templ(new KeyStone_b); |
add_templ(new KeyStone_b); |
3977 |
add_templ(new KeyStone_c); |
add_templ(new KeyStone_c); |
3978 |
add_templ(new MagicStone); |
add_templ(new MagicStone); |
3979 |
|
|
3980 |
add_templ(new OneWayStone); |
add_templ(new OneWayStone); |
3981 |
|
add_templ("st-oneway-n", new OneWayStone(NORTH)); |
3982 |
|
add_templ("st-oneway-e", new OneWayStone(EAST)); |
3983 |
|
add_templ("st-oneway-s", new OneWayStone(SOUTH)); |
3984 |
|
add_templ("st-oneway-w", new OneWayStone(WEST)); |
3985 |
add_templ(new OneWayStone_black); |
add_templ(new OneWayStone_black); |
3986 |
|
add_templ("st-oneway_black-n", new OneWayStone_black(NORTH)); |
3987 |
|
add_templ("st-oneway_black-e", new OneWayStone_black(EAST)); |
3988 |
|
add_templ("st-oneway_black-s", new OneWayStone_black(SOUTH)); |
3989 |
|
add_templ("st-oneway_black-w", new OneWayStone_black(WEST)); |
3990 |
add_templ(new OneWayStone_white); |
add_templ(new OneWayStone_white); |
3991 |
|
add_templ("st-oneway_white-n", new OneWayStone_white(NORTH)); |
3992 |
|
add_templ("st-oneway_white-e", new OneWayStone_white(EAST)); |
3993 |
|
add_templ("st-oneway_white-s", new OneWayStone_white(SOUTH)); |
3994 |
|
add_templ("st-oneway_white-w", new OneWayStone_white(WEST)); |
3995 |
|
|
3996 |
add_templ(new OxydStone); |
add_templ(new OxydStone); |
3997 |
add_templ(new PuzzleStone); |
add_templ(new PuzzleStone); |
3998 |
add_templ(new RubberBandStone); |
add_templ(new RubberBandStone); |