예제 #1
0
void ActorSet::load(const PropertyBag &objects, World *_world)
{
	ASSERT(_world!=0, "world was null");
	world = _world;

	for(size_t i=0, n=objects.getNumInstances("object"); i<n; ++i)
	{
		const tuple<OBJECT_ID, ActorPtr> t = create();
		const ActorPtr object = t.get<1>();

		const PropertyBag decl = objects.getBag("object", i);
		const FileName templateFile = decl.getFileName("template");
		const vec3 initialPosition = decl.getVec3("position");
		const PropertyBag templateData = PropertyBag::fromFile(templateFile);
		const PropertyBag base = templateData.getBag("components");

		ComponentDataSet s = ComponentDataSet::load(base, decl);

		// get actor name
		object->actorName = "(no name)";
		templateData.get("name", object->actorName);

		object->load(s, initialPosition, vec3(0,0,0), world);
		object->setParentBlackBoard(this);
	}
}
예제 #2
0
tuple<OBJECT_ID, ActorPtr> ActorSet::create()
{
	ActorFactory &factory = getActorFactory();
	const tuple<OBJECT_ID, ActorPtr> t = factory.create();
	const OBJECT_ID id = t.get<0>();
	const ActorPtr actor = t.get<1>();
	actors.insert(make_pair(id, actor)); // record it in this actor set
	registerSubscriber(actor);           // record it in the blackboard
	actor->setParentBlackBoard(this);
	return t;
}