From: Anders R. <ma...@us...> - 2003-09-28 13:09:09
|
Update of /cvsroot/planeshift/planeshift/src/client/effects In directory sc8-pr-cvs1:/tmp/cvs-serv20646/src/client/effects Modified Files: psspelleffect.cpp psspelleffect.h Removed Files: psemittereffect.cpp psemittereffect.h psexplotioneffect.cpp psexplotioneffect.h psfountaineffect.cpp psfountaineffect.h psmeshballeffect.cpp psmeshballeffect.h psspiraleffect.cpp psspiraleffect.h Log Message: - A update from Chen Yue Feng: - Use CS load functions to load spell effects. - Created a spell effect manager. - Cleanup of the spell effect system: Removed old code Index: psspelleffect.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/effects/psspelleffect.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** psspelleffect.cpp 26 Aug 2003 17:19:07 -0000 1.3 --- psspelleffect.cpp 28 Sep 2003 11:48:11 -0000 1.4 *************** *** 1,5 **** - /* ! * psclientchar.cpp * * Copyright (C) 2002 PlaneShift Team (in...@pl..., --- 1,4 ---- /* ! * psspelleffect.cpp * * Copyright (C) 2002 PlaneShift Team (in...@pl..., *************** *** 23,29 **** --- 22,32 ---- // CS INCLUDES #include <csutil/xmltiny.h> + #include <imesh/partsys.h> // PS INCLUDES #include "util/log.h" + #include "iclient/psengine.h" + #include "iclient/isoundmngr.h" + #include "psspelleffect.h" *************** *** 36,50 **** psSpellEffect::~psSpellEffect() { } bool psSpellEffect::Update(csTicks elapsed_time) { ! if (duration > elapsed_time) { duration -= elapsed_time; return true; } ! EndEffect(); ! return false; } --- 39,106 ---- psSpellEffect::~psSpellEffect() { + effectobjects.DeleteAll(); } bool psSpellEffect::Update(csTicks elapsed_time) { ! int length = effectobjects.Length(); ! for(int i=0; i < length; i++) ! { ! int delay = effectobjects[i]->delay; ! if(effectobjects[i]->delay > elapsed_time) ! { ! effectobjects[i]->delay -= elapsed_time; ! } ! else ! { ! if(effectobjects[i]->delay != 0) ! { ! TakeEffect(i); ! effectobjects[i]->delay = 0; ! } ! if(effectobjects[i]->duration>elapsed_time) ! { ! effectobjects[i]->duration -= elapsed_time; ! } ! else ! { ! EndEffect(i); ! } ! } ! } ! ! if(duration > elapsed_time) { duration -= elapsed_time; return true; } ! else ! { ! EndEffect(); ! return false; ! } ! } ! ! void psSpellEffect::EndEffect() ! { ! int length = this->effectmeshs.Length(); ! int i =0; ! for(i; i < length; i++) ! { ! int j = engine->GetMeshes()->Find(effectmeshs[i]); ! if(j >=0 && j < engine->GetMeshes()->GetCount()) ! engine->GetMeshes()->Remove(j); ! } ! effectmeshs.DeleteAll(); ! ! } ! ! void psSpellEffect::EndEffect(int i) ! { ! int length = this->effectmeshs.Length(); ! if(length > i && i >= 0) ! { ! engine->GetMeshes()->Remove(effectmeshs[i]); ! } } *************** *** 53,59 **** csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem); CS_ASSERT( xml ); ! csRef<iDocument> doc = xml->CreateDocument(); ! const char* error = doc->Parse( effect_update ); if ( error ) --- 109,115 ---- csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem); CS_ASSERT( xml ); ! csRef<iDocument> doc = xml->CreateDocument(); ! const char* error = doc->Parse( effect_update ); if ( error ) *************** *** 62,71 **** return; } ! csRef<iDocumentNode> root = doc->GetRoot(); ! Load(root); } ! void psSpellEffect::CopyEffect(psSpellEffect*spellEffect) { name = spellEffect->name; --- 118,127 ---- return; } ! csRef<iDocumentNode> root = doc->GetRoot(); ! Load(root); } ! void psSpellEffect::CopyEffect(psSpellEffect* spellEffect) { name = spellEffect->name; *************** *** 73,76 **** --- 129,181 ---- animation = spellEffect->animation; sound = spellEffect->sound; + for(int i=0; i < spellEffect->effectobjects.Length(); i++) + { + psEffectObject *object = new psEffectObject(); + object->Copy(spellEffect->effectobjects[i]); + effectobjects.Push(object); + } + } + + bool psSpellEffect::StartEffect(iCelEntity * entity,iSector* sector, const csVector3& center, csTicks duration, iObjectRegistry *objectreg) + { + SetDuration(duration); + this->sector=sector; + this->center=center; + //effectmeshs.DeleteAll(); + engine = CS_QUERY_REGISTRY(objectreg,iEngine); + + csRef<iPSEngine> psengine = CS_QUERY_REGISTRY(objectreg, iPSEngine); + if (animation != "" && entity == psengine->GetCelClient()->GetMainActor()) + { + psengine->SetAnimation(animation,entity); + } + + csRef<iSoundManager> soundmanager = psengine->GetSoundManager(); + if (soundmanager){ + soundmanager->PlaySound (sound); + } + + int length = effectobjects.Length(); + int i=0; + for(i;i<length;i++) + { + if(effectobjects[i]->delay == 0) + { + TakeEffect(i); + } + } + return true; } + + void psSpellEffect::TakeEffect(int i) + { + if(i >= 0 && i < effectobjects.Length()) + { + csRef<iMeshWrapper> src = effectobjects[i]->mesh; + csRef<iMeshWrapper>out = engine->CreateMeshWrapper(src->GetMeshObject(),effectobjects[i]->name,sector,center); + if(out) + effectmeshs.Push(out); + effectmeshs[i]->PlaceMesh(); + } + } Index: psspelleffect.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/effects/psspelleffect.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** psspelleffect.h 18 Sep 2003 16:11:12 -0000 1.6 --- psspelleffect.h 28 Sep 2003 11:48:11 -0000 1.7 *************** *** 21,24 **** --- 21,25 ---- #define __SPELLEFFECT_H__ + #include <csutil/refarr.h> #include <csutil/refcount.h> #include <iutil/document.h> *************** *** 26,54 **** #include <csutil/csstring.h> #include <csgeom/vector3.h> struct iSector; ! class psSpellEffect : public csRefCount { public: ! psSpellEffect(csString& effectName); ! virtual ~psSpellEffect(); ! virtual csString& GetName(){ return name; } ! void SetName(csString& effectName) { name = effectName; } ! void SetDuration(csTicks effectDuration) { duration = effectDuration; } ! virtual bool Update(csTicks elapsed_time); ! virtual void EndEffect(){}; ! virtual void Load(csString& effect_update); ! ! virtual bool Load(iDocumentNode *node) = 0; ! virtual bool StartEffect(iSector* sector, const csVector3& center, csTicks duration, iObjectRegistry *objectreg) = 0; ! virtual bool NeedCloning(){ return false; } ! virtual psSpellEffect* Clone() = 0; ! virtual void CopyEffect(psSpellEffect*spellEffect); ! csString animation; ! csString sound; private: ! csString name; ! csTicks duration; }; --- 27,65 ---- #include <csutil/csstring.h> #include <csgeom/vector3.h> + #include "pscelclient.h" + #include "pseffectobject.h" + struct iSector; ! class psSpellEffect : public csObject { public: ! psSpellEffect(csString& effectName); ! virtual ~psSpellEffect(); ! virtual csString& GetName(){ return name; } ! void SetName(csString& effectName) { name = effectName; } ! void SetDuration(csTicks effectDuration) { duration = effectDuration; } ! virtual bool Update(csTicks elapsed_time); ! virtual void EndEffect(); ! virtual void EndEffect(int i); ! virtual void TakeEffect(int i); ! virtual void Load(csString& effect_update); ! ! virtual bool Load(iDocumentNode *node){return true;}; ! virtual bool StartEffect(iCelEntity * entity,iSector* sector, const csVector3& center, csTicks duration, iObjectRegistry *objectreg); ! virtual bool NeedCloning(){return false;} ! virtual psSpellEffect* Clone(){return NULL;}; ! virtual void CopyEffect(psSpellEffect*spellEffect); ! csString animation; ! csString sound; ! csRefArray<psEffectObject> effectobjects; ! csRefArray<iMeshWrapper> effectmeshs;; private: ! csString name; ! csTicks duration; ! csRef<iEngine> engine; ! iSector* sector; ! csVector3 center; }; --- psemittereffect.cpp DELETED --- --- psemittereffect.h DELETED --- --- psexplotioneffect.cpp DELETED --- --- psexplotioneffect.h DELETED --- --- psfountaineffect.cpp DELETED --- --- psfountaineffect.h DELETED --- --- psmeshballeffect.cpp DELETED --- --- psmeshballeffect.h DELETED --- --- psspiraleffect.cpp DELETED --- --- psspiraleffect.h DELETED --- |