Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4826 in orxonox.OLD for orxonox/trunk/src


Ignore:
Timestamp:
Jul 8, 2005, 7:02:18 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: moved the weaponManager out of Weapon
we have files enough. one more is not too much :)

Location:
orxonox/trunk/src
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r4779 r4826  
    5757                  world_entities/character_attributes.cc \
    5858                  world_entities/test_entity.cc \
     59                  world_entities/weapons/weapon_manager.cc \
    5960                  world_entities/weapons/weapon.cc \
    6061                  world_entities/weapons/projectile.cc \
     
    109110                 world_entities/character_attributes.h \
    110111                 world_entities/test_entity.h \
     112                 world_entities/weapons/weapon_manager.h \
    111113                 world_entities/weapons/weapon.h \
    112114                 world_entities/weapons/projectile.h \
  • orxonox/trunk/src/Makefile.in

    r4789 r4826  
    6969        orxonox-satellite.$(OBJEXT) \
    7070        orxonox-character_attributes.$(OBJEXT) \
    71         orxonox-test_entity.$(OBJEXT) orxonox-weapon.$(OBJEXT) \
    72         orxonox-projectile.$(OBJEXT) orxonox-test_gun.$(OBJEXT) \
    73         orxonox-test_bullet.$(OBJEXT) orxonox-crosshair.$(OBJEXT) \
    74         orxonox-p_node.$(OBJEXT) orxonox-null_parent.$(OBJEXT) \
     71        orxonox-test_entity.$(OBJEXT) orxonox-weapon_manager.$(OBJEXT) \
     72        orxonox-weapon.$(OBJEXT) orxonox-projectile.$(OBJEXT) \
     73        orxonox-test_gun.$(OBJEXT) orxonox-test_bullet.$(OBJEXT) \
     74        orxonox-crosshair.$(OBJEXT) orxonox-p_node.$(OBJEXT) \
     75        orxonox-null_parent.$(OBJEXT) \
    7576        orxonox-graphics_engine.$(OBJEXT) orxonox-light.$(OBJEXT) \
    7677        orxonox-text_engine.$(OBJEXT) orxonox-base_object.$(OBJEXT) \
     
    127128@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-vector.Po \
    128129@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-weapon.Po \
     130@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-weapon_manager.Po \
    129131@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-world.Po \
    130132@AMDEP_TRUE@    ./$(DEPDIR)/orxonox-world_entity.Po
     
    303305                  world_entities/character_attributes.cc \
    304306                  world_entities/test_entity.cc \
     307                  world_entities/weapons/weapon_manager.cc \
    305308                  world_entities/weapons/weapon.cc \
    306309                  world_entities/weapons/projectile.cc \
     
    355358                 world_entities/character_attributes.h \
    356359                 world_entities/test_entity.h \
     360                 world_entities/weapons/weapon_manager.h \
    357361                 world_entities/weapons/weapon.h \
    358362                 world_entities/weapons/projectile.h \
     
    411415          esac; \
    412416        done; \
    413         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
     417        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/Makefile'; \
    414418        cd $(top_srcdir) && \
    415           $(AUTOMAKE) --gnu  src/Makefile
     419          $(AUTOMAKE) --foreign  src/Makefile
    416420.PRECIOUS: Makefile
    417421Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    507511@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-vector.Po@am__quote@
    508512@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-weapon.Po@am__quote@
     513@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-weapon_manager.Po@am__quote@
    509514@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-world.Po@am__quote@
    510515@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-world_entity.Po@am__quote@
     
    957962@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    958963@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-test_entity.obj `if test -f 'world_entities/test_entity.cc'; then $(CYGPATH_W) 'world_entities/test_entity.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/test_entity.cc'; fi`
     964
     965orxonox-weapon_manager.o: world_entities/weapons/weapon_manager.cc
     966@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-weapon_manager.o -MD -MP -MF "$(DEPDIR)/orxonox-weapon_manager.Tpo" -c -o orxonox-weapon_manager.o `test -f 'world_entities/weapons/weapon_manager.cc' || echo '$(srcdir)/'`world_entities/weapons/weapon_manager.cc; \
     967@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-weapon_manager.Tpo" "$(DEPDIR)/orxonox-weapon_manager.Po"; else rm -f "$(DEPDIR)/orxonox-weapon_manager.Tpo"; exit 1; fi
     968@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='world_entities/weapons/weapon_manager.cc' object='orxonox-weapon_manager.o' libtool=no @AMDEPBACKSLASH@
     969@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-weapon_manager.Po' tmpdepfile='$(DEPDIR)/orxonox-weapon_manager.TPo' @AMDEPBACKSLASH@
     970@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     971@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-weapon_manager.o `test -f 'world_entities/weapons/weapon_manager.cc' || echo '$(srcdir)/'`world_entities/weapons/weapon_manager.cc
     972
     973orxonox-weapon_manager.obj: world_entities/weapons/weapon_manager.cc
     974@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-weapon_manager.obj -MD -MP -MF "$(DEPDIR)/orxonox-weapon_manager.Tpo" -c -o orxonox-weapon_manager.obj `if test -f 'world_entities/weapons/weapon_manager.cc'; then $(CYGPATH_W) 'world_entities/weapons/weapon_manager.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/weapons/weapon_manager.cc'; fi`; \
     975@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/orxonox-weapon_manager.Tpo" "$(DEPDIR)/orxonox-weapon_manager.Po"; else rm -f "$(DEPDIR)/orxonox-weapon_manager.Tpo"; exit 1; fi
     976@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='world_entities/weapons/weapon_manager.cc' object='orxonox-weapon_manager.obj' libtool=no @AMDEPBACKSLASH@
     977@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/orxonox-weapon_manager.Po' tmpdepfile='$(DEPDIR)/orxonox-weapon_manager.TPo' @AMDEPBACKSLASH@
     978@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     979@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-weapon_manager.obj `if test -f 'world_entities/weapons/weapon_manager.cc'; then $(CYGPATH_W) 'world_entities/weapons/weapon_manager.cc'; else $(CYGPATH_W) '$(srcdir)/world_entities/weapons/weapon_manager.cc'; fi`
    959980
    960981orxonox-weapon.o: world_entities/weapons/weapon.cc
  • orxonox/trunk/src/lib/Makefile.in

    r4789 r4826  
    189189          esac; \
    190190        done; \
    191         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/Makefile'; \
     191        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/Makefile'; \
    192192        cd $(top_srcdir) && \
    193           $(AUTOMAKE) --gnu  src/lib/Makefile
     193          $(AUTOMAKE) --foreign  src/lib/Makefile
    194194.PRECIOUS: Makefile
    195195Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/collision_detection/Makefile.in

    r4789 r4826  
    224224          esac; \
    225225        done; \
    226         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/collision_detection/Makefile'; \
     226        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/collision_detection/Makefile'; \
    227227        cd $(top_srcdir) && \
    228           $(AUTOMAKE) --gnu  src/lib/collision_detection/Makefile
     228          $(AUTOMAKE) --foreign  src/lib/collision_detection/Makefile
    229229.PRECIOUS: Makefile
    230230Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/event/Makefile.in

    r4789 r4826  
    212212          esac; \
    213213        done; \
    214         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/event/Makefile'; \
     214        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/event/Makefile'; \
    215215        cd $(top_srcdir) && \
    216           $(AUTOMAKE) --gnu  src/lib/event/Makefile
     216          $(AUTOMAKE) --foreign  src/lib/event/Makefile
    217217.PRECIOUS: Makefile
    218218Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/graphics/Makefile.in

    r4789 r4826  
    179179          esac; \
    180180        done; \
    181         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/graphics/Makefile'; \
     181        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/graphics/Makefile'; \
    182182        cd $(top_srcdir) && \
    183           $(AUTOMAKE) --gnu  src/lib/graphics/Makefile
     183          $(AUTOMAKE) --foreign  src/lib/graphics/Makefile
    184184.PRECIOUS: Makefile
    185185Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/graphics/importer/Makefile.in

    r4789 r4826  
    218218          esac; \
    219219        done; \
    220         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/graphics/importer/Makefile'; \
     220        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/graphics/importer/Makefile'; \
    221221        cd $(top_srcdir) && \
    222           $(AUTOMAKE) --gnu  src/lib/graphics/importer/Makefile
     222          $(AUTOMAKE) --foreign  src/lib/graphics/importer/Makefile
    223223.PRECIOUS: Makefile
    224224Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/graphics/spatial_separation/Makefile.in

    r4821 r4826  
    205205          esac; \
    206206        done; \
    207         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/graphics/spatial_separation/Makefile'; \
     207        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/graphics/spatial_separation/Makefile'; \
    208208        cd $(top_srcdir) && \
    209           $(AUTOMAKE) --gnu  src/lib/graphics/spatial_separation/Makefile
     209          $(AUTOMAKE) --foreign  src/lib/graphics/spatial_separation/Makefile
    210210.PRECIOUS: Makefile
    211211Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/gui/Makefile.in

    r4789 r4826  
    241241          esac; \
    242242        done; \
    243         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/gui/Makefile'; \
     243        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/gui/Makefile'; \
    244244        cd $(top_srcdir) && \
    245           $(AUTOMAKE) --gnu  src/lib/gui/Makefile
     245          $(AUTOMAKE) --foreign  src/lib/gui/Makefile
    246246.PRECIOUS: Makefile
    247247Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/particles/Makefile.in

    r4789 r4826  
    209209          esac; \
    210210        done; \
    211         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/particles/Makefile'; \
     211        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/particles/Makefile'; \
    212212        cd $(top_srcdir) && \
    213           $(AUTOMAKE) --gnu  src/lib/particles/Makefile
     213          $(AUTOMAKE) --foreign  src/lib/particles/Makefile
    214214.PRECIOUS: Makefile
    215215Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/physics/Makefile.in

    r4789 r4826  
    218218          esac; \
    219219        done; \
    220         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/physics/Makefile'; \
     220        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/physics/Makefile'; \
    221221        cd $(top_srcdir) && \
    222           $(AUTOMAKE) --gnu  src/lib/physics/Makefile
     222          $(AUTOMAKE) --foreign  src/lib/physics/Makefile
    223223.PRECIOUS: Makefile
    224224Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/sound/Makefile.in

    r4789 r4826  
    201201          esac; \
    202202        done; \
    203         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/sound/Makefile'; \
     203        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/sound/Makefile'; \
    204204        cd $(top_srcdir) && \
    205           $(AUTOMAKE) --gnu  src/lib/sound/Makefile
     205          $(AUTOMAKE) --foreign  src/lib/sound/Makefile
    206206.PRECIOUS: Makefile
    207207Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/lib/tinyxml/Makefile.in

    r4789 r4826  
    204204          esac; \
    205205        done; \
    206         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/lib/tinyxml/Makefile'; \
     206        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/lib/tinyxml/Makefile'; \
    207207        cd $(top_srcdir) && \
    208           $(AUTOMAKE) --gnu  src/lib/tinyxml/Makefile
     208          $(AUTOMAKE) --foreign  src/lib/tinyxml/Makefile
    209209.PRECIOUS: Makefile
    210210Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/story_entities/world.cc

    r4823 r4826  
    880880    }
    881881  delete iterator;
    882   crosshair->draw();
    883882
    884883  glCallList (objectList);
     
    888887  TextEngine::getInstance()->draw();
    889888  LightManager::getInstance()->draw(); // must be at the end of the drawing procedure, otherwise Light cannot be handled as PNodes //
     889  crosshair->draw();
    890890}
    891891
  • orxonox/trunk/src/subprojects/Makefile.in

    r4789 r4826  
    187187          esac; \
    188188        done; \
    189         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/Makefile'; \
     189        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/Makefile'; \
    190190        cd $(top_srcdir) && \
    191           $(AUTOMAKE) --gnu  src/subprojects/Makefile
     191          $(AUTOMAKE) --foreign  src/subprojects/Makefile
    192192.PRECIOUS: Makefile
    193193Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/subprojects/collision_detection/Makefile.in

    r4789 r4826  
    270270          esac; \
    271271        done; \
    272         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/collision_detection/Makefile'; \
     272        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/collision_detection/Makefile'; \
    273273        cd $(top_srcdir) && \
    274           $(AUTOMAKE) --gnu  src/subprojects/collision_detection/Makefile
     274          $(AUTOMAKE) --foreign  src/subprojects/collision_detection/Makefile
    275275.PRECIOUS: Makefile
    276276Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/subprojects/gui/Makefile.in

    r4789 r4826  
    225225          esac; \
    226226        done; \
    227         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/gui/Makefile'; \
     227        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/gui/Makefile'; \
    228228        cd $(top_srcdir) && \
    229           $(AUTOMAKE) --gnu  src/subprojects/gui/Makefile
     229          $(AUTOMAKE) --foreign  src/subprojects/gui/Makefile
    230230.PRECIOUS: Makefile
    231231Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/subprojects/importer/Makefile.in

    r4789 r4826  
    243243          esac; \
    244244        done; \
    245         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/importer/Makefile'; \
     245        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/importer/Makefile'; \
    246246        cd $(top_srcdir) && \
    247           $(AUTOMAKE) --gnu  src/subprojects/importer/Makefile
     247          $(AUTOMAKE) --foreign  src/subprojects/importer/Makefile
    248248.PRECIOUS: Makefile
    249249Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/subprojects/particles/Makefile.in

    r4789 r4826  
    259259          esac; \
    260260        done; \
    261         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/particles/Makefile'; \
     261        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/particles/Makefile'; \
    262262        cd $(top_srcdir) && \
    263           $(AUTOMAKE) --gnu  src/subprojects/particles/Makefile
     263          $(AUTOMAKE) --foreign  src/subprojects/particles/Makefile
    264264.PRECIOUS: Makefile
    265265Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/subprojects/testmain/Makefile.in

    r4789 r4826  
    196196          esac; \
    197197        done; \
    198         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/subprojects/testmain/Makefile'; \
     198        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/subprojects/testmain/Makefile'; \
    199199        cd $(top_srcdir) && \
    200           $(AUTOMAKE) --gnu  src/subprojects/testmain/Makefile
     200          $(AUTOMAKE) --foreign  src/subprojects/testmain/Makefile
    201201.PRECIOUS: Makefile
    202202Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
  • orxonox/trunk/src/world_entities/player.cc

    r4824 r4826  
    2121#include "objModel.h"
    2222#include "resource_manager.h"
     23
     24#include "weapon_manager.h"
    2325#include "weapon.h"
    2426#include "test_gun.h"
  • orxonox/trunk/src/world_entities/weapons/crosshair.cc

    r4824 r4826  
    2323#include "p_node.h"
    2424#include "state.h"
     25
     26#include <iostream>
    2527
    2628using namespace std;
     
    113115  */
    114116
     117
    115118  GraphicsEngine::storeMatrices();
    116119
    117   GLfloat z;
    118   glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1], 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);
     120  float z;
     121  glReadPixels ((int)position2D[0], GraphicsEngine::getInstance()->getResolutionY()-(int)position2D[1]-1, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
    119122
    120   printf("%p:: %d %d %f\n",this, (int)position2D[0], (int)position2D[1], z);
     123
     124  printf("%f %f %f\n", (int)position2D[0], (int)position2D[1], z);
     125
     126  //cout << z <<"  "<< scale << "  "  << bias<< endl;
    121127
    122128  GLdouble objX, objY, objZ;
    123   if (gluUnProject(position2D[0],
    124       GraphicsEngine::getInstance()->getResolutionY()-position2D[1],
    125       z,
    126       GraphicsEngine::modMat,
    127       GraphicsEngine::projMat,
    128       GraphicsEngine::viewPort,
    129       &objX,
    130       &objY,
    131       &objZ ));
    132   /*
     129  gluUnProject(position2D[0],
     130               GraphicsEngine::getInstance()->getResolutionY()-position2D[1]-1,
     131               .5,
     132               GraphicsEngine::modMat,
     133               GraphicsEngine::projMat,
     134               GraphicsEngine::viewPort,
     135               &objX,
     136               &objY,
     137               &objZ );
     138
    133139  glBegin(GL_TRIANGLES);
    134140  glColor3f(1,0,0);
     
    137143  glVertex3f(objX, objY, objZ+1);
    138144  glEnd();
    139   */
    140145}
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4758 r4826  
    1 
    21
    32/*
     
    1110   any later version.
    1211
    13    ### File Specific
     12### File Specific
    1413   main-programmer: Patrick Boenzli
    1514   co-programmer:
    1615*/
    1716
    18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    19 
     17#include "weapon_manager.h"
    2018#include "weapon.h"
    2119#include "stdincl.h"
     
    2725#include "world.h"
    2826
    29 using namespace std;
    30 
    31 
    32 
    33 /**
    34    \brief this initializes the weaponManager for a given nnumber of weapon slots
    35    \param number of weapon slots of the model/ship <= 8 (limitied)
    36 */
    37 WeaponManager::WeaponManager(int nrOfSlots)
    38 {
    39   this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
    40 
    41   for(int i = 0; i < W_MAX_CONFIGS; ++i)
    42     {
    43       this->configs[i].bUsed = false;
    44       for(int j = 0; j < W_MAX_SLOTS; ++j)
    45         this->configs[i].slots[j] = NULL;
    46     }
    47   this->nrOfSlots = nrOfSlots;
    48   this->currConfID = W_CONFIG0;
    49 }
    50 
    51 
    52 WeaponManager::~WeaponManager()
    53 {
    54   /*
    55      i dont have to delete the weapons itself, because they are
    56      worldentities and therefore in the entities list of the world.
    57      world will clean them up for me
    58   */
    59   for(int i = 0; i < W_MAX_CONFIGS; ++i)
    60     {
    61       this->configs[i].bUsed = false;
    62       for(int j = 0; j < W_MAX_SLOTS; ++j)
    63         this->configs[i].slots[j] = NULL;
    64     }
    65 }
    66 
    67 
    68 /**
    69    \brief adds a weapon to the selected weaponconfiguration into the selected slot
    70    \param the weapon to add
    71    \param an identifier for the slot: number between 0..7 if not specified: slotID=next free slot
    72    \param an identifier for the weapon configuration, number between 0..3
    73 
    74    if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be
    75    replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free
    76    slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be
    77    a error message.
    78 */
    79 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID)
    80 {
    81   if( slotID == W_FREE_SLOT)
    82     {
    83       int freeSlot = this->getNextFreeSlot( configID);
    84       if( freeSlot < 0 || freeSlot >= this->nrOfSlots)
    85         {
    86           PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
    87           return;
    88         }
    89       PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot);
    90       this->configs[configID].bUsed = true;
    91       this->configs[configID].slots[freeSlot] = weapon;
    92       return;
    93     }
    94   this->configs[configID].bUsed = true;
    95   this->configs[configID].slots[slotID] = weapon;
    96   PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID);
    97 }
    98 
    99 
    100 void WeaponManager::removeWeapon(Weapon* weapon, int configID)
    101 {
    102   /* empty */
    103 }
    104 
    105 
    106 /**
    107    \brief changes to the next weapon configuration
    108 
    109    if there are multiple weapon configurations defined by the manager, use this to switch between them
    110    this function will deactivate the weapons first, change the config and reactivate them later
    111 */
    112 void WeaponManager::nextWeaponConf()
    113 {
    114   PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID);
    115 
    116   int i, lastConfID;
    117   lastConfID = this->currConfID;
    118   for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
    119   if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0;
    120   else this->currConfID = i;
    121 
    122 
    123   Weapon *w1, *w2;
    124   for(int j = 0; j < W_MAX_SLOTS; ++j)
    125     {
    126       w1 = this->configs[lastConfID].slots[j];
    127       w2 = this->configs[this->currConfID].slots[j];
    128 
    129       if( w1 == w2)
    130         {
    131           printf("no need for change\n");
    132         }
    133       else
    134         {
    135         if( w1 != NULL )
    136           {
    137             w1->deactivate();
    138             printf("deactivating %i,%i\n", j,lastConfID);
    139           }
    140         if( w2 != NULL)
    141           {
    142             w2->activate();
    143             printf("activating %i,%i\n", j, this->currConfID);
    144           }
    145         }
    146     }
    147 }
    148 
    149 
    150 
    151 /**
    152    \brief triggers fire of all weapons in the current weaponconfig
    153 */
    154 void WeaponManager::fire()
    155 {
    156   Weapon* firingWeapon;
    157   for(int i = 0; i < W_MAX_SLOTS; ++i)
    158     {
    159       firingWeapon = this->configs[this->currConfID].slots[i];
    160       if( firingWeapon != NULL) firingWeapon->fire();
    161     }
    162 }
    163 
    164 
    165 /**
    166    \brief triggers tick of all weapons in the current weaponconfig
    167    \param second passed since last tick
    168 */
    169 void WeaponManager::tick(float sec)
    170 {
    171   Weapon* w;
    172   for(int i = 0; i < W_MAX_SLOTS; ++i)
    173     {
    174       w = this->configs[this->currConfID].slots[i];
    175       if( w != NULL) w->tick(sec);
    176     }
    177 }
    178 
    179 
    180 /**
    181    \brief triggers draw of all weapons in the current weaponconfig
    182 */
    183 void WeaponManager::draw()
    184 {
    185   Weapon* w;
    186   for(int i = 0; i < W_MAX_SLOTS; ++i)
    187     {
    188       w = this->configs[this->currConfID].slots[i];
    189       if( w != NULL) w->draw();
    190     }
    191 }
    192 
    193 
    194 /**
    195    \brief private gets the next free slot in a certain weaponconfig
    196    \param the selected weaponconfig
    197 */
    198 int WeaponManager::getNextFreeSlot(int configID)
    199 {
    200   for( int i = 0; i < W_MAX_SLOTS; ++i)
    201     {
    202       if( this->configs[configID].slots[i] == NULL)
    203         return i;
    204     }
    205   return -1;
    206 }
    207 
    208 
    209 
    210 
    211 
    212 
    21327/**
    21428   \brief standard constructor
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4759 r4826  
    33    \brief a weapon that a player can use
    44
    5     A Player has a list of weapons, that can be choosen to shoot projectiles
    6     (projectiles.{cc,h}) at ennemies. These weapons can be shooted sequentially
    7     or (if able) combined. Therefore you can choose the weapon mode = choose
    8     a weapon.
    95
    106    A weapon is characterized by:
     
    1713     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
    1814     o shooting animation
    19 
    20 
    21      a player defines one or more weapon configurations. a player has got one to eight
    22      weapon slots: places where weapons can be attached to. a weapon configuration
    23      is a matching between weapons and slots.
    24      Since its clear how many weapons a player will have, there is no list of weapons:
    25      its hard coded and limited to 8 slots and 4 configs. More would be a waste of
    26      memory and time you need to customize and change to a weapon config...
    2715*/
    2816
     
    4432class TiXmlElement;
    4533
     34
     35// typedef enum {
     36//   W_SHOOT,
     37//   W_EMPTY,
     38//   W_RELOAD,
     39//   W_SPECIAL1,
     40//   W_SPECIAL2,
     41//   W_SPECIAL3
     42// } WeaponSoundType;
     43
    4644typedef enum {
     45  W_NONE,
    4746  W_SHOOT,
    48   W_EMPTY,
    4947  W_RELOAD,
    50   W_SPECIAL1,
    51   W_SPECIAL2,
    52   W_SPECIAL3
    53 } WeaponSoundType;
     48  W_ACTIVATING,
     49  W_DEACTIVATE,
     50  W_IDLE,
     51} WeaponState;
    5452
    55 
    56 //! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time
    57 #define    W_SLOT0       0
    58 #define    W_SLOT1       1
    59 #define    W_SLOT2       2
    60 #define    W_SLOT3       3
    61 #define    W_SLOT4       4
    62 #define    W_SLOT5       5
    63 #define    W_SLOT6       6
    64 #define    W_SLOT7       7
    65 #define    W_FREE_SLOT   99
    66 
    67 
    68 //! this is an identifier for the weapon config
    69 #define    W_CONFIG0     0
    70 #define    W_CONFIG1     1
    71 #define    W_CONFIG2     2
    72 #define    W_CONFIG3     3
    7353
    7454//! a weapon can be left or right sided
     
    7656#define    W_RIGHT       1
    7757
    78 //! this is a weapon Configuration: it has up to 8 slots
    79 typedef struct weaponConfig {
    80   bool           bUsed;                       //<! is set to true, if this configuration is
    81   Weapon*        slots[8];
    82 };
    8358
    8459
    85 class WeaponManager : public BaseObject {
    86  public:
    87   WeaponManager(int nrOfSlots = 2);
    88   WeaponManager(const TiXmlElement* root);
    89   ~WeaponManager();
    9060
    91   void init();
    92   void loadParams(const TiXmlElement* root);
    93 
    94   void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT);
    95   void removeWeapon(Weapon* weapon, int configID = W_CONFIG0);
    96   void nextWeaponConf();
    97 
    98   void fire();
    99   void tick(float sec);
    100   void draw();
    101 
    102  private:
    103   int                   nrOfSlots;               //<! number of weapon slots a ship has
    104   int                   currConfID;              //<! the currently selected config
    105   weaponConfig          configs[4];              //<! a list of four configurations
    106 
    107   int getNextFreeSlot(int configID);
    108 };
    10961
    11062class Weapon : public WorldEntity
Note: See TracChangeset for help on using the changeset viewer.