1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-15 05:59:16 +00:00

Remove unused stuff

- entity group IDs
- entity node groups (?!)
- WaterFont.[cpp|h]
This commit is contained in:
fgenesis 2012-12-13 19:57:30 +01:00
parent 8b67ece907
commit 0f13f08357
8 changed files with 21 additions and 331 deletions

View file

@ -217,7 +217,6 @@ Entity::Entity()
targetRange = 32;
//energyChargeTarget = energyShotTarget = true;
deathSound = "GenericDeath";
groupID = 0;
entityID = 0;
//assignUniqueID();
hair = 0;
@ -349,50 +348,6 @@ void Entity::setSpiritFreeze(bool v)
spiritFreeze = v;
}
Vector Entity::getGroupCenter()
{
Vector position;
int sz = 0;
FOR_ENTITIES(i)
{
Entity *e = *i;
if (e->getGroupID() == this->getGroupID())
{
position += e->position;
sz++;
}
}
position/=sz;
return position;
}
Vector Entity::getGroupHeading()
{
Vector v;
int sz = 0;
FOR_ENTITIES(i)
{
Entity *e = *i;
if (e->getGroupID() == this->getGroupID())
{
v += e->vel;
sz++;
}
}
v/=sz;
return v;
}
int Entity::getGroupID()
{
return groupID;
}
void Entity::setGroupID(int g)
{
groupID = g;
}
void Entity::setEntityProperty(EntityProperty ep, bool value)
{
entityProperties[int(ep)] = value;
@ -574,37 +529,6 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
//position.startPath(((position.data->path.getNumPathNodes()*TILE_SIZE*4)-2)/dsq->continuity.getSpeedType(speedType));
}
void Entity::addNodeToNodeGroup(int group, Path *p)
{
nodeGroups[group].push_back(p);
}
void Entity::removeNodeFromAllNodeGroups(Path *p)
{
for (int j = 0; j < nodeGroups.size(); j++)
{
for (int i = 0; i < nodeGroups[j].size(); i++)
{
if (nodeGroups[j][i] == p)
{
nodeGroups[j][i] = 0;
}
}
}
}
void Entity::setNodeGroupActive(int group, bool v)
{
for (int i = 0; i < nodeGroups[group].size(); i++)
{
Path *p = nodeGroups[group][i];
if (p)
{
p->setActive(v);
}
}
}
void Entity::stopFollowingPath()
{
position.stopPath();
@ -2455,24 +2379,6 @@ void Entity::moveTowardsTarget(float dt, int spd, int t)
moveTowards(targets[t]->position, dt, spd);
}
void Entity::moveTowardsGroupCenter(float dt, int speed)
{
if (getGroupID() != 0)
{
moveTowards(getGroupCenter(), dt, speed);
}
}
void Entity::moveTowardsGroupHeading(float dt, int speed)
{
if (getGroupID() != 0)
{
Vector d = getGroupHeading() - position;
d.setLength2D(speed*dt);
vel += d;
}
}
void Entity::moveAroundTarget(float dt, int spd, int dir, int t)
{
if (!targets[t]) return;

View file

@ -392,10 +392,6 @@ public:
InterpolatedVector maxSpeedLerp;
Hair *hair;
void setGroupID(int gid);
int getGroupID();
Vector getGroupCenter();
Vector getGroupHeading();
void assignUniqueID();
int entityID;
@ -424,12 +420,6 @@ public:
bool isCrawling() { return crawling; }
*/
void flipToVel();
typedef std::vector<Path*> NodeGroup;
typedef std::map<int, NodeGroup> NodeGroups;
NodeGroups nodeGroups;
void addNodeToNodeGroup(int group, Path *p);
void setNodeGroupActive(int group, bool v);
void removeNodeFromAllNodeGroups(Path *p);
bool isInCurrent() { return inCurrent; }
void clearTargetPoints();
void addTargetPoint(const Vector &point);
@ -546,7 +536,6 @@ protected:
//Vector backupPos, backupVel;
virtual void onIdle() {}
int groupID;
virtual void onHeal(int type){}
virtual void onDamage(DamageData &d){}
virtual void onHealthChange(float change){}

View file

@ -2532,7 +2532,7 @@ int Game::getIdxForEntityType(std::string type)
return -1;
}
Entity *Game::createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
Entity *Game::createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, bool doPostInit)
{
std::string type;
for (int i = 0; i < dsq->game->entityTypeList.size(); i++)
@ -2541,7 +2541,7 @@ Entity *Game::createEntity(int idx, int id, Vector position, int rot, bool creat
if (ec->idx == idx)
{
type = ec->name;
return createEntity(type, id, position, rot, createSaveData, name, et, nodeGroups, gid, doPostInit);
return createEntity(type, id, position, rot, createSaveData, name, et, doPostInit);
}
}
return 0;
@ -2580,7 +2580,7 @@ void Game::ensureLimit(Entity *e, int num, int state)
}
}
Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, bool doPostInit)
{
// e->layer must be set BEFORE calling this function!
@ -2615,12 +2615,6 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
}
}
// get node groups before calling init
if (nodeGroups)
{
e->nodeGroups = (*nodeGroups);
}
// NOTE: init cannot be called after "addRenderObject" for some unknown reason
e->init();
@ -2629,8 +2623,6 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
if (!name.empty())
e->name = name;
e->setGroupID(gid);
e->rotation.z = rot;
int idx = getIdxForEntityType(type);
@ -2640,7 +2632,7 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
if (createSaveData)
{
int idx = dsq->game->getIdxForEntityType(type);
entitySaveData.push_back(EntitySaveData(e, idx, usePos.x, usePos.y, rot, e->getGroupID(), e->getID(), e->name));
entitySaveData.push_back(EntitySaveData(e, idx, usePos.x, usePos.y, rot, e->getID(), e->name));
}
addRenderObject(e, e->layer);
@ -2653,7 +2645,7 @@ Entity* Game::establishEntity(Entity *e, int id, Vector position, int rot, bool
return e;
}
Entity *Game::createEntity(const std::string &t, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, Entity::NodeGroups *nodeGroups, int gid, bool doPostInit)
Entity *Game::createEntity(const std::string &t, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType et, bool doPostInit)
{
std::string type = t;
stringToLower(type);
@ -2663,7 +2655,7 @@ Entity *Game::createEntity(const std::string &t, int id, Vector position, int ro
e = new ScriptedEntity(type, position, et);
return establishEntity(e, id, position, rot, createSaveData, name, et, nodeGroups, gid, doPostInit);
return establishEntity(e, id, position, rot, createSaveData, name, et, doPostInit);
}
void Game::initEntities()
@ -5109,110 +5101,11 @@ bool Game::loadSceneXML(std::string scene)
TiXmlElement *entitiesNode = doc.FirstChildElement("Entities");
while(entitiesNode)
{
if (entitiesNode->Attribute("d"))
{
SimpleIStringStream is(entitiesNode->Attribute("d"));
int idx, x, y;
while (is >> idx)
{
is >> x >> y;
dsq->game->createEntity(idx, 0, Vector(x,y), 0, true, "");
}
}
if (entitiesNode->Attribute("e"))
{
SimpleIStringStream is(entitiesNode->Attribute("e"));
int idx, x, y, rot;
while (is >> idx)
{
is >> x >> y >> rot;
if (idx == 32)
{
std::ostringstream os;
os << "read in rot as: " << rot;
debugLog(os.str());
}
dsq->game->createEntity(idx, 0, Vector(x,y), rot, true, "");
}
}
if (entitiesNode->Attribute("f"))
{
SimpleIStringStream is(entitiesNode->Attribute("f"));
int idx, x, y, rot, group;
while (is >> idx)
{
is >> x >> y >> rot >> group;
Entity *e = dsq->game->createEntity(idx, 0, Vector(x,y), rot, true, "");
e->setGroupID(group);
}
}
if (entitiesNode->Attribute("g"))
{
SimpleIStringStream is(entitiesNode->Attribute("g"));
int idx, x, y, rot, group, id;
while (is >> idx)
{
is >> x >> y >> rot >> group >> id;
Entity *e = dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "");
e->setGroupID(group);
}
}
if (entitiesNode->Attribute("h"))
{
SimpleIStringStream is(entitiesNode->Attribute("h"));
int idx, x, y, rot, groupID, id;
Entity::NodeGroups *ng;
Entity::NodeGroups nodeGroups;
while (is >> idx)
{
int numNodeGroups = 0;
is >> x >> y >> rot >> groupID >> id;
is >> numNodeGroups;
ng = 0;
nodeGroups.clear();
if (numNodeGroups > 0)
{
ng = &nodeGroups;
for (int i = 0; i < numNodeGroups; i++)
{
int sz;
is >> sz;
for (int j = 0; j < sz; j++)
{
int idx;
is >> idx;
if (idx >= 0 && idx < getNumPaths())
{
nodeGroups[i].push_back(getPath(idx));
}
}
}
}
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, ng, groupID);
// setting group ID
}
}
if (entitiesNode->Attribute("i"))
{
SimpleIStringStream is(entitiesNode->Attribute("i"));
int idx, x, y, rot, groupID, id;
Entity::NodeGroups nodeGroups;
while (is >> idx)
{
is >> x >> y >> rot >> groupID >> id;
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, 0, groupID);
// setting group ID
}
}
if (entitiesNode->Attribute("j"))
{
SimpleIStringStream is(entitiesNode->Attribute("j"));
int idx, x, y, rot, groupID, id;
std::string name;
Entity::NodeGroups nodeGroups;
while (is >> idx)
{
name="";
@ -5221,10 +5114,9 @@ bool Game::loadSceneXML(std::string scene)
is >> x >> y >> rot >> groupID >> id;
if (!name.empty())
dsq->game->createEntity(name, id, Vector(x,y), rot, true, "", ET_ENEMY, 0, groupID);
dsq->game->createEntity(name, id, Vector(x,y), rot, true, "", ET_ENEMY);
else
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY, 0, groupID);
// setting group ID
dsq->game->createEntity(idx, id, Vector(x,y), rot, true, "", ET_ENEMY);
}
}
entitiesNode = entitiesNode->NextSiblingElement("Entities");
@ -5341,22 +5233,6 @@ void Game::setWarpAreaSceneName(WarpArea &warpArea)
}
}
Entity *Game::getEntityInGroup(int gid, int iter)
{
int c = 0;
FOR_ENTITIES(i)
{
Entity *e = *i;
if (e->getGroupID() == gid)
{
if (iter == c)
return e;
c++;
}
}
return 0;
}
bool Game::loadScene(std::string scene)
{
stringToLower(scene);
@ -5552,8 +5428,8 @@ bool Game::saveScene(std::string scene)
else
os << "INVALID" << " ";
}
os << e->x << " " << e->y << " " << e->rot << " " << e->group << " " << e->id << " ";
// group ID no longer used
os << e->x << " " << e->y << " " << e->rot << " " << 0 << " " << e->id << " ";
}
entitiesNode.SetAttribute("j", os.str());
saveFile.InsertEndChild(entitiesNode);

