00001 /* 00002 SagaEngine library 00003 Copyright (c) 2002-2006 Skalden Studio AS 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to distribute the library under the terms of the 00010 Q Public License version 1.0. Be sure to read and understand the license 00011 before using the library. It should be included here, or you may read it 00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl 00013 00014 The original version of this library can be located at: 00015 http://www.sagaengine.com/ 00016 00017 Rune Myrland 00018 rune@skalden.com 00019 */ 00020 00021 00022 #include "Spawn.hpp" 00023 #include "sim/schema/SimSchema.hpp" 00024 #include "sim/pos/Pos.hpp" 00025 #include "sim/thing/Actor.hpp" 00026 #include "sim/spawn/SpawnComponent.hpp" 00027 00028 using namespace se_core; 00029 00030 namespace se_basic { 00031 Spawn 00032 ::Spawn() 00033 : se_core::Action("Spawn") 00034 , PROPERTY_SPAWN(Property::hash("Action.SPAWN")) 00035 , PROPERTY_SPAWN_POINT(Property::hash("Action.SPAWN_POINT")) 00036 , PROPERTY_SPAWN_MAX(Property::hash("Action.SPAWN_MAX")) 00037 { 00038 } 00039 00040 00041 void Spawn 00042 ::perform(long when, ActionComponent& perf, Parameter& parameter) const { 00043 StatComponent::Ptr pStat(perf); 00044 SpawnComponent::Ptr pSpawn(perf); 00045 const Property* prop = pStat->property(PROPERTY_SPAWN); 00046 if(prop) { 00047 const Property* propPoint = pStat->property(PROPERTY_SPAWN_POINT); 00048 const Property* propMax = pStat->property(PROPERTY_SPAWN_MAX); 00049 00050 if(!propMax || propMax->shortValue() > pSpawn->spawnCount()) { 00051 pSpawn->spawn(prop->string(), propPoint->shortValue()); 00052 } 00053 00054 } 00055 else { 00056 Param* p = static_cast<Param*>(parameter.data(sizeof(Param))); 00057 pSpawn->spawn(p->thingType_, p->spawnPoint_); 00058 } 00059 } 00060 00061 00062 const Spawn& Spawn 00063 ::param(const char* thingType, short spawnPoint, Parameter& out) const { 00064 Param* p = static_cast<Param*>(out.data(sizeof(Param))); 00065 *p = Param(thingType, spawnPoint); 00066 return *this; 00067 } 00068 00069 00070 const Spawn actionSpawn; 00071 } 00072
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:02 2007 by Doxygen version 1.3.9.1.