refactor: creation
This commit is contained in:
parent
c1bdae1c8c
commit
ffa391fcef
|
@ -22,10 +22,9 @@ function animal() {
|
|||
};
|
||||
}
|
||||
|
||||
export default async function createHomestead(id) {
|
||||
function createMaster() {
|
||||
const area = {x: 100, y: 60};
|
||||
const entities = [];
|
||||
entities.push({
|
||||
return {
|
||||
AreaSize: {x: area.x * 16, y: area.y * 16},
|
||||
Ticking: {},
|
||||
TileLayers: {
|
||||
|
@ -46,8 +45,11 @@ export default async function createHomestead(id) {
|
|||
},
|
||||
Time: {},
|
||||
Water: {water: {}},
|
||||
});
|
||||
entities.push({
|
||||
};
|
||||
}
|
||||
|
||||
function createShitShack(id) {
|
||||
return {
|
||||
Collider: {
|
||||
bodies: [
|
||||
{
|
||||
|
@ -72,8 +74,11 @@ export default async function createHomestead(id) {
|
|||
},
|
||||
Ticking: {},
|
||||
VisibleAabb: {},
|
||||
});
|
||||
entities.push({
|
||||
};
|
||||
}
|
||||
|
||||
function createHouseTeleport(id) {
|
||||
return {
|
||||
Collider: {
|
||||
bodies: [
|
||||
{
|
||||
|
@ -102,8 +107,11 @@ export default async function createHomestead(id) {
|
|||
},
|
||||
Position: {x: 71, y: 113},
|
||||
Ticking: {},
|
||||
});
|
||||
entities.push({
|
||||
};
|
||||
}
|
||||
|
||||
function createChest() {
|
||||
return {
|
||||
Collider: {
|
||||
bodies: [
|
||||
{
|
||||
|
@ -160,10 +168,54 @@ export default async function createHomestead(id) {
|
|||
},
|
||||
Ticking: {},
|
||||
VisibleAabb: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function createTomato() {
|
||||
return {
|
||||
Collider: {
|
||||
bodies: [
|
||||
{
|
||||
points: [
|
||||
{x: -4, y: -4},
|
||||
{x: 3, y: -4},
|
||||
{x: 3, y: 3},
|
||||
{x: -4, y: 3},
|
||||
],
|
||||
},
|
||||
],
|
||||
collisionStartScript: [
|
||||
'if (other.Inventory) {',
|
||||
' other.Inventory.give({',
|
||||
' qty: 1,',
|
||||
" source: '/resources/tomato/tomato.json',",
|
||||
' })',
|
||||
' ecs.destroy(entity.id)',
|
||||
' undefined;',
|
||||
'}',
|
||||
].join('\n'),
|
||||
},
|
||||
Forces: {},
|
||||
Magnetic: {},
|
||||
Position: {
|
||||
x: 168 + Math.random() * 30,
|
||||
y: 448 + Math.random() * 30,
|
||||
},
|
||||
Sprite: {
|
||||
anchorX: 0.5,
|
||||
anchorY: 0.5,
|
||||
scaleX: 0.333,
|
||||
scaleY: 0.333,
|
||||
source: '/resources/tomato/tomato-sprite.json',
|
||||
},
|
||||
Ticking: {},
|
||||
VisibleAabb: {},
|
||||
};
|
||||
}
|
||||
|
||||
function createTestKitten() {
|
||||
const animalJson = animal();
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
entities.push({
|
||||
return {
|
||||
...animalJson,
|
||||
Behaving: {
|
||||
routines: {
|
||||
|
@ -214,10 +266,12 @@ export default async function createHomestead(id) {
|
|||
speed: 0.115,
|
||||
},
|
||||
Tags: {tags: ['kittan']},
|
||||
});
|
||||
};
|
||||
}
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
entities.push({
|
||||
|
||||
function createTestCow() {
|
||||
const animalJson = animal();
|
||||
return {
|
||||
...animalJson,
|
||||
Behaving: {
|
||||
routines: {
|
||||
|
@ -264,10 +318,12 @@ export default async function createHomestead(id) {
|
|||
source: '/resources/farm/animals/cow-adult/cow-adult.json',
|
||||
speed: 0.25,
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
entities.push({
|
||||
|
||||
function createTestGoat() {
|
||||
const animalJson = animal();
|
||||
return {
|
||||
...animalJson,
|
||||
Behaving: {
|
||||
routines: {
|
||||
|
@ -313,9 +369,11 @@ export default async function createHomestead(id) {
|
|||
source: '/resources/farm/animals/goat-white/goat-white.json',
|
||||
speed: 0.25,
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
entities.push({
|
||||
|
||||
function createTownTeleport() {
|
||||
return {
|
||||
Collider: {
|
||||
bodies: [
|
||||
{
|
||||
|
@ -345,6 +403,65 @@ export default async function createHomestead(id) {
|
|||
|
||||
Position: {x: 8, y: 432},
|
||||
Ticking: {},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function createTomatoPlant() {
|
||||
return {
|
||||
Collider: {
|
||||
bodies: [
|
||||
{
|
||||
points: [
|
||||
{x: -8, y: -8},
|
||||
{x: 7, y: -8},
|
||||
{x: -8, y: 7},
|
||||
{x: 7, y: 7},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
Interactive: {
|
||||
interactScript: '/resources/tomato-plant/interact.js',
|
||||
},
|
||||
Plant: {
|
||||
growScript: '/resources/tomato-plant/grow.js',
|
||||
growthFactor: Math.floor(Math.random() * 256),
|
||||
mayGrowScript: '/resources/tomato-plant/may-grow.js',
|
||||
stages: [0.5, 0.5, 0.5, 0.5, 0.5],
|
||||
},
|
||||
Position: {
|
||||
x: 168,
|
||||
y: 440,
|
||||
},
|
||||
Sprite: {
|
||||
anchorY: 0.75,
|
||||
animation: 'stage/0',
|
||||
source: '/resources/tomato-plant/tomato-plant.json',
|
||||
},
|
||||
Ticking: {},
|
||||
VisibleAabb: {},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function createHomestead(id) {
|
||||
const entities = [];
|
||||
entities.push(createMaster());
|
||||
entities.push(createShitShack(id));
|
||||
entities.push(createHouseTeleport(id));
|
||||
entities.push(createChest());
|
||||
// for (let i = 0; i < 200; ++i) {
|
||||
// entities.push(createTomato());
|
||||
// }
|
||||
entities.push(createTomatoPlant());
|
||||
// for (let i = 0; i < 10; ++i) {
|
||||
// entities.push(createTestKitten());
|
||||
// }
|
||||
// for (let i = 0; i < 10; ++i) {
|
||||
// entities.push(createTestCow());
|
||||
// }
|
||||
// for (let i = 0; i < 10; ++i) {
|
||||
// entities.push(createTestGoat());
|
||||
// }
|
||||
entities.push(createTownTeleport());
|
||||
return entities;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,18 @@ export default async function createPlayer(id) {
|
|||
qty: 1,
|
||||
source: '/resources/magic-swords/magic-swords.json',
|
||||
},
|
||||
3: {
|
||||
qty: 1,
|
||||
source: '/resources/watering-can/watering-can.json',
|
||||
},
|
||||
4: {
|
||||
qty: 1,
|
||||
source: '/resources/tomato-seeds/tomato-seeds.json',
|
||||
},
|
||||
5: {
|
||||
qty: 1,
|
||||
source: '/resources/hoe/hoe.json',
|
||||
},
|
||||
},
|
||||
},
|
||||
Health: {health: 100},
|
||||
|
|
Loading…
Reference in New Issue
Block a user