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 "SpawnChildren.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 #include "sim/pos/PosComponent.hpp" 00028 #include "sim/physics/PhysicsComponent.hpp" 00029 00030 using namespace se_core; 00031 00032 namespace se_basic { 00033 SpawnChildren 00034 ::SpawnChildren() 00035 : se_core::Action("SpawnChildren") 00036 , PROPERTY_SPAWN(Property::hash("Action.SPAWN_CHILDREN")) 00037 , PROPERTY_SPAWN_POINT(Property::hash("Action.SPAWN_CHILDREN_POINT")) 00038 { 00039 } 00040 00041 00042 void SpawnChildren 00043 ::perform(long when, ActionComponent& perf, Parameter& parameter) const { 00044 StatComponent::Ptr pStat(perf); 00045 SpawnComponent::Ptr pSpawn(perf); 00046 const Property* prop = pStat->property(PROPERTY_SPAWN); 00047 if(prop) { 00048 PosComponent::Ptr pos(perf); 00049 const Property* propPoint = pStat->property(PROPERTY_SPAWN_POINT); 00050 for(unsigned int i = 0; i < prop->valueCount(); ++i) { 00051 Composite* s = pSpawn->spawn(prop->string(i), propPoint->shortValue() + i); 00052 PosComponent::Ptr childPos(s); 00053 if(!childPos.isNull() && !pos.isNull()) { 00054 PosComponent::Ptr(*s)->nextPos().setParent(*pos, true); 00055 CollisionComponent::Ptr cc1(*s); 00056 CollisionComponent::Ptr cc2(perf); 00057 if(!cc1.isNull() && !cc2.isNull()) 00058 cc1->setIgnore(*cc2); 00059 00060 StatComponent::Ptr(*s)->setShouldSave(false); 00061 } 00062 } 00063 00064 } 00065 else { 00066 Param* p = static_cast<Param*>(parameter.data(sizeof(Param))); 00067 pSpawn->spawn(p->thingType_, p->SpawnChildrenPoint_); 00068 } 00069 } 00070 00071 00072 const SpawnChildren& SpawnChildren 00073 ::param(const char* thingType, short SpawnChildrenPoint, Parameter& out) const { 00074 Param* p = static_cast<Param*>(out.data(sizeof(Param))); 00075 *p = Param(thingType, SpawnChildrenPoint); 00076 return *this; 00077 } 00078 00079 00080 const SpawnChildren actionSpawnChildren; 00081 } 00082
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:02 2007 by Doxygen version 1.3.9.1.