2575 |
return (a->state==BLINKING || a->state==OPENING); |
return (a->state==BLINKING || a->state==OPENING); |
2576 |
} |
} |
2577 |
static bool not_open(OxydStone *a) { |
static bool not_open(OxydStone *a) { |
2578 |
return a->state!=OPEN; |
return !(a->state==OPEN || a->state==OPENING); |
2579 |
} |
} |
2580 |
|
|
2581 |
// Stone interface |
// Stone interface |
2599 |
OxydStone::InstanceList OxydStone::instances; |
OxydStone::InstanceList OxydStone::instances; |
2600 |
|
|
2601 |
OxydStone::OxydStone() |
OxydStone::OxydStone() |
2602 |
: PhotoStone("st-oxyd"), state(CLOSED), model_bak(0) |
: PhotoStone("st-oxyd") |
2603 |
|
, state(CLOSED) |
2604 |
|
, model_bak(0) |
2605 |
{ |
{ |
2606 |
set_attrib("flavor", "b"); |
set_attrib("flavor", "b"); |
2607 |
set_attrib("color", "0"); |
set_attrib("color", "0"); |
2649 |
|
|
2650 |
string modelname = string("st-oxyd") + flavor + color; |
string modelname = string("st-oxyd") + flavor + color; |
2651 |
|
|
2652 |
|
State oldstate = state; |
2653 |
|
state = newstate; |
2654 |
|
|
2655 |
switch (newstate) { |
switch (newstate) { |
2656 |
case CLOSED: |
case CLOSED: |
2657 |
set_model(string("st-oxyd")+flavor); |
set_model(string("st-oxyd")+flavor); |
2662 |
break; |
break; |
2663 |
|
|
2664 |
case OPEN: |
case OPEN: |
2665 |
if (state == CLOSED) { |
if (oldstate == CLOSED) { |
2666 |
play_sound("st-oxydopen"); |
play_sound("st-oxydopen"); |
2667 |
play_sound("st-oxydopened"); |
play_sound("st-oxydopened"); |
2668 |
set_anim(modelname+"-opening"); |
set_anim(modelname+"-opening"); |
2669 |
} else { |
} else { |
2670 |
set_model(modelname + "-open"); |
set_model(modelname + "-open"); |
2671 |
|
} |
2672 |
/* If this was the last closed oxyd stone, finish the |
/* If this was the last closed oxyd stone, finish the |
2673 |
level */ |
level */ |
2674 |
if (find_if(instances.begin(),instances.end(),not_open) |
if (find_if(instances.begin(),instances.end(),not_open) |
2675 |
==instances.end()) |
==instances.end()) |
2676 |
{ |
{ |
2677 |
enigma::FinishLevel(); |
enigma::FinishLevel(); |
|
} |
|
2678 |
} |
} |
2679 |
break; |
break; |
2680 |
|
|
2681 |
case OPENING: |
case OPENING: |
2682 |
play_sound("st-oxydopen"); |
play_sound("st-oxydopen"); |
2683 |
if (state == CLOSED) |
if (oldstate == CLOSED) |
2684 |
set_anim(modelname + "-opening"); |
set_anim(modelname + "-opening"); |
2685 |
else if (state == CLOSING) |
else if (oldstate == CLOSING) |
2686 |
get_model()->reverse(); |
get_model()->reverse(); |
2687 |
|
|
2688 |
break; |
break; |
2689 |
|
|
2690 |
case CLOSING: |
case CLOSING: |
2691 |
if (state == CLOSED || state==CLOSING) |
if (oldstate == CLOSED || oldstate==CLOSING) |
2692 |
return; |
return; |
2693 |
|
|
2694 |
play_sound("st-oxydclose"); |
play_sound("st-oxydclose"); |
2695 |
if (state == OPENING) |
if (oldstate == OPENING) |
2696 |
get_model()->reverse(); |
get_model()->reverse(); |
2697 |
else if (state == BLINKING || state == OPEN) { |
else if (oldstate == BLINKING || oldstate == OPEN) { |
2698 |
set_anim(modelname + "-closing"); |
set_anim(modelname + "-closing"); |
2699 |
} |
} |
2700 |
break; |
break; |
2701 |
} |
} |
|
state = newstate; |
|
2702 |
} |
} |
2703 |
|
|
2704 |
void |
void |