Skip to content

Commit

Permalink
#9 emit resource-add event
Browse files Browse the repository at this point in the history
  • Loading branch information
minecrawler committed Jul 5, 2023
1 parent 68a9edd commit 8fd9d85
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/world/runtime/runtime-world_resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import {type RuntimeWorld} from "./runtime-world.ts";
import type {TTypeProto} from "../../_.spec.ts";
import {systemRunParamSym} from "../../system/_.ts";
import type {TSystemParameterDesc} from "../../system/system.spec.ts";
import {SimECSReplaceResourceEvent, SimECSSystemReplaceResource} from "../../events/internal-events.ts";
import {
SimECSAddResourceEvent,
SimECSReplaceResourceEvent,
SimECSSystemReplaceResource
} from "../../events/internal-events.ts";

export function addResource<T extends object>(
this: RuntimeWorld,
Expand Down Expand Up @@ -34,6 +38,9 @@ export function addResource<T extends object>(
}

this.data.resources.set(type, instance);
// todo: await in 0.7.0
this.eventBus.publish(new SimECSAddResourceEvent(type, instance));

return instance;
}

Expand Down

0 comments on commit 8fd9d85

Please sign in to comment.