refactor: collision scripts

This commit is contained in:
cha0s 2024-07-26 02:20:12 -05:00
parent a2b30d2f8b
commit eaf144668a
6 changed files with 53 additions and 48 deletions

View File

@ -28,15 +28,6 @@ export default async function createHomestead(id) {
entities.push({
Collider: {
bodies: [
{
points: [
{x: -36, y: 8},
{x: -21, y: 8},
{x: -36, y: 17},
{x: -21, y: 17},
],
tags: ['door'],
},
{
impassable: 1,
points: [
@ -47,7 +38,6 @@ export default async function createHomestead(id) {
],
},
],
collisionStartScript: '/assets/shit-shack/collision-start.js',
},
Ecs: {
path: ['houses', `${id}`].join('/'),
@ -61,6 +51,36 @@ export default async function createHomestead(id) {
Ticking: {},
VisibleAabb: {},
});
entities.push({
Collider: {
bodies: [
{
points: [
{x: -8, y: -5},
{x: 8, y: -5},
{x: 8, y: 5},
{x: -8, y: 5},
],
},
],
collisionStartScript: `
if (other.Player) {
ecs.switchEcs(
other,
'houses/${id}',
{
Position: {
x: 72,
y: 304,
},
},
);
}
`,
},
Position: {x: 71, y: 113},
Ticking: {},
});
entities.push({
Collider: {
bodies: [

View File

@ -29,10 +29,20 @@ export default async function createHouse(Ecs, id) {
],
},
],
collisionStartScript: '/assets/house/collision-start.js',
},
Ecs: {
path: ['homesteads', `${id}`].join('/'),
collisionStartScript: `
if (other.Player) {
ecs.switchEcs(
other,
'homesteads/${id}',
{
Position: {
x: 74,
y: 128,
},
},
);
}
`,
},
Position: {
x: 72,

View File

@ -1,10 +0,0 @@
ecs.switchEcs(
other,
entity.Ecs.path,
{
Position: {
x: 74,
y: 128,
},
},
);

View File

@ -1,16 +0,0 @@
for (const [{tags}] of intersections) {
if (tags && tags.includes('door')) {
if (other.Player) {
ecs.switchEcs(
other,
entity.Ecs.path,
{
Position: {
x: 72,
y: 304,
},
},
);
}
}
}

View File

@ -17,7 +17,15 @@ for (let i = 0; i < 10; ++i) {
],
},
],
collisionStartScript: '/assets/tomato/collision-start.js',
collisionStartScript: `
if (other.Inventory) {
other.Inventory.give({
qty: 1,
source: '/assets/tomato/tomato.json',
})
ecs.destroy(entity.id)
}
`,
},
Forces: {},
Magnetic: {},

View File

@ -1,7 +0,0 @@
if (other.Inventory) {
other.Inventory.give({
qty: 1,
source: '/assets/tomato/tomato.json',
})
ecs.destroy(entity.id)
}