AddTarget.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <actions/AddTarget.h>
00022 #include <engine/ActionController.h>
00023 #include <engine/ScorchedContext.h>
00024 #include <target/TargetContainer.h>
00025 #include <target/TargetDamageCalc.h>
00026 #include <tankai/TankAIAdder.h>
00027 #include <weapons/AccessoryStore.h>
00028 #include <weapons/WeaponAddTarget.h>
00029 #include <weapons/Shield.h>
00030 #include <common/RandomGenerator.h>
00031 #include <common/OptionsScorched.h>
00032 
00033 AddTarget::AddTarget(FixedVector &position,
00034         WeaponAddTarget *addTarget) :
00035         ActionReferenced("AddTarget"),
00036         position_(position),
00037         addTarget_(addTarget)
00038 {
00039 
00040 }
00041 
00042 AddTarget::~AddTarget()
00043 {
00044 }
00045 
00046 void AddTarget::init()
00047 {
00048 }
00049 
00050 void AddTarget::simulate(fixed frameTime, bool &remove)
00051 {
00052         unsigned int playerId = TankAIAdder::getNextTargetId(*context_);
00053 
00054         Target *target = addTarget_->getTargetDefinition().createTarget(
00055                 playerId, position_, FixedVector::getNullVector(), *context_, 
00056                 context_->getActionController().getRandom());
00057         context_->getTargetContainer().addTarget(target);
00058 
00059         if (context_->getOptionsGame().getActionSyncCheck())
00060         {
00061                 context_->getActionController().addSyncCheck(
00062                         S3D::formatStringBuffer("AddTarget : %u %s %i,%i,%i", 
00063                                 playerId,
00064                                 target->getCStrName().c_str(),
00065                                 position_[0].getInternal(),
00066                                 position_[1].getInternal(),
00067                                 position_[2].getInternal()));
00068         }
00069 
00070         // Check if this new target can fall
00071         WeaponFireContext weaponContext(0, 0);
00072         TargetDamageCalc::damageTarget(*context_, target, addTarget_, 
00073                 weaponContext, 0, false, true, false);
00074 
00075         remove = true;
00076         Action::simulate(frameTime, remove);
00077 }
00078 
00079 std::string AddTarget::getActionDetails()
00080 {
00081         return addTarget_->getParent()->getName();
00082 }

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3