Use render offset instead of shifting Mega Chest pedestal

This commit is contained in:
Buurazu authored and GitHub committed 2021-12-17 03:24:14 -05:00
1 parent efca551ec9
commit 68896a939d
1 file changed
+5 -2
+5 -2
View File
@@ -574,8 +574,7 @@ function EID:onGameUpdate()
local pos = entity.Position
for _, otherPos in ipairs(curPositions) do
if pos:Distance(otherPos[2]) == 0 then
-- adjust the position so Mega Chests can have both descriptions viewable
entity.Position = entity.Position + Vector(1,0)
--entity.Position = entity.Position + Vector(1,0)
entity:GetData()["EID_RenderOffset"] = Vector(10,0)
otherPos[1]:GetData()["EID_RenderOffset"] = Vector(-10,0)
end
@@ -750,6 +749,10 @@ local function onRender(t)
for i, entity in ipairs(entitySearch) do
if EID:hasDescription(entity) and entity.FrameCount > 0 then
local diff = entity.Position:__sub(sourcePos)
-- break ties with the render offset (for Mega Chest double collectibles)
if diff:Length() == EID.lastDist and entity:GetData()["EID_RenderOffset"] then
diff = diff + entity:GetData()["EID_RenderOffset"]
end
if diff:Length() < EID.lastDist then
EID.lastDescriptionEntity = entity
EID.lastDist = diff:Length()