Resurrection.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/Resurrection.h>
00022 #include <engine/ActionController.h>
00023 #include <engine/ScorchedContext.h>
00024 #include <landscapemap/DeformLandscape.h>
00025 #include <common/ChannelManager.h>
00026 #include <common/OptionsScorched.h>
00027 #include <tank/TankContainer.h>
00028 #include <tank/TankState.h>
00029 #include <target/TargetLife.h>
00030 #include <lang/LangResource.h>
00031 #ifndef S3D_SERVER
00032         #include <land/VisibilityPatchGrid.h>
00033 #endif
00034 
00035 Resurrection::Resurrection(
00036         unsigned int playerId,
00037         FixedVector &position) :
00038         ActionReferenced("Resurrection"),
00039         playerId_(playerId),
00040         position_(position)
00041 {
00042 
00043 }
00044 
00045 Resurrection::~Resurrection()
00046 {
00047 }
00048 
00049 void Resurrection::init()
00050 {
00051 }
00052 
00053 void Resurrection::simulate(fixed frameTime, bool &remove)
00054 {
00055         remove = true;
00056 
00057         Tank *tank = context_->getTankContainer().getTankById(playerId_);
00058         if (tank)
00059         {
00060 #ifndef S3D_SERVER
00061                 {
00062                         ChannelText text("combat",
00063                                 LANG_RESOURCE_2(
00064                                         "TANK_RESURRECTED", 
00065                                         "[p:{0}] was resurrected, {1} lives remaining",
00066                                         tank->getTargetName(),
00067                                         S3D::formatStringBuffer("%i", tank->getState().getLives())));
00068                         ChannelManager::showText(*context_, text);
00069                 }
00070 #endif
00071 
00072                 if (context_->getOptionsGame().getActionSyncCheck())
00073                 {
00074                         context_->getActionController().addSyncCheck(
00075                                 S3D::formatStringBuffer("TankRez: %u %i, %i, %i", 
00076                                         tank->getPlayerId(),
00077                                         position_[0].getInternal(),
00078                                         position_[1].getInternal(),
00079                                         position_[2].getInternal()));
00080                 }
00081 
00082                 // Rez this tank
00083                 tank->rezTank();
00084                 tank->getLife().setTargetPosition(position_);
00085                 DeformLandscape::flattenArea(*context_, position_);
00086 #ifndef S3D_SERVER
00087                 if (!context_->getServerMode())
00088                 {
00089                         VisibilityPatchGrid::instance()->recalculateErrors(position_, 2);
00090                 }
00091 #endif
00092         }
00093 
00094         Action::simulate(frameTime, remove);
00095 }

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