/[enigma]/enigma/src/objects.cc
ViewVC logotype

Diff of /enigma/src/objects.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mhawlisch, Fri Jan 17 16:14:12 2003 UTC revision 1.9 by sfennig, Sun Jan 19 03:35:01 2003 UTC
# Line 493  Other stones: Line 493  Other stones:
493  - \ref st-puzzle  - \ref st-puzzle
494  - \ref st-stone_break  - \ref st-stone_break
495  - \ref st-oneway  - \ref st-oneway
496    - \ref st-oneway_black
497    - \ref st-oneway_white
498  - \ref st-chameleon  - \ref st-chameleon
499  */  */
500    
# Line 555  namespace Line 557  namespace
557  }  }
558    
559  //----------------------------------------  //----------------------------------------
560  // One Way Stone  // One Way Stone; black, white
561  //  //
562  // This stone can only be passed in one direction.  // This stone can only be passed in one direction.
563  //----------------------------------------  //----------------------------------------
# Line 629  OneWayStone::actor_hit(const StoneContac Line 631  OneWayStone::actor_hit(const StoneContac
631  }  }
632    
633  //----------------------------------------  //----------------------------------------
634    // One Way Stone; black only
635    //
636    // This stone can only be passed in one direction.
637    //----------------------------------------
638    
639    namespace
640    {
641        class OneWayStone_black : public Stone {
642            CLONEOBJ(OneWayStone_black);
643        public:
644            OneWayStone_black() : Stone("st-oneway_black") {
645                set_orientation(SOUTH);
646            }
647        private:
648            void init_model() {
649                string mname = "st-oneway_black";
650                mname += to_suffix(get_orientation());
651                set_model (mname);
652            }
653            Direction get_orientation() const {
654                return Direction(int_attrib("orientation"));
655            }
656            void set_orientation(Direction dir) {
657                set_attrib("orientation", Value(dir));
658            }
659            StoneResponse collision_response(const StoneContact&);
660            void actor_hit (const StoneContact&);
661        };
662    }
663    
664    StoneResponse
665    OneWayStone_black::collision_response(const StoneContact &sc)
666    {
667        DirectionBits dirs=contact_faces(sc);
668        Direction o=get_orientation();
669        if (sc.actor->get_attrib("blackball"))
670        return has_dir(dirs,o) ? STONE_REBOUND : STONE_PASS;
671        else
672             return STONE_REBOUND;
673    }
674    
675    void
676    OneWayStone_black::actor_hit(const StoneContact &sc)
677    {
678        DirectionBits dirs=contact_faces(sc);
679        Direction o=get_orientation();
680    
681        if (has_dir(dirs,o)) {
682            // magic wand as first item?
683            if (wielded_item_is(sc.actor, "it-magicwand")) {
684                set_orientation(reverse(o));
685                init_model();
686            }
687        }
688    }
689    
690    //----------------------------------------
691    // One Way Stone ; white only
692    //
693    // This stone can only be passed in one direction.
694    //----------------------------------------
695    
696    namespace
697    {
698        class OneWayStone_white : public Stone {
699            CLONEOBJ(OneWayStone_white);
700        public:
701            OneWayStone_white() : Stone("st-oneway_white") {
702                set_orientation(SOUTH);
703            }
704        private:
705            void init_model() {
706                string mname = "st-oneway_white";
707                mname += to_suffix(get_orientation());
708                set_model (mname);
709            }
710            Direction get_orientation() const {
711                return Direction(int_attrib("orientation"));
712            }
713            void set_orientation(Direction dir) {
714                set_attrib("orientation", Value(dir));
715            }
716            StoneResponse collision_response(const StoneContact&);
717            void actor_hit (const StoneContact&);
718        };
719    }
720    
721    StoneResponse
722    OneWayStone_white::collision_response(const StoneContact &sc)
723    {
724        DirectionBits dirs=contact_faces(sc);
725        Direction o=get_orientation();
726        if (sc.actor->get_attrib("whiteball"))
727        return has_dir(dirs,o) ? STONE_REBOUND : STONE_PASS;
728        else
729             return STONE_REBOUND;
730    }
731    
732    void
733    OneWayStone_white::actor_hit(const StoneContact &sc)
734    {
735        DirectionBits dirs=contact_faces(sc);
736        Direction o=get_orientation();
737    
738        if (has_dir(dirs,o)) {
739            // magic wand as first item?
740            if (wielded_item_is(sc.actor, "it-magicwand")) {
741                set_orientation(reverse(o));
742                init_model();
743            }
744        }
745    }
746    
747    //----------------------------------------
748  // Chameleon Stone  // Chameleon Stone
749  //  //
750  // This stone takes on the look of the floor beneath it.  Actors can  // This stone takes on the look of the floor beneath it.  Actors can
# Line 3123  ObjectRepos::ObjectRepos() Line 3239  ObjectRepos::ObjectRepos()
3239      add_templ(new KeyStone_c);      add_templ(new KeyStone_c);
3240      add_templ(new MagicStone);      add_templ(new MagicStone);
3241      add_templ(new OneWayStone);      add_templ(new OneWayStone);
3242        add_templ(new OneWayStone_black);
3243        add_templ(new OneWayStone_white);    
3244      add_templ(new OxydStone);      add_templ(new OxydStone);
3245      add_templ(new PuzzleStone);      add_templ(new PuzzleStone);
3246      add_templ(new ShogunStone);      add_templ(new ShogunStone);

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26