43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
|
|
import { Loader, Sprite } from "pixi.js";
|
||
|
|
import { app, world } from ".";
|
||
|
|
import { Door } from "./Components/door";
|
||
|
|
import { Human } from "./Components/human";
|
||
|
|
import { Name } from "./Components/name";
|
||
|
|
import { InCabin } from "./Components/inCabin";
|
||
|
|
import { Appearance } from "./Components/appearance";
|
||
|
|
import { Position } from "./Components/position";
|
||
|
|
import { AABB } from "./Datatypes/aabb";
|
||
|
|
import { DebugRect } from "./Components/debugRect";
|
||
|
|
import { OrderZ } from "./Components/orderZ";
|
||
|
|
|
||
|
|
|
||
|
|
export function setup(){
|
||
|
|
let resources = Loader.shared.resources;
|
||
|
|
|
||
|
|
//base sprites without entity representation
|
||
|
|
const bgTex = new Sprite(resources["Background"].texture)
|
||
|
|
app.stage.addChild(bgTex)
|
||
|
|
|
||
|
|
//start entities
|
||
|
|
|
||
|
|
//door
|
||
|
|
world.createEntity()
|
||
|
|
.addComponent(Door, <Door>{open: true,
|
||
|
|
openOffset: {x:38, y:2}, openTex: resources["Door"].spritesheet.textures[0],
|
||
|
|
closedOffset: {x:38, y:2}, closedTex: resources["Door"].spritesheet.textures[1]})
|
||
|
|
|
||
|
|
//example humans
|
||
|
|
//TODO delete those
|
||
|
|
let roomBounds = new AABB(10, 17, 62, 56)
|
||
|
|
world.createEntity()
|
||
|
|
.addComponent(DebugRect, <DebugRect>{color:0x0000FF, rect: roomBounds})
|
||
|
|
|
||
|
|
for(let i=0;i<10;i++)
|
||
|
|
world.createEntity()
|
||
|
|
.addComponent(Human)
|
||
|
|
.addComponent(Name, <Name>{first: "Sarah", last:"Lee"})
|
||
|
|
.addComponent(Appearance, <Appearance>{idleTexture: resources["Human"].texture}) //Todo: generate appearance from body traits instead?
|
||
|
|
.addComponent(InCabin)
|
||
|
|
.addComponent(Position, <Position>{value: roomBounds.randomPoint()})
|
||
|
|
.addComponent(OrderZ)
|
||
|
|
}
|