Skip to content

Commit

Permalink
feat: Use the sdkHelpers in the admin-toolkit system
Browse files Browse the repository at this point in the history
  • Loading branch information
cyaiox committed Feb 21, 2025
1 parent 5c67117 commit c6417f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/admin-toolkit.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Entity, IEngine, PointerEventsSystem } from '@dcl/ecs'
import { ReactBasedUiSystem } from '@dcl/react-ecs'
import { getComponents, IPlayersHelper } from './definitions'
import { getComponents, IPlayersHelper, ISDKHelpers } from './definitions'
import { createAdminToolkitUI } from './admin-toolkit-ui'

// Create a system to manage the AdminToolkit
export function createAdminToolkitSystem(
engine: IEngine,
pointerEventsSystem: PointerEventsSystem,
reactBasedUiSystem: ReactBasedUiSystem,
sdkHelpers?: ISDKHelpers,
playersHelper?: IPlayersHelper,
) {
let adminToolkitEntity: Entity | null = null
Expand All @@ -24,6 +25,7 @@ export function createAdminToolkitSystem(
engine,
pointerEventsSystem,
reactBasedUiSystem,
sdkHelpers,
playersHelper,
)
}
Expand Down
1 change: 1 addition & 0 deletions src/scene-entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function initAssetPacks(
engine,
pointerEventsSystem,
reactBasedUiSystem,
sdkHelpers,
playersHelper,
),
)
Expand Down
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,21 @@ export type Component = {
export type ISDKHelpers = {
// SyncEntity helper to create network entities at runtime.
syncEntity?: SyncEntitySDK
parentEntity?: ParentEntitySDK
removeParent?: RemoveParentSDK
getParent?: GetParentSDK
getChildren?: GetChildrenSDK
}

export type SyncEntitySDK = (
entityId: Entity,
componentIds: number[],
entityEnumId?: number | undefined,
) => void
export type ParentEntitySDK = (entity: Entity, parent: Entity) => void
export type RemoveParentSDK = (entity: Entity) => void
export type GetParentSDK = (children: Entity) => Entity
export type GetChildrenSDK = (parent: Entity) => Iterable<Entity>

export type IPlayersHelper = {
onEnterScene(cb: (player: GetPlayerDataRes) => void): void
Expand Down

0 comments on commit c6417f3

Please sign in to comment.