00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "sceneeffector.h"
00024 #include "sceneaction.h"
00025 #include <zeitgeist/logserver/logserver.h>
00026 #include <oxygen/gamecontrolserver/actionobject.h>
00027 #include <oxygen/agentaspect/agentaspect.h>
00028
00029 using namespace boost;
00030 using namespace oxygen;
00031 using namespace zeitgeist;
00032 using namespace std;
00033
00034 SceneEffector::SceneEffector() : oxygen::Effector()
00035 {
00036 }
00037
00038 SceneEffector::~SceneEffector()
00039 {
00040 }
00041
00042 bool SceneEffector::Realize(boost::shared_ptr<ActionObject> action)
00043 {
00044 shared_ptr<SceneAction> sceneAction =
00045 shared_dynamic_cast<SceneAction>(action);
00046
00047 if (sceneAction.get() == 0)
00048 {
00049 GetLog()->Error()
00050 << "(SceneEffector) ERROR: cannot realize "
00051 << "an unknown ActionObject\n";
00052 return false;
00053 }
00054
00055 boost::shared_ptr<AgentAspect> aspect =GetAgentAspect();
00056
00057 if (aspect.get() == 0)
00058 {
00059 GetLog()->Error()
00060 << "(SceneEffector) ERROR: cannot get AgentAspect\n";
00061 return false;
00062 }
00063
00064 aspect->ImportScene(sceneAction->GetScene(), shared_ptr<ParameterList>());
00065 return true;
00066 }
00067
00068 shared_ptr<ActionObject>
00069 SceneEffector::GetActionObject(const Predicate& predicate)
00070 {
00071 if (predicate.name != GetPredicate())
00072 {
00073 GetLog()->Error() << "(SceneEffector) ERROR: invalid predicate"
00074 << predicate.name << "\n";
00075 return shared_ptr<ActionObject>();
00076 }
00077
00078 string scene;
00079 if (! predicate.GetValue(predicate.begin(), scene))
00080 {
00081 GetLog()->Error()
00082 << "ERROR: (SceneEffector) scene filename expected\n";
00083 return shared_ptr<ActionObject>();
00084 };
00085
00086 return shared_ptr<ActionObject>(new SceneAction(GetPredicate(),scene));
00087 }
00088
00089