View file

@ -418,7 +418,6 @@ public:
void closeMainMenu();
void setBackgroundGradient();
void addSpringPlant();
bool isOn();
@ -472,12 +471,10 @@ public:
void moveLayer();
void moveElementToLayer(Element *e, int bgLayer);
void toggleElementRepeat();
void setGroup();
bool multiSelecting;
Vector multiSelectPoint;
std::vector <Element*> selectedElements;
void fixEntityIDs();
void bindNodeToEntity();
Vector groupCenter;
Vector getSelectedElementsCenter();
@ -610,9 +607,9 @@ enum ObsType
struct EntitySaveData
{
public:
EntitySaveData(Entity *e, int idx, int x, int y, int rot, int group, int id, const std::string &name) : e(e), idx(idx), x(x), y(y), rot(rot), group(group), id(id), name(name) {}
EntitySaveData(Entity *e, int idx, int x, int y, int rot, int id, const std::string &name) : e(e), idx(idx), x(x), y(y), rot(rot), id(id), name(name) {}
Entity *e;
int idx, x, y, rot, group, id;
int idx, x, y, rot, id;
std::string name;
};
@ -699,7 +696,6 @@ public:
WarpAreas warpAreas;
void postInitEntities();
Entity *getEntityInGroup(int gid, int iter);
EntityClass *getEntityClassForEntityType(const std::string &type);
void warpToArea(WarpArea *area);
@ -744,9 +740,9 @@ public:
MiniMapHint miniMapHint;
void updateMiniMapHintPosition();
EntitySaveData *getEntitySaveDataForEntity(Entity *e, Vector pos);
Entity *createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
Entity *createEntity(const std::string &type, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
Entity *establishEntity(Entity *e, int id=0, Vector position=Vector(0,0), int rot=0, bool createSaveData=false, std::string name="", EntityType = ET_ENEMY, Entity::NodeGroups *nodeGroups=0, int groupID=0, bool doPostInit=false);
Entity *createEntity(int idx, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, bool doPostInit=false);
Entity *createEntity(const std::string &type, int id, Vector position, int rot, bool createSaveData, std::string name, EntityType = ET_ENEMY, bool doPostInit=false);
Entity *establishEntity(Entity *e, int id=0, Vector position=Vector(0,0), int rot=0, bool createSaveData=false, std::string name="", EntityType = ET_ENEMY,bool doPostInit=false);
void setCameraFollow(RenderObject *r);
void setCameraFollowEntity(Entity *e);
void setMenuDescriptionText(const std::string &text);

View file

@ -643,9 +643,6 @@ void SceneEditor::init()
addAction(MakeFunctionEvent(SceneEditor, mouseButtonLeftUp), MOUSE_BUTTON_LEFT, 0);
addAction(MakeFunctionEvent(SceneEditor, mouseButtonRightUp), MOUSE_BUTTON_RIGHT, 0);
// removed in fc3
//addAction(MakeFunctionEvent(SceneEditor, bindNodeToEntity), KEY_B, 0);
addAction(MakeFunctionEvent(SceneEditor, alignHorz), KEY_C, 1);
addAction(MakeFunctionEvent(SceneEditor, alignVert), KEY_V, 1);
@ -879,38 +876,6 @@ void SceneEditor::createAquarian()
inCreateAqurian = false;
}
void SceneEditor::bindNodeToEntity()
{
if (editType == ET_PATHS)
{
Path *p = getSelectedPath();
if (p)
{
std::istringstream is(dsq->getUserInputString("Enter group number"));
int group = 0;
is >> group;
Entity *e = getEntityAtCursor();
if (e)
{
e->removeNodeFromAllNodeGroups(p);
e->addNodeToNodeGroup(group, p);
}
else
{
debugLog("no entity at cursor");
}
}
}
}
void SceneEditor::addSpringPlant()
{
/*
SpringPlant *s = new SpringPlant(dsq->getGameCursorPosition());
dsq->game->addRenderObject(s, LR_ENTITIES);
*/
}
Path *SceneEditor::getSelectedPath()
{
if (selectedIdx >= 0 && selectedIdx < dsq->game->getNumPaths())
@ -1472,7 +1437,6 @@ void SceneEditor::updateEntitySaveData(Entity *editingEntity)
os << "idx2: " << editingEntity->entityTypeIdx << " ";
os << "name: " << editingEntity->name;
//os << "state: " << editingEntity->getState();
os << "groupID: " << editingEntity->getGroupID();
debugLog(os.str());
//debugLog("changing entity save data");
d->x = editingEntity->position.x;
@ -1484,7 +1448,6 @@ void SceneEditor::updateEntitySaveData(Entity *editingEntity)
debugLog(os2.str());
*/
d->rot = editingEntity->rotation.z;
d->group = editingEntity->getGroupID();
}
else
{
@ -1636,25 +1599,6 @@ void SceneEditor::toggleElementHurt()
}
}
void SceneEditor::setGroup()
{
if (editingEntity)
{
std::ostringstream os;
os << editingEntity->getGroupID();
Entity *backup = editingEntity;
std::string value = dsq->getUserInputString("Enter Group", os.str());
int group = 0;
if (!value.empty())
{
std::istringstream is(value);
is >> group;
}
backup->setGroupID(group);
updateEntitySaveData(backup);
}
}
void SceneEditor::toggleElementRepeat()
{
if (editingElement)
@ -3135,9 +3079,9 @@ void SceneEditor::placeElement()
else if (editType == ET_ENTITIES)
{
if (!selectedEntity.nameBased)
dsq->game->createEntity(selectedEntity.index, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, 0, 0, true);
dsq->game->createEntity(selectedEntity.index, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, true);
else
dsq->game->createEntity(selectedEntity.name, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, 0, 0, true);
dsq->game->createEntity(selectedEntity.name, 0, dsq->getGameCursorPosition(), 0, true, "", ET_ENEMY, true);
}
else if (editType == ET_PATHS)
{

View file

@ -2907,7 +2907,7 @@ luaFunc(entity_createEntity)
Entity *e = entity(L);
Entity *ret = NULL;
if (e)
ret = dsq->game->createEntity(dsq->getEntityTypeIndexByName(getString(L, 2)), 0, e->position, 0, false, "", ET_ENEMY, 0, 0, true);
ret = dsq->game->createEntity(dsq->getEntityTypeIndexByName(getString(L, 2)), 0, e->position, 0, false, "", ET_ENEMY, true);
luaReturnPtr(ret);
}
@ -3505,7 +3505,7 @@ luaFunc(createEntity)
int y = lua_tointeger(L, 4);
Entity *e = 0;
e = dsq->game->createEntity(type, 0, Vector(x, y), 0, false, name, ET_ENEMY, 0, 0, true);
e = dsq->game->createEntity(type, 0, Vector(x, y), 0, false, name, ET_ENEMY, true);
luaReturnPtr(e);
}
@ -6048,24 +6048,6 @@ luaFunc(entity_partSetSegs)
luaReturnNil();
}
luaFunc(getEntityInGroup)
{
int gid = lua_tonumber(L, 1);
int iter = lua_tonumber(L, 2);
luaReturnPtr(dsq->game->getEntityInGroup(gid, iter));
}
luaFunc(entity_getGroupID)
{
Entity *e = entity(L);
int id = 0;
if(e)
{
id = e->getGroupID();
}
luaReturnNum(id);
}
luaFunc(entity_getID)
{
Entity *e = entity(L);
@ -7290,8 +7272,6 @@ static const struct {
luaRegister(getWaterLevel),
luaRegister(setWaterLevel),
luaRegister(getEntityInGroup),
luaRegister(createQuad),
luaRegister(setupEntity),
@ -7469,7 +7449,6 @@ static const struct {
luaRegister(entity_move),
luaRegister(entity_getID),
luaRegister(entity_getGroupID),
luaRegister(getEntityByID),

View file

@ -515,7 +515,7 @@ void Shot::onHitWall()
{
if (!shotData->spawnEntity.empty())
{
dsq->game->createEntity(shotData->spawnEntity, 0, position, 0, false, "", ET_ENEMY, 0, 0, true);
dsq->game->createEntity(shotData->spawnEntity, 0, position, 0, false, "", ET_ENEMY, true);
//(shotData->spawnEntity, 0, position, 0, false, "");
if (shotData->spawnEntity == "NatureFormFlowers")
{

View file

@ -348,7 +348,6 @@ SET(AQUARIA_SRCS
${SRCDIR}/SubtitlePlayer.cpp
${SRCDIR}/ToolTip.cpp
${SRCDIR}/UserSettings.cpp
${SRCDIR}/WaterFont.cpp
${SRCDIR}/WaterSurfaceRender.cpp
${SRCDIR}/Web.cpp
${SRCDIR}/WorldMapRender.cpp
@ -361,6 +360,7 @@ SET(AQUARIA_SRCS_UNUSED
${SRCDIR}/BubbleRender.cpp
${SRCDIR}/FFTNotes.cpp
${SRCDIR}/StarRenderer.cpp
${SRCDIR}/WaterFont.cpp
)
IF(MACOSX)