Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/command/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"dependencies": {
"@wimaengine/app": "0.3.0",
"@wimaengine/core": "0.3.0",
"@wimaengine/ecs": "0.3.0"
},
"types": "./dist/index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/command/src/core/command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { World } from '@wimaengine/ecs'
/** @import { World } from '@wimaengine/ecs' */

export class Command {

Expand Down
1 change: 1 addition & 0 deletions packages/command/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './plugin'
export * from './core'
export * from './resources'
export * from './systems'
export * from './typedef'
15 changes: 14 additions & 1 deletion packages/command/src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { App, Plugin } from '@wimaengine/app'
/** @import { App } from '@wimaengine/app' */
import { Plugin } from '@wimaengine/app'
import { AppSchedule, CoreSystems } from '@wimaengine/core'
import { CommandQueue } from './resources'
import { executeCommands } from './systems'

export class CommandsPlugin extends Plugin {

Expand All @@ -9,5 +12,15 @@ export class CommandsPlugin extends Plugin {
register(app) {
app
.setResource(new CommandQueue())
.registerSystem({
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.End,
system: executeCommands
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.End,
system: executeCommands
})
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandQueue } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'
/** @import { World } from '@wimaengine/ecs' */
import { CommandQueue } from '../resources'

/**
* @param {World} world
Expand Down
1 change: 1 addition & 0 deletions packages/command/src/systems/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './commands'
31 changes: 31 additions & 0 deletions packages/command/tests/executecommands.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { strictEqual } from 'node:assert'
import { describe, test } from 'vitest'
import { Command, CommandQueue, executeCommands } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'

class TestCommand extends Command {
/**
* @param {World} world
*/
execute(world) {
world.setResource(new TestResource())
}
}

class TestResource { }

describe('Testing `executeCommands`', () => {
test('drains and executes queued commands', () => {
const world = new World()
const queue = new CommandQueue()
const command = new TestCommand()

queue.add(command)
world.setResource(queue)

executeCommands(world)

strictEqual(world.hasResource(TestResource), true)
strictEqual(queue.size(), 0)
})
})
1 change: 1 addition & 0 deletions packages/commands/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src'
39 changes: 39 additions & 0 deletions packages/commands/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@wimaengine/commands",
"description": "Wima engine high-level commands package.",
"version": "0.3.0",
"type": "module",
"license": "SEE LICENSE in LICENSE.txt",
"author": "Wima engine contributors",
"repository": {
"type": "git",
"url": "https://github.com/wimaengine/wima.git"
},
"homepage": "https://wimaengine.org",
"bugs": {
"url": "https://github.com/wimaengine/wima/issues"
},
"main": "./dist/index.umd.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.module.js",
"require": "./dist/index.umd.js"
}
},
"files": [
"dist"
],
"scripts": {
"build": "vite build --config ../../.config/vite.config.js",
"test": "vitest run --dir tests --passWithNoTests",
"types": "tsc -p ./tsc.type.json"
},
"dependencies": {
"@wimaengine/command": "0.3.0",
"@wimaengine/ecs": "0.3.0",
"@wimaengine/logger": "0.3.0",
"@wimaengine/type": "0.3.0"
},
"types": "./dist/index.d.ts"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @import { World } from '@wimaengine/ecs' */
import { Command } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'

