[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src stones_simple.cc,1.62,1.63
From: |
Ralf Westram <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src stones_simple.cc,1.62,1.63 |
Date: |
Wed, 12 Nov 2003 09:31:12 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv19913/src
Modified Files:
stones_simple.cc
Log Message:
- added st-break_gray
- combined functionality of TimeSwitch and LaserSwitch in class
LaserTimeSwitchBase
- added st-lasertimeswitch for Oxyd1/Oxyd Magnum (mix of TimeSwitch and
LaserSwitch)
- added attribute "inverse" to LaserTimeSwitchBase
- added attribute "delay" to LaserTimeSwitch/TimeSwitch
Index: stones_simple.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/stones_simple.cc,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** stones_simple.cc 9 Nov 2003 11:58:28 -0000 1.62
--- stones_simple.cc 12 Nov 2003 09:31:10 -0000 1.63
***************
*** 1368,1426 ****
//----------------------------------------
- // Timeswitch
- //
- // Attributes:
- //
- // :on 1 or 0
- // :target,action as usual
- //----------------------------------------
-
- /** \page st-switch Switch Stone
-
- On actor hit this stone can trigger actions
-
- \image html st-timeswitch.png
- */
- namespace
- {
- class TimeSwitch : public OnOffStone {
- CLONEOBJ(TimeSwitch);
- public:
- TimeSwitch() : OnOffStone("st-timeswitch"), state(IDLE) {}
- private:
- enum State {IDLE, ON, OFF };
- State state;
- void change_state (State newstate)
- {
- if (newstate == IDLE) {
- state = IDLE;
- }
- }
-
- void actor_hit(const StoneContact &sc)
- {
-
- if ( state == IDLE) {
- if (sc.actor)
- state = ON;
- set_on(!is_on());
- PerformAction(this, is_on());
- play_sound("st-switch");
- set_anim("st-time1switch");
- }
- }
-
- void animcb() {
- if (state == ON) {
- set_on(!is_on());
- PerformAction(this, is_on());
- play_sound("st-switch");
- change_state (IDLE);
- }
- }
- const char *collision_sound() { return "st-metal"; }
- };
- }
- //----------------------------------------
// FourSwitch
//
--- 1368,1371 ----
***************
*** 1471,1490 ****
//----------------------------------------
! // Laser Switch
//----------------------------------------
- /** \page st-laserswitch Laserswitch Stone
-
- Activated by laser light this switch can trigger actions
-
- */
namespace
{
! class LaserSwitch : public laser::PhotoStone {
! CLONEOBJ(LaserSwitch);
public:
! LaserSwitch();
private:
// Stone interface
void on_creation();
--- 1416,1436 ----
//----------------------------------------
! // Laser/Time Switch
//----------------------------------------
namespace
{
! class LaserTimeSwitchBase : public laser::PhotoStone, public TimeHandler {
public:
! LaserTimeSwitchBase(const char *kind);
private:
+ // LaserTimeSwitchBase interface
+ virtual const char *get_active_model() const = 0;
+ virtual const char *get_inactive_model() const = 0;
+ virtual double timer_delay() const;
+
+ bool inverse() { return int_attrib("inverse") == 1; }
+
// Stone interface
void on_creation();
***************
*** 1493,1518 ****
// PhotoStone interface.
! void notify_laseron() { set_model("st-laserswitch1");
PerformAction(this, true);}
! void notify_laseroff() { set_model("st-laserswitch0");
PerformAction(this, false);}
};
}
LaserSwitch::LaserSwitch()
! : PhotoStone("st-laserswitch")
{
}
! void
! LaserSwitch::on_creation()
{
! set_model("st-laserswitch0");
! photo_activate();
}
! void
! LaserSwitch::on_removal()
{
- photo_deactivate();
}
//----------------------------------------
--- 1439,1598 ----
// PhotoStone interface.
! void notify_laseron();
! void notify_laseroff();
!
! // TimeHandler interface
! void alarm();
!
! protected:
! // variables :
! enum State { IDLE, LIGHTED, TOUCHED };
! State state;
!
! void change_state(State newstate);
! };
! }
!
! LaserTimeSwitchBase::LaserTimeSwitchBase(const char *kind)
! : PhotoStone(kind) , state(IDLE) {}
!
! void LaserTimeSwitchBase::change_state(State newstate) {
! if (state == newstate)
! return;
!
! if (state == IDLE) {
! play_sound("st-switch");
! set_model(get_active_model());
! PerformAction(this, !inverse());
! if (newstate == TOUCHED) {
! double delay = timer_delay();
! assert(delay>0.0);
! GameTimer.set_alarm(this, delay, false);
! }
! }
! else if (newstate == IDLE) {
! play_sound("st-switch");
! set_model(get_inactive_model());
! PerformAction(this, inverse());
! }
! else {
! // it's not allowed to switch from LIGHTED to TOUCHED
! assert(!(state == LIGHTED && newstate == TOUCHED));
! }
! state = newstate;
! }
! void LaserTimeSwitchBase::on_creation() {
! set_model(get_inactive_model());
! photo_activate();
! }
! void LaserTimeSwitchBase::on_removal() {
! photo_deactivate();
! }
! void LaserTimeSwitchBase::notify_laseron() {
! if (state != LIGHTED)
! change_state(LIGHTED);
! }
! void LaserTimeSwitchBase::notify_laseroff() {
! if (state == LIGHTED)
! change_state(IDLE);
! }
! void LaserTimeSwitchBase::alarm() {
! if (state == TOUCHED)
! change_state(IDLE);
! }
! double LaserTimeSwitchBase::timer_delay() const {
! return -1; // we have no timer delay
! }
!
!
! namespace {
! class LaserSwitch : public LaserTimeSwitchBase {
! CLONEOBJ(LaserSwitch);
! public:
! LaserSwitch();
! private:
! // LaserTimeSwitchBase interface
! const char *get_active_model() const;
! const char *get_inactive_model() const;
};
}
LaserSwitch::LaserSwitch()
! : LaserTimeSwitchBase("st-laserswitch")
{
}
+ const char *LaserSwitch::get_active_model() const { return "st-laserswitch1";
}
+ const char *LaserSwitch::get_inactive_model() const { return
"st-laserswitch0"; }
! namespace {
! class LaserTimeSwitch : public LaserTimeSwitchBase {
! CLONEOBJ(LaserTimeSwitch);
! public:
! LaserTimeSwitch(const char *kind = "st-lasertimeswitch");
! private:
! // LaserTimeSwitchBase interface
! const char *get_active_model() const;
! const char *get_inactive_model() const;
! double timer_delay() const;
!
! // Stone interface
! void actor_hit(const StoneContact &sc);
! };
! }
!
! LaserTimeSwitch::LaserTimeSwitch(const char *kind)
! : LaserTimeSwitchBase(kind)
{
! set_attrib("delay", 1.8);
}
+ const char *LaserTimeSwitch::get_active_model() const { return
"st-time1switch"; }
+ const char *LaserTimeSwitch::get_inactive_model() const { return
"st-timeswitch"; }
! double LaserTimeSwitch::timer_delay() const {
! double delay;
! if (!double_attrib("delay", &delay)) assert(0);
! return delay;
! }
! void LaserTimeSwitch::actor_hit(const StoneContact &sc) {
! if (sc.actor && state == IDLE)
! change_state(TOUCHED);
! }
!
! //----------------------------------------
! // Timeswitch
! //
! // Attributes:
! //
! // :on 1 or 0
! // :target,action as usual
! //----------------------------------------
!
! /** \page st-switch Switch Stone
!
! On actor hit this stone can trigger actions
!
! \image html st-timeswitch.png
! */
!
! namespace {
! class TimeSwitch : public LaserTimeSwitch {
! CLONEOBJ(TimeSwitch);
! public:
! TimeSwitch();
! private:
! // ignore laser:
! void notify_laseron();
! void notify_laseroff();
! };
!
!
! }
!
! TimeSwitch::TimeSwitch()
! : LaserTimeSwitch("st-timeswitch")
{
}
+ void TimeSwitch::notify_laseron() {} // ignore laser
+ void TimeSwitch::notify_laseroff() {}
//----------------------------------------
***************
*** 1903,1913 ****
for (unsigned i = 0; i<actors.size(); ++i) {
Actor *a = actors[i];
-
if (a->get_actorinfo()->grabbed &&
! a->get_attrib("color") &&
! a->int_attrib("color") == color)
! {
ReleaseActor(a);
- }
}
}
--- 1983,1989 ----
for (unsigned i = 0; i<actors.size(); ++i) {
Actor *a = actors[i];
if (a->get_actorinfo()->grabbed &&
! a->get_attrib(color ? "whiteball" : "blackball"))
ReleaseActor(a);
}
}
***************
*** 2420,2423 ****
--- 2496,2500 ----
Register(new Knight);
Register(new LaserSwitch);
+ Register(new LaserTimeSwitch);
Register(new MagicStone);
Register(new RubberBandStone);
***************
*** 2425,2428 ****
--- 2502,2506 ----
Register(new Stone_break("st-stone_break"));
Register(new Stone_break("st-rock3_break"));
+ Register(new Stone_break("st-break_gray"));
Register(new Stone_movebreak);
Register(new Stonebrush);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src stones_simple.cc,1.62,1.63,
Ralf Westram <address@hidden> <=