Skip to content

Commit

Permalink
Add cleanup to types
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Oct 8, 2024
1 parent 270260c commit 2e246e1
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 90 deletions.
132 changes: 68 additions & 64 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,64 +1,68 @@
# Compiled Lua sources
luac.out

# luarocks build files
*.src.rock
*.zip
*.tar.gz
*.rbxm

# Object files
*.o
*.os
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Wally files
DevPackages
Packages
wally.lock
WallyPatches

# Typescript
/node_modules
/include

# Misc
roblox.toml
sourcemap.json
drafts/

# Cached Vitepress (docs)

/docs/.vitepress/cache
/docs/.vitepress/dist

.vitepress/cache
.vitepress/dist
# Compiled Lua sources
luac.out

# luarocks build files
*.src.rock
*.zip
*.tar.gz
*.rbxm

# Object files
*.o
*.os
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Wally files
DevPackages
Packages
wally.lock
WallyPatches

# Typescript
/node_modules
/include

# Misc
roblox.toml
sourcemap.json
drafts/

# Cached Vitepress (docs)

/docs/.vitepress/cache
/docs/.vitepress/dist

.vitepress/cache
.vitepress/dist

# Luau tools
/tools
profile.*
53 changes: 27 additions & 26 deletions src/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,34 @@ type ArchetypeDiff = {
removed: Ty,
}

local HI_COMPONENT_ID = _G.__JECS_HI_COMPONENT_ID or 256

local EcsOnAdd = HI_COMPONENT_ID + 1
local EcsOnRemove = HI_COMPONENT_ID + 2
local EcsOnSet = HI_COMPONENT_ID + 3
local EcsWildcard = HI_COMPONENT_ID + 4
local EcsChildOf = HI_COMPONENT_ID + 5
local EcsComponent = HI_COMPONENT_ID + 6
local EcsOnDelete = HI_COMPONENT_ID + 7
local EcsOnDeleteTarget = HI_COMPONENT_ID + 8
local EcsDelete = HI_COMPONENT_ID + 9
local EcsRemove = HI_COMPONENT_ID + 10
local EcsName = HI_COMPONENT_ID + 11
local EcsRest = HI_COMPONENT_ID + 12

local ECS_PAIR_FLAG = 0x8
local ECS_ID_FLAGS_MASK = 0x10
local ECS_ENTITY_MASK = bit32.lshift(1, 24)
local ECS_GENERATION_MASK = bit32.lshift(1, 16)

local ECS_ID_DELETE = 0b0000_0001
local ECS_ID_IS_TAG = 0b0000_0010
local ECS_ID_HAS_ON_ADD = 0b0000_0100
local ECS_ID_HAS_ON_SET = 0b0000_1000
local HI_COMPONENT_ID = _G.__JECS_HI_COMPONENT_ID or 256

local EcsOnAdd = HI_COMPONENT_ID + 1
local EcsOnRemove = HI_COMPONENT_ID + 2
local EcsOnSet = HI_COMPONENT_ID + 3
local EcsWildcard = HI_COMPONENT_ID + 4
local EcsChildOf = HI_COMPONENT_ID + 5
local EcsComponent = HI_COMPONENT_ID + 6
local EcsOnDelete = HI_COMPONENT_ID + 7
local EcsOnDeleteTarget = HI_COMPONENT_ID + 8
local EcsDelete = HI_COMPONENT_ID + 9
local EcsRemove = HI_COMPONENT_ID + 10
local EcsName = HI_COMPONENT_ID + 11
local EcsRest = HI_COMPONENT_ID + 12

local ECS_PAIR_FLAG = 0x8
local ECS_ID_FLAGS_MASK = 0x10
local ECS_ENTITY_MASK = bit32.lshift(1, 24)
local ECS_GENERATION_MASK = bit32.lshift(1, 16)

local ECS_ID_DELETE = 0b0000_0001
local ECS_ID_IS_TAG = 0b0000_0010
local ECS_ID_HAS_ON_ADD = 0b0000_0100
local ECS_ID_HAS_ON_SET = 0b0000_1000
local ECS_ID_HAS_ON_REMOVE = 0b0001_0000
local ECS_ID_MASK = 0b0000_0000
local ECS_ID_MASK = 0b0000_0000

local NULL_ARRAY = table.freeze({})
local NULL_ARRAY = table.freeze({})

local function FLAGS_ADD(is_pair: boolean): number
local flags = 0x0
Expand Down Expand Up @@ -1711,6 +1711,7 @@ export type World = {
--- Assigns a value to a component on the given entity
set: <T>(self: World, id: Entity, component: Id<T>, data: T) -> (),

cleanup: (self: World) -> (),
-- Clears an entity from the world
clear: (self: World, id: Entity) -> (),
--- Removes a component from the given entity
Expand Down

0 comments on commit 2e246e1

Please sign in to comment.