Some renames to be a little less generic
I.e. `entity` is unclear, and hard to search for.
This commit is contained in:
parent
e90e06d15c
commit
60461aa14f
|
@ -1,3 +1,6 @@
|
||||||
|
if not playdate.isSimulator then
|
||||||
|
return
|
||||||
|
end
|
||||||
getCurrentTimeMilliseconds = playdate.getCurrentTimeMilliseconds
|
getCurrentTimeMilliseconds = playdate.getCurrentTimeMilliseconds
|
||||||
|
|
||||||
tinyTrackEntityAges = true
|
tinyTrackEntityAges = true
|
||||||
|
@ -10,4 +13,33 @@ if tinyTrackEntityAges then
|
||||||
end
|
end
|
||||||
|
|
||||||
tinyLogSystemUpdateTime = false
|
tinyLogSystemUpdateTime = false
|
||||||
tinyLogSystemChanges = false
|
tinyLogSystemChanges = false
|
||||||
|
|
||||||
|
tinyWarnWhenNonDataOnEntities = false
|
||||||
|
|
||||||
|
if tinyWarnWhenNonDataOnEntities then
|
||||||
|
function checkForNonData(e, nested, tableCache)
|
||||||
|
nested = nested or false
|
||||||
|
tableCache = tableCache or {}
|
||||||
|
|
||||||
|
local valType = type(e)
|
||||||
|
if valType == "table" then
|
||||||
|
if tableCache[e] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
tableCache[e] = true
|
||||||
|
for k, v in pairs(e) do
|
||||||
|
local keyWarning = checkForNonData(k, true, tableCache)
|
||||||
|
if keyWarning then
|
||||||
|
return keyWarning
|
||||||
|
end
|
||||||
|
local valueWarning = checkForNonData(v, true, tableCache)
|
||||||
|
if valueWarning then
|
||||||
|
return valueWarning
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif valType == "function" or valType == "thread" or valType == "userdata" then
|
||||||
|
return valType
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
14
lib/tiny.lua
14
lib/tiny.lua
|
@ -489,6 +489,20 @@ if tinyTrackEntityAges then
|
||||||
function tiny.addEntity(world, entity)
|
function tiny.addEntity(world, entity)
|
||||||
local added = wrapped(world, entity)
|
local added = wrapped(world, entity)
|
||||||
added[ENTITY_INIT_MS] = getCurrentTimeMilliseconds()
|
added[ENTITY_INIT_MS] = getCurrentTimeMilliseconds()
|
||||||
|
return added
|
||||||
|
end
|
||||||
|
tiny_addEntity = tiny.addEntity
|
||||||
|
end
|
||||||
|
|
||||||
|
if tinyWarnWhenNonDataOnEntities then
|
||||||
|
local wrapped = tiny.addEntity
|
||||||
|
function tiny.addEntity(world, entity)
|
||||||
|
local added = wrapped(world, entity)
|
||||||
|
local nonDataType = checkForNonData(added)
|
||||||
|
if nonDataType then
|
||||||
|
print("Detected non-data type '" .. nonDataType .. "' on entity")
|
||||||
|
end
|
||||||
|
return added
|
||||||
end
|
end
|
||||||
tiny_addEntity = tiny.addEntity
|
tiny_addEntity = tiny.addEntity
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,6 +27,7 @@ function Cart.reset(o)
|
||||||
|
|
||||||
---@param world World
|
---@param world World
|
||||||
function o:spawnEntitiesWhenStopped(world)
|
function o:spawnEntitiesWhenStopped(world)
|
||||||
|
-- it'd be funny if the cart fully just exploded instead
|
||||||
self.velocity = { x = 300, y = 0 }
|
self.velocity = { x = 300, y = 0 }
|
||||||
self.canCollideWith = 4
|
self.canCollideWith = 4
|
||||||
world:addEntity({
|
world:addEntity({
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
---@alias BitMask number
|
---@alias BitMask number
|
||||||
---@alias CanBeBounced { flat: XyPair, mult = XyPair }
|
---@alias CanBeBounced { flat: XyPair, mult = XyPair }
|
||||||
---@alias CanSpawn { entity: Entity }
|
---@alias CanSpawn { entityToSpawn: Entity }
|
||||||
---@alias Collision { collisionBetween: Entity[] }
|
---@alias Collision { collisionBetween: Entity[] }
|
||||||
---@alias Entity table
|
---@alias Entity table
|
||||||
---@alias InRelations Entity[]
|
---@alias InRelations Entity[]
|
||||||
|
|
|
@ -58,7 +58,7 @@ end
|
||||||
BitMask = "number",
|
BitMask = "number",
|
||||||
CanBeBounced = "{ flat: XyPair, mult: XyPair }",
|
CanBeBounced = "{ flat: XyPair, mult: XyPair }",
|
||||||
RoundStateAction = { '"end" | "start"', '"start"' },
|
RoundStateAction = { '"end" | "start"', '"start"' },
|
||||||
CanSpawn = "{ entity: Entity }",
|
CanSpawn = "{ entityToSpawn: Entity }",
|
||||||
InRelations = "Entity[]",
|
InRelations = "Entity[]",
|
||||||
CanBeBounced = "{ flat: XyPair, mult = XyPair }",
|
CanBeBounced = "{ flat: XyPair, mult = XyPair }",
|
||||||
InputState = "{ receivedInputThisFrame: boolean, aJustPressed: boolean, bJustPressed: boolean, upJustPressed: boolean, downJustPressed: boolean, leftJustPressed: boolean, rightJustPressed: boolean }",
|
InputState = "{ receivedInputThisFrame: boolean, aJustPressed: boolean, bJustPressed: boolean, upJustPressed: boolean, downJustPressed: boolean, leftJustPressed: boolean, rightJustPressed: boolean }",
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
local MenuItems = {}
|
local MenuItems = {}
|
||||||
|
|
||||||
menuController = filteredSystem("menuController", { menuItems = MenuItems, inputState = T.InputState }, function(e, _, system)
|
menuController = filteredSystem("menuController", { menuItems = MenuItems, inputState = T.InputState }, function(e, _, system)
|
||||||
if not e.inputState.receivedInputThisFrame then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, menuItem in pairs(e.menuItems) do
|
for _, menuItem in pairs(e.menuItems) do
|
||||||
if menuItem.highlighted then
|
if menuItem.highlighted then
|
||||||
if e.inputState.aJustPressed then
|
if e.inputState.aJustPressed then
|
||||||
|
|
|
@ -32,12 +32,12 @@ end)
|
||||||
|
|
||||||
removeAtRoundStart = filteredSystem("removeAtRoundStart", { removeAtRoundStart = T.bool })
|
removeAtRoundStart = filteredSystem("removeAtRoundStart", { removeAtRoundStart = T.bool })
|
||||||
|
|
||||||
filteredSystem("afterDelayAdd", { afterDelayAdd = { entity = T.Entity, delay = T.number } }, function(e, dt, system)
|
filteredSystem("afterDelayAdd", { afterDelayAdd = { entityToAdd = T.Entity, delay = T.number } }, function(e, dt, system)
|
||||||
e.afterDelayAdd.delay = e.afterDelayAdd.delay - dt
|
e.afterDelayAdd.delay = e.afterDelayAdd.delay - dt
|
||||||
if e.afterDelayAdd.delay > 0 then
|
if e.afterDelayAdd.delay > 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
system.world:addEntity(e.afterDelayAdd.entity)
|
system.world:addEntity(e.afterDelayAdd.entityToAdd)
|
||||||
system.world:removeEntity(e)
|
system.world:removeEntity(e)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ roundSystem = filteredSystem("round", { roundAction = T.RoundStateAction, positi
|
||||||
system.world:addEntity({
|
system.world:addEntity({
|
||||||
afterDelayAdd = {
|
afterDelayAdd = {
|
||||||
delay = delay,
|
delay = delay,
|
||||||
entity = upgradeEntity
|
entityToAdd = upgradeEntity
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
system.world:addEntity(menuEntity)
|
system.world:addEntity(menuEntity)
|
||||||
|
|
|
@ -35,7 +35,7 @@ function spawnerSystem:preProcess()
|
||||||
return tiny.SKIP_PROCESS
|
return tiny.SKIP_PROCESS
|
||||||
end
|
end
|
||||||
|
|
||||||
local spawnEveryX = 30
|
local spawnEveryX = 35
|
||||||
|
|
||||||
-- Currently spawns AT MOST one new ingredient per frame, which is probably not enough at high speeds!
|
-- Currently spawns AT MOST one new ingredient per frame, which is probably not enough at high speeds!
|
||||||
function spawnerSystem:postProcess()
|
function spawnerSystem:postProcess()
|
||||||
|
@ -43,7 +43,7 @@ function spawnerSystem:postProcess()
|
||||||
local newlySpawned = Ingredients.nextInCache()
|
local newlySpawned = Ingredients.nextInCache()
|
||||||
|
|
||||||
-- TODO: If performance becomes an issue, maybe just swap out __index
|
-- TODO: If performance becomes an issue, maybe just swap out __index
|
||||||
for k, v in pairs(selectedSpawner.canSpawn.entity) do
|
for k, v in pairs(selectedSpawner.canSpawn.entityToSpawn) do
|
||||||
newlySpawned[k] = v
|
newlySpawned[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ function addAllSpawners(world)
|
||||||
odds = spawnerOdds,
|
odds = spawnerOdds,
|
||||||
canSpawn = {
|
canSpawn = {
|
||||||
yRange = yRange,
|
yRange = yRange,
|
||||||
entity = {
|
entityToSpawn = {
|
||||||
score = score,
|
score = score,
|
||||||
canBeCollidedBy = 1,
|
canBeCollidedBy = 1,
|
||||||
expireAfterCollision = true,
|
expireAfterCollision = true,
|
||||||
|
@ -111,13 +111,13 @@ function getAvailableSpawnerUpgrades()
|
||||||
-- upgrades[#upgrades + 1] = { hasUpgradeSpeed = spawner.hasUpgradeSpeed }
|
-- upgrades[#upgrades + 1] = { hasUpgradeSpeed = spawner.hasUpgradeSpeed }
|
||||||
end
|
end
|
||||||
|
|
||||||
if spawner.canSpawn.entity.score then
|
if spawner.canSpawn.entityToSpawn.score then
|
||||||
local name = "Double " .. spawner.name .. " value"
|
local name = "Double " .. spawner.name .. " value"
|
||||||
upgrades[#upgrades + 1] = {
|
upgrades[#upgrades + 1] = {
|
||||||
name = name,
|
name = name,
|
||||||
apply = function(world)
|
apply = function(world)
|
||||||
print("Applying " .. name)
|
print("Applying " .. name)
|
||||||
spawner.canSpawn.entity.score = spawner.canSpawn.entity.score * 2
|
spawner.canSpawn.entityToSpawn.score = spawner.canSpawn.entityToSpawn.score * 2
|
||||||
world:addEntity({ roundAction = "start" })
|
world:addEntity({ roundAction = "start" })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
@ -133,15 +133,6 @@ function getAvailableSpawnerUpgrades()
|
||||||
world:addEntity({ roundAction = "start" })
|
world:addEntity({ roundAction = "start" })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- if not spawner.canSpawn.entity.velocity then
|
|
||||||
-- upgrades[#upgrades + 1] = {
|
|
||||||
-- name = spawner.name .. " Movement",
|
|
||||||
-- upgrade = function()
|
|
||||||
-- spawner.canSpawn.entity.velocity = { x = -10, y = 0 }
|
|
||||||
-- end,
|
|
||||||
-- }
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
return upgrades
|
return upgrades
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue