From b17afecd4bf36a4b911ac71a57d6771ef3b4445f Mon Sep 17 00:00:00 2001 From: fgenesis Date: Fri, 9 Dec 2022 04:20:17 +0100 Subject: [PATCH] Remove 3 unused Lua functions: - entityFollowEntity() - entity_followEntity() - entity_isFollowingEntity() --- Aquaria/Entity.cpp | 57 ------------------- Aquaria/Entity.h | 2 - Aquaria/ScriptInterface.cpp | 40 ------------- .../scripts/compat/internal/oldfunctions.lua | 3 + 4 files changed, 3 insertions(+), 99 deletions(-) diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index 7b97628..d8b81a8 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -208,7 +208,6 @@ Entity::Entity() damageTime = vars->entityDamageTime; slowingToStopPathTimer = 0; slowingToStopPath = 0; - followPos = 0; swimPath = false; currentEntityTarget = 0; deleteOnPathEnd = false; @@ -233,8 +232,6 @@ Entity::Entity() activationRadius = 40; activationRange = 600; - - followEntity = 0; bubble = 0; @@ -452,8 +449,6 @@ float Entity::moveToPos(Vector dest, float speed, int dieOnPathEnd, bool swim) speed = getMaxSpeed(); Vector start = position; - followEntity = 0; - position.ensureData(); position.data->path.clear(); @@ -1597,61 +1592,9 @@ void Entity::onUpdate(float dt) if (getState() == STATE_PUSH) { - vel = pushVec; } - else if (followEntity) - { - Vector lastPos = position; - Vector off; - int sz = 96; - if (followEntity->vel.getSquaredLength2D() > sqr(1)) - { - off = followEntity->vel.getPerpendicularLeft(); - switch (followPos) - { - case 0: off.setLength2D(sz); break; - case 1: off.setLength2D(-sz); break; - } - } - else if (followEntity->lastMove.getSquaredLength2D() > sqr(1)) - { - - off = followEntity->lastMove.getPerpendicularLeft(); - switch (followPos) - { - case 0: off.setLength2D(sz); break; - case 1: off.setLength2D(-sz); break; - } - } - Vector mov = followEntity->position + off - this->position; - if (mov.getSquaredLength2D() > sqr(96)) - { - - int spd = mov.getLength2D(); - spd -= 64; - if (spd < 0) - spd = 0; - else if (spd < 400) - spd *= 2; - - else - spd = 800; - - mov.setLength2D(spd); - position += mov * dt; - Vector diff = position - lastPos; - movementDetails(diff); - } - else - { - Animation *anim = skeletalSprite.getCurrentAnimation(); - if (!anim || anim->name != "idle") - idle(); - } - } - if (stickToNaijasHead) { position = dsq->game->avatar->headPosition; diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index cf18ca8..5e0689a 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -132,7 +132,6 @@ public: ActivationType activationType; float activationRange; - Entity *followEntity; Entity *ridingOnEntity; Vector startPos; void rotateToVec(Vector addVec, float time, float offsetAngle=0); @@ -220,7 +219,6 @@ public: bool isNormalLayer() const; void idle(); - int followPos; void slowToStopPath(float t); bool isSlowingToStopPath(); Vector lastMove; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 0ef2d8b..2bae152 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -6603,42 +6603,6 @@ luaFunc(entity_setCurrentTarget) luaReturnNil(); } -luaFunc(entityFollowEntity) -{ - Entity *e = dsq->getEntityByName(getString(L, 1)); - if (e) - { - e->followEntity = dsq->getEntityByName(getString(L, 2)); - } - - luaReturnNil(); -} - -luaFunc(entity_isFollowingEntity) -{ - Entity *e = entity(L); - bool v = false; - if (e) - v = e->followEntity != 0; - luaReturnBool(v); -} - -luaFunc(entity_followEntity) -{ - Entity *e1 = entity(L); - Entity *e2 = 0; - if (lua_touserdata(L, 2) != NULL) - { - e2 = entity(L, 2); - } - if (e1) - { - e1->followEntity = e2; - e1->followPos = lua_tointeger(L, 3); - } - luaReturnNil(); -} - luaFunc(toggleInput) { bool v = getBool(L, 1); @@ -10300,7 +10264,6 @@ static const struct { luaRegister(entity_followPath), luaRegister(entity_followPathSpeed), luaRegister(entity_isFollowingPath), - luaRegister(entity_followEntity), luaRegister(entity_sound), luaRegister(entity_playSfx), @@ -10355,8 +10318,6 @@ static const struct { luaRegister(toggleBlackBars), luaRegister(setBlackBarsColor), - luaRegister(entityFollowEntity), - luaRegister(bedEffects), luaRegister(warpNaijaToEntity), @@ -10751,7 +10712,6 @@ static const struct { luaRegister(entity_isSlowingToStopPath), luaRegister(entity_findNearestEntityOfType), - luaRegister(entity_isFollowingEntity), luaRegister(entity_resumePath), luaRegister(entity_generateCollisionMask), diff --git a/files/scripts/compat/internal/oldfunctions.lua b/files/scripts/compat/internal/oldfunctions.lua index aafab11..7357f4f 100644 --- a/files/scripts/compat/internal/oldfunctions.lua +++ b/files/scripts/compat/internal/oldfunctions.lua @@ -24,6 +24,8 @@ local WARN_FUNCTIONS = entity_grabTarget = true, entity_releaseTarget = true, entity_watchEntity = true, + entityFollowEntity = true, + entity_followEntity = true, } -- These returned something important, so here we just return a failure/dummy value @@ -72,6 +74,7 @@ local DUMMY_FUNCTIONS = streamSfx = true, toggleVersionLabel = true, setVersionLabelText = true, + entity_isFollowingEntity = true, -- never following anything now since those functions are gone } -- Deprecated stuff from v1.1's scripts/entities/entityinclude.lua