feat: genned and loaded entities
This commit is contained in:
parent
e06b3d5089
commit
b7cd05732d
1
resource/base-test.entity.json
Normal file
1
resource/base-test.entity.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"traits": {"existent": {"state": {"isTicking": false, "name": "Base"}}}}
|
1
resource/blue-fire.entity.json
Normal file
1
resource/blue-fire.entity.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"traits":{"animated":{"params":{"animations":{"idle":{"jitter":0.1,"offset":[0,0],"uri":"/blue-fire.animation.json"}}}},"audible":{"params":{"sounds":{"fire":{"uri":"/blue-fire.sound.json"}}}},"collider":{"params":{"isSensor":true}},"damaging":{"params":{"damagingSound":"fire","damageSpecs":[{"affinity":1,"lock":0.45,"power":-15,"variance":0.25}]}},"darkened":{"params":{"isDarkened":false}},"existent":{"state":{"name":"Blue fire"}},"layered":{},"listed":{},"physical":{},"positioned":{"state":{"x":0,"y":0}},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[16,16]}}},"visible":{"params":{"filter":"bloom"}}}}
|
1
resource/extension-test.entity.json
Normal file
1
resource/extension-test.entity.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"base": "/base-test.entity.json", "traits": {"existent": {"state": {"name": "Extension"}}}}
|
1
resource/fire.entity.json
Normal file
1
resource/fire.entity.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"traits":{"animated":{"params":{"animations":{"idle":{"jitter":0.1,"offset":[0,0],"uri":"/fire.animation.json"}}}},"audible":{"params":{"sounds":{"fire":{"uri":"/fire.sound.json"}}}},"collider":{"params":{"isSensor":true}},"damaging":{"params":{"damagingSound":"fire","damageSpecs":[{"affinity":1,"lock":0.45,"power":15,"variance":0.25}]}},"darkened":{"params":{"isDarkened":false}},"existent":{"state":{"name":"Fire"}},"layered":{},"listed":{},"physical":{},"positioned":{"state":{"x":0,"y":0}},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[16,16]}}},"visible":{"params":{"filter":"bloom"}}}}
|
1
resource/flower-barrel.entity.json
Normal file
1
resource/flower-barrel.entity.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"traits":{"alive":{"state":{"maxLife":1000,"life":1000}},"collider":{},"emitter":{},"existent":{"state":{"name":"Flower Barrel"}},"layered":{},"listed":{},"physical":{},"pictured":{"params":{"images":{"initial":{"offset":[0,-8],"size":[32,32],"uri":"/flower-barrel.png"}}}},"positioned":{"state":{"x":0,"y":0}},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[20,10]}}},"visible":{},"vulnerable":{}}}
|
1
resource/kitty.entity.json
Normal file
1
resource/kitty.entity.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"traits":{"alive":{},"animated":{"params":{"animations":{"idle":{"offset":[0,-3],"uri":"/kitty.animation.json"}}}},"audible":{"params":{"sounds":{"deathSound":{"uri":"/ded.sound.json"}}}},"behaved":{"params":{"routines":{"type":"routines","routines":{"initial":{"type":"routine","routine":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"moveFor"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"global"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0.25},{"type":"literal","value":2.5},{"type":"literal","value":false}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isAnimating"}],"value":{"type":"literal","value":false}},{"type":"traversal","steps":[{"type":"key","key":"global"},{"type":"key","key":"wait"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"global"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":1},{"type":"literal","value":4},{"type":"literal","value":false}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"global"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0},{"type":"literal","value":3}]}]}},{"type":"traversal","steps":[{"type":"key","key":"global"},{"type":"key","key":"wait"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"global"},{"type":"key","key":"randomNumber"},{"type":"invoke","args":[{"type":"literal","value":0.5},{"type":"literal","value":3},{"type":"literal","value":false}]}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"entity"},{"type":"key","key":"isAnimating"}],"value":{"type":"literal","value":true}}]}}}}}},"collider":{},"directional":{"params":{"directionCount":4},"state":{"direction":2}},"emitter":{},"existent":{"state":{"name":"Kitty"}},"visible":{"state":{"visibleScale":[1,1]}},"layered":{},"listed":{},"mobile":{"state":{"speed":40}},"physical":{},"positioned":{"state":{"x":0,"y":0}},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[8,4]}}},"vulnerable":{}}}
|
1
resource/mama-kitty-spawner.entity.json
Normal file
1
resource/mama-kitty-spawner.entity.json
Normal file
File diff suppressed because one or more lines are too long
1
resource/mama-kitty.entity.json
Normal file
1
resource/mama-kitty.entity.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,6 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import {buildInvoke, buildTraversal} from '@avocado/behavior';
|
||||
import {Vector} from '@avocado/math';
|
||||
import {World} from '@avocado/physics/matter/world';
|
||||
|
@ -476,26 +479,81 @@ function mamaKittySpawnerJSON() {
|
|||
};
|
||||
}
|
||||
|
||||
const RESOURCE_PATH = path.resolve(process.cwd(), 'resource');
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(RESOURCE_PATH, 'flower-barrel.entity.json'),
|
||||
JSON.stringify(flowerBarrelJSON([0, 0]))
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(RESOURCE_PATH, 'kitty.entity.json'),
|
||||
JSON.stringify(kittyJSON([0, 0]))
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(RESOURCE_PATH, 'mama-kitty.entity.json'),
|
||||
JSON.stringify(mamaKittyJSON([0, 0]))
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(RESOURCE_PATH, 'mama-kitty-spawner.entity.json'),
|
||||
JSON.stringify(mamaKittySpawnerJSON([0, 0]))
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(RESOURCE_PATH, 'fire.entity.json'),
|
||||
JSON.stringify(fireJSON([0, 0]))
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(RESOURCE_PATH, 'blue-fire.entity.json'),
|
||||
JSON.stringify(blueFireJSON([0, 0]))
|
||||
);
|
||||
|
||||
function positionedEntityJSON(uri, position) {
|
||||
return {
|
||||
uri,
|
||||
traits: {
|
||||
positioned: {
|
||||
state: {
|
||||
x: position[0] * 4,
|
||||
y: position[1] * 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
for (let i = 0; i < 50; ++i) {
|
||||
const x = Math.floor(Math.random() * (roomSize[0] - 100)) + 50;
|
||||
const y = Math.floor(Math.random() * (roomSize[1] - 100)) + 50;
|
||||
roomJSON.layers[0].entities.push(flowerBarrelJSON([x * 4, y * 4]));
|
||||
roomJSON.layers[0].entities.push(
|
||||
positionedEntityJSON('/flower-barrel.entity.json', [x, y])
|
||||
);
|
||||
}
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
const x = Math.floor(Math.random() * (roomSize[0] - 100)) + 50;
|
||||
const y = Math.floor(Math.random() * (roomSize[1] - 100)) + 50;
|
||||
roomJSON.layers[0].entities.push(mamaKittySpawnerJSON());
|
||||
roomJSON.layers[0].entities.push(
|
||||
positionedEntityJSON('/mama-kitty-spawner.entity.json', [x, y])
|
||||
);
|
||||
}
|
||||
for (let i = 0; i < 60; ++i) {
|
||||
const x = Math.floor(Math.random() * (roomSize[0] - 100)) + 50;
|
||||
const y = Math.floor(Math.random() * (roomSize[1] - 100)) + 50;
|
||||
roomJSON.layers[0].entities.push(fireJSON([x * 4, y * 4]));
|
||||
roomJSON.layers[0].entities.push(
|
||||
positionedEntityJSON('/fire.entity.json', [x, y])
|
||||
);
|
||||
}
|
||||
for (let i = 0; i < 5; ++i) {
|
||||
const x = Math.floor(Math.random() * (roomSize[0] - 100)) + 50;
|
||||
const y = Math.floor(Math.random() * (roomSize[1] - 100)) + 50;
|
||||
roomJSON.layers[0].entities.push(blueFireJSON([x * 4, y * 4]));
|
||||
roomJSON.layers[0].entities.push(
|
||||
positionedEntityJSON('/blue-fire.entity.json', [x, y])
|
||||
);
|
||||
}
|
||||
|
||||
export function createRoom() {
|
||||
const room = new Room();
|
||||
room.fromJSON(roomJSON);
|
||||
|
|
Loading…
Reference in New Issue
Block a user