2 Dec 2004 20:50
cel/plugins/tools/quests trig_entersector.cpp,NONE,1.1 trig_entersector.h,NONE,1.1 Jamfile,1.1,1.2 quests.cpp,1.4,1.5 quests.h,1.3,1.4
Update of /cvsroot/cel/cel/plugins/tools/quests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14510/plugins/tools/quests
Modified Files:
Jamfile quests.cpp quests.h
Added Files:
trig_entersector.cpp trig_entersector.h
Log Message:
- Jorrit continued working on the quest manager. The first predefined
trigger (cel.questtrigger.entersector) is created. This trigger
is not functional yet.
--- NEW FILE: trig_entersector.cpp ---
/*
Crystal Space Entity Layer
Copyright (C) 2004 by Jorrit Tyberghein
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "cssysdef.h"
#include "csutil/objreg.h"
#include "csutil/dirtyaccessarray.h"
#include "csutil/util.h"
#include "iutil/evdefs.h"
#include "iutil/event.h"
#include "iutil/document.h"
#include "plugins/tools/quests/trig_entersector.h"
//---------------------------------------------------------------------------
SCF_IMPLEMENT_IBASE (celEnterSectorTriggerType)
SCF_IMPLEMENTS_INTERFACE (iQuestTriggerType)
SCF_IMPLEMENT_IBASE_END
celEnterSectorTriggerType::celEnterSectorTriggerType (
iObjectRegistry* object_reg)
{
SCF_CONSTRUCT_IBASE (0);
celEnterSectorTriggerType::object_reg = object_reg;
}
celEnterSectorTriggerType::~celEnterSectorTriggerType ()
{
SCF_DESTRUCT_IBASE ();
}
csPtr<iQuestTriggerFactory> celEnterSectorTriggerType::CreateTriggerFactory ()
{
celEnterSectorTriggerFactory* fact = new
celEnterSectorTriggerFactory ();
return fact;
}
//---------------------------------------------------------------------------
SCF_IMPLEMENT_IBASE (celEnterSectorTriggerFactory)
SCF_IMPLEMENTS_INTERFACE (iQuestTriggerFactory)
SCF_IMPLEMENTS_INTERFACE (iEnterSectorQuestTriggerFactory)
SCF_IMPLEMENT_IBASE_END
celEnterSectorTriggerFactory::celEnterSectorTriggerFactory ()
{
SCF_CONSTRUCT_IBASE (0);
entity_name = 0;
sector_name = 0;
}
celEnterSectorTriggerFactory::~celEnterSectorTriggerFactory ()
{
delete[] entity_name;
delete[] sector_name;
SCF_DESTRUCT_IBASE ();
}
csPtr<iQuestTrigger> celEnterSectorTriggerFactory::CreateTrigger (
const csHash<csStrKey,csStrKey,csConstCharHashKeyHandler>& params)
{
celEnterSectorTrigger* trig = new celEnterSectorTrigger ();
return trig;
}
bool celEnterSectorTriggerFactory::Load (iDocumentNode* node)
{
return false;
}
void celEnterSectorTriggerFactory::SetEntityName (const char* entity_name)
{
if (celEnterSectorTriggerFactory::entity_name == entity_name) return;
delete[] celEnterSectorTriggerFactory::entity_name;
celEnterSectorTriggerFactory::entity_name = csStrNew (entity_name);
}
void celEnterSectorTriggerFactory::SetSectorName (const char* sector_name)
{
if (celEnterSectorTriggerFactory::sector_name == sector_name) return;
delete[] celEnterSectorTriggerFactory::sector_name;
celEnterSectorTriggerFactory::sector_name = csStrNew (sector_name);
}
//---------------------------------------------------------------------------
SCF_IMPLEMENT_IBASE (celEnterSectorTrigger)
SCF_IMPLEMENTS_INTERFACE (iQuestTrigger)
SCF_IMPLEMENT_IBASE_END
celEnterSectorTrigger::celEnterSectorTrigger ()
{
SCF_CONSTRUCT_IBASE (0);
}
celEnterSectorTrigger::~celEnterSectorTrigger ()
{
SCF_DESTRUCT_IBASE ();
}
void celEnterSectorTrigger::RegisterCallback (iQuestTriggerCallback* callback)
{
celEnterSectorTrigger::callback = callback;
}
void celEnterSectorTrigger::ClearCallback ()
{
callback = 0;
}
void celEnterSectorTrigger::NewSector (iCamera* camera, iSector* sector)
{
callback->TriggerFired ((iQuestTrigger*)this);
}
//---------------------------------------------------------------------------
--- NEW FILE: trig_entersector.h ---
/*
Crystal Space Entity Layer
Copyright (C) 2004 by Jorrit Tyberghein
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CEL_TOOLS_QUESTS_TRIG_ENTERSECTOR__
#define __CEL_TOOLS_QUESTS_TRIG_ENTERSECTOR__
#include "csutil/util.h"
#include "csutil/refarr.h"
#include "iutil/comp.h"
#include "iutil/eventh.h"
#include "iutil/eventq.h"
#include "iutil/virtclk.h"
#include "tools/questmanager.h"
#include "iengine/camera.h"
struct iObjectRegistry;
struct iEvent;
/**
* A standard trigger type that triggers whenever the camera
* enters a specific sector. This trigger type listens to the
* name 'cel.questtrigger.entersector'.
*/
class celEnterSectorTriggerType : public iQuestTriggerType
{
private:
iObjectRegistry* object_reg;
public:
celEnterSectorTriggerType (iObjectRegistry* object_reg);
virtual ~celEnterSectorTriggerType ();
SCF_DECLARE_IBASE;
virtual const char* GetName () const
{
return "cel.questtrigger.entersector";
}
virtual csPtr<iQuestTriggerFactory> CreateTriggerFactory ();
};
/**
* The 'entersector' trigger factory.
*/
class celEnterSectorTriggerFactory :
public iQuestTriggerFactory,
public iEnterSectorQuestTriggerFactory
{
private:
char* entity_name;
char* sector_name;
public:
celEnterSectorTriggerFactory ();
virtual ~celEnterSectorTriggerFactory ();
SCF_DECLARE_IBASE;
virtual csPtr<iQuestTrigger> CreateTrigger (
const csHash<csStrKey,csStrKey,csConstCharHashKeyHandler>& params);
virtual bool Load (iDocumentNode* node);
//----------------- iEnterSectorQuestTriggerFactory ----------------------
virtual void SetEntityName (const char* entity_name);
virtual void SetSectorName (const char* sector_name);
};
/**
* The 'entersector' trigger.
*/
class celEnterSectorTrigger :
public iQuestTrigger,
public iCameraSectorListener
{
private:
csRef<iQuestTriggerCallback> callback;
public:
celEnterSectorTrigger ();
virtual ~celEnterSectorTrigger ();
SCF_DECLARE_IBASE;
virtual void RegisterCallback (iQuestTriggerCallback* callback);
virtual void ClearCallback ();
//----------------------- iCameraSectorListener --------------------------
virtual void NewSector (iCamera* camera, iSector* sector);
};
#endif // __CEL_TOOLS_QUESTS_TRIG_ENTERSECTOR__
Index: Jamfile
===================================================================
RCS file: /cvsroot/cel/cel/plugins/tools/quests/Jamfile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Jamfile 4 Oct 2004 19:00:20 -0000 1.1
+++ Jamfile 2 Dec 2004 19:50:43 -0000 1.2
<at> <at> -1,7 +1,7 <at> <at>
SubDir TOP plugins tools quests ;
Plugin mgr_quests
- : quests.cpp quests.h
+ : quests.cpp quests.h trig_entersector.cpp trig_entersector.h
;
ExternalLibs mgr_quests : CRYSTAL ;
Index: quests.cpp
===================================================================
RCS file: /cvsroot/cel/cel/plugins/tools/quests/quests.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- quests.cpp 2 Dec 2004 13:03:36 -0000 1.4
+++ quests.cpp 2 Dec 2004 19:50:43 -0000 1.5
<at> <at> -25,6 +25,7 <at> <at>
#include "iutil/event.h"
#include "plugins/tools/quests/quests.h"
+#include "plugins/tools/quests/trig_entersector.h"
//---------------------------------------------------------------------------
<at> <at> -160,6 +161,11 <at> <at>
{
celQuestManager::object_reg = object_reg;
+ celEnterSectorTriggerType* type_es = new celEnterSectorTriggerType (
+ object_reg);
+ RegisterTriggerType (type_es);
+ type_es->DecRef ();
+
return true;
}
Index: quests.h
===================================================================
RCS file: /cvsroot/cel/cel/plugins/tools/quests/quests.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- quests.h 2 Dec 2004 13:03:36 -0000 1.3
+++ quests.h 2 Dec 2004 19:50:43 -0000 1.4
<at> <at> -92,6 +92,7 <at> <at>
virtual iQuestStateFactory* GetState (const char* name);
virtual iQuestStateFactory* CreateState (const char* name);
};
+
/**
* This is a manager for quests.
*/
RSS Feed