export class AddResourceCommand extends Command {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @import { EntityHandle } from '@wimaengine/ecs' */
/** @import { EntityHandle, World } from '@wimaengine/ecs' */
import { Command } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'

export class DespawnCommand extends Command {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @import {Constructor} from '@wimaengine/type' */
import { Command } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'

export class RemoveResourceCommand extends Command {

Expand All @@ -19,7 +18,7 @@ export class RemoveResourceCommand extends Command {
}

/**
* @param {World} world
* @param {import('@wimaengine/ecs').World} world
*/
execute(world) {
world.removeResource(this.resourceType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @import {Constructor, TypeId} from '@wimaengine/type' */
import { Command } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'

export class SetResourceAliasCommand extends Command {

Expand All @@ -27,7 +26,7 @@ export class SetResourceAliasCommand extends Command {
}

/**
* @param {World} world
* @param {import('@wimaengine/ecs').World} world
*/
execute(world) {
world.setResourceAlias(this.id, this.alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @import { EntityHandle, World } from '@wimaengine/ecs' */
import { Command } from '@wimaengine/command'
import { World, EntityHandle } from '@wimaengine/ecs'

export class SpawnCommand extends Command {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @import { EntityHandle } from '@wimaengine/ecs' */
/** @import { EntityHandle, World } from '@wimaengine/ecs' */
import { CommandQueue } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'
import { assert } from '@wimaengine/logger'
import { SpawnCommand, DespawnCommand } from '../commands'

Expand Down
2 changes: 2 additions & 0 deletions packages/commands/src/core/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './entity'
export * from './resourcecommands'
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @import {Constructor, TypeId} from '@wimaengine/type' */
import { CommandQueue } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'
import { AddResourceCommand, RemoveResourceCommand, SetResourceAliasCommand } from '../commands'

export class ResourceCommands {
Expand All @@ -12,7 +11,7 @@ export class ResourceCommands {
buffer

/**
* @param {World} world
* @param {import('@wimaengine/ecs').World} world
*/
constructor(world) {
this.buffer = world.getResource(CommandQueue)
Expand Down
2 changes: 2 additions & 0 deletions packages/commands/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './commands'
export * from './core'
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { strictEqual } from 'node:assert'
import { describe, test } from 'vitest'
import { CommandQueue } from '@wimaengine/command'
import { CommandQueue, executeCommands } from '@wimaengine/command'
import { World } from '@wimaengine/ecs'
import { typeid } from '@wimaengine/type'
import { ResourceCommands } from '../src/index.js'
import { executeCommands } from '../src/systems/index.js'

class TestResource { }
class TestAlias extends TestResource { }
Expand Down
15 changes: 15 additions & 0 deletions packages/commands/tsc.type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../.config/tsc.type.base.json",
"include": [
"index.js"
],
"exclude": [
"dist/**",
"types/**",
"tests/**"
],
"compilerOptions": {
"declarationDir": "./types",
"rootDir": "."
}
}
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
},
"dependencies": {
"@wimaengine/app": "0.3.0",
"@wimaengine/command": "0.3.0",
"@wimaengine/ecs": "0.3.0",
"@wimaengine/logger": "0.3.0",
"@wimaengine/reflect": "0.3.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/core/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export * from './schedules'
export * from './runner'
export * from './entity'
export * from './resourcecommands'
export * from './systemgroups'
export * from './snapshot'
export * from './worlds'
1 change: 0 additions & 1 deletion packages/core/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './commands'
export * from './core'
export * from './plugin'
15 changes: 3 additions & 12 deletions packages/core/src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { App, Plugin } from '@wimaengine/app'
/** @import { App } from '@wimaengine/app' */
import { Plugin } from '@wimaengine/app'
import { SchedulerBuilder } from '@wimaengine/schedule'
import { AppSchedule, CoreSystems, MainWorld, defaultRunner } from './core'
import { executeCommands, registerCoreTypes, registerPrimitiveTypes } from './systems'
import { registerCoreTypes, registerPrimitiveTypes } from './systems'

export class CorePlugin extends Plugin {

Expand Down Expand Up @@ -81,15 +82,5 @@ export class CorePlugin extends Plugin {
schedule: AppSchedule.Startup,
system: registerPrimitiveTypes
})
.registerSystem({
schedule: AppSchedule.Startup,
systemGroup: CoreSystems.End,
system: executeCommands
})
.registerSystem({
schedule: AppSchedule.Update,
systemGroup: CoreSystems.End,
system: executeCommands
})
}
}
1 change: 0 additions & 1 deletion packages/core/src/systems/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './types'
export * from './commands'
3 changes: 2 additions & 1 deletion packages/core/src/systems/types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EntityHandle, World } from '@wimaengine/ecs'
/** @import { World } from '@wimaengine/ecs' */
import { EntityHandle } from '@wimaengine/ecs'
import { ArrayInfo, Field, MapInfo, MethodEntry, OpaqueInfo, StructInfo, TypeEntry, TypeRegistry } from '@wimaengine/reflect'
import { setTypeId, typeid, typeidGeneric } from '@wimaengine/type'

Expand Down
1 change: 1 addition & 0 deletions packages/emitter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"dependencies": {
"@wimaengine/app": "0.3.0",
"@wimaengine/commands": "0.3.0",
"@wimaengine/core": "0.3.0",
"@wimaengine/datastructures": "0.3.0",
"@wimaengine/ecs": "0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/emitter/src/components/emitter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntityCommands } from '@wimaengine/core'
/** @import { EntityCommands } from '@wimaengine/commands' */
import { Range } from '@wimaengine/datastructures'
import { EntityHandle } from '@wimaengine/ecs'

Expand Down
2 changes: 1 addition & 1 deletion packages/emitter/src/systems/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntityCommands } from '@wimaengine/core'
import { EntityCommands } from '@wimaengine/commands'
import { EntityHandle, has, Query, World } from '@wimaengine/ecs'
import { Timer } from '@wimaengine/time'
import { Position2D, Orientation2D, GlobalTransform2D, GlobalTransform3D, Orientation3D, Position3D, Scale3D } from '@wimaengine/transform'
Expand Down
1 change: 1 addition & 0 deletions packages/window/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"dependencies": {
"@wimaengine/app": "0.3.0",
"@wimaengine/commands": "0.3.0",
"@wimaengine/command": "0.3.0",
"@wimaengine/core": "0.3.0",
"@wimaengine/ecs": "0.3.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/window/src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @import {WindowOptions} from './components' */
import { App, Plugin } from '@wimaengine/app'
import { AppSchedule, CoreSystems, EntityCommands } from '@wimaengine/core'
import { EntityCommands } from '@wimaengine/commands'
import { AppSchedule, CoreSystems } from '@wimaengine/core'
import { EventPlugin } from '@wimaengine/event'
import { Window, MainWindow } from './components'
import {
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from '@wimaengine/audio'
export * from '@wimaengine/broadphase'
export * from '@wimaengine/color'
export * from '@wimaengine/command'
export * from '@wimaengine/commands'
export * from '@wimaengine/core'
export * from '@wimaengine/damping'
export * from '@wimaengine/datastructures'
Expand Down