Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 21, 2011, 5:36:37 PM (13 years ago)
Author:
jo
Message:

Moved intern waypoint functionallity from the waypointController to its base class ArtificialController. Further usage of this is planned.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai2/src/orxonox/controllers/ArtificialController.cc

    r8764 r8769  
    4949#include "weaponsystem/Weapon.h"
    5050#include "weaponsystem/WeaponSlot.h"
     51#include "weaponsystem/WeaponSlot.h"
    5152
    5253namespace orxonox
     
    9394        this->botlevel_ = 0.5f;
    9495        this->mode_ = DEFAULT;////Vector-implementation: mode_.push_back(DEFAULT);
    95         this->timeout_=0;
     96        this->timeout_ = 0;
     97        this->currentWaypoint_ = 0;
     98        this->setAccuracy(100);
    9699    }
    97100
     
    100103        if (this->isInitialized())
    101104        {//Vector-implementation: mode_.erase(mode_.begin(),mode_.end());
     105            for (size_t i = 0; i < this->waypoints_.size(); ++i)
     106                this->waypoints_[i]->destroy();
    102107            this->removeFromFormation();
    103108            this->weaponModes_.clear();
     
    11401145    }
    11411146
     1147    void ArtificialController::addWaypoint(WorldEntity* waypoint)
     1148    {
     1149        this->waypoints_.push_back(waypoint);
     1150    }
     1151
     1152    WorldEntity* ArtificialController::getWaypoint(unsigned int index) const
     1153    {
     1154        if (index < this->waypoints_.size())
     1155            return this->waypoints_[index];
     1156        else
     1157            return 0;
     1158    }
     1159
     1160    void ArtificialController::updatePointsOfInterest(std::string name, float distance)
     1161    {
     1162        WorldEntity* waypoint = NULL;
     1163        if(name == "Pickup")
     1164        {
     1165            for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it != ObjectList<WorldEntity>::end(); ++it)
     1166            {
     1167                //get POI by string: Possible POIs are PICKUPSPAWNER, FORCEFIELDS (!analyse!), ...
     1168                //if(it->isA(Pickupable)) //distance to POI decides wether it is added (neither too close nor too far away)
     1169                //To Think: how should POI's be managed? (e.g. if there are no real moving target or if the can be taken "en passant".)
     1170                   waypoint = *it;
     1171                /*const Vector3 realDistance = it->getPosition() - this->getControllableEntity()->getPosition();
     1172                if( realDistance.length() < distance)
     1173                {
     1174                    float minDistance = it->getTriggerDistance().length()*it->getTriggerDistance().length();
     1175                    if(this->squaredaccuracy_ > minDistance)
     1176                        this->squaredaccuracy_ = minDistance;
     1177                    //waypoint = static_cast<WorldEntity*>(it);
     1178                    break;
     1179               // }*/
     1180            }
     1181        }
     1182        if(waypoint)
     1183            this->waypoints_.push_back(waypoint);
     1184    }
     1185
    11421186}
Note: See TracChangeset for help on using the changeset viewer.