1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "fsCEntityFactory.h"

#include <fsCore/src/debug/fsAssert.h>

#include "fsCEntity.h"


void fsCEntityFactory::merge(fsCEntityFactory* const pRHS)
{
	mPlans.insert(pRHS->mPlans.begin(), pRHS->mPlans.end());
}

fsCEntity* fsCEntityFactory::emptyEntityCreate(const fsStr& pEntityName) const<--- The member function 'fsCEntityFactory::emptyEntityCreate' can be static.
{
	fsCEntity* const retEnt = new fsCEntity(pEntityName);
	return retEnt;
}

fsCEntity* fsCEntityFactory::entityConstructWithComponent(const fsStr& pEntityName, fsCUniqueId pComponentId) const
{
	fsCEntity* const retEnt = emptyEntityCreate(pEntityName);
	retEnt->componentAdd(pComponentId);
	retEnt->init();
	return retEnt;
}

fsCEntity* fsCEntityFactory::entityConstruct(const fsStr& pEntityName) const
{
	fsCEntity* const retEnt = emptyEntityCreate(pEntityName);

	const fsStr& entPrefix = entityPrefixGet(pEntityName);
	auto plan = mPlans.find(entPrefix);

	if (mPlans.end() != plan)
	{
		for (fsCUniqueId compId : plan->second)
		{
			retEnt->componentAdd(compId);
		}

		retEnt->init();
	}

	return retEnt;
}

fsStr fsCEntityFactory::entityPrefixGet(const fsStr& pEntityName) const<--- The member function 'fsCEntityFactory::entityPrefixGet' can be static.
{
	fsStr::sizeT matchPos = pEntityName.find("-");
	fsAssert(fsStr::npos != matchPos, "Expected a prefix on entity name %s.\n", pEntityName.utf8Get());
	fsStr prefix;
	prefix.copy(pEntityName.utf8Get(), 0, matchPos + 1);
	return prefix;
}

void fsCEntityFactory::constructionPlansRegister()
{
	mHierarchyCheck = false;

	constructionPlansRegisterDo();

	fsAssert(mHierarchyCheck, "All derived classes need to call super::constructionPlansRegisterDo()\n");
}

void fsCEntityFactory::constructionPlansRegisterDo()
{
	mHierarchyCheck = true;
}

fsCEntityFactory::fsCEntityFactory() :
	mHierarchyCheck(false)
{
}

fsCEntityFactory::~fsCEntityFactory()
{
}