diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-01-28 13:37:20 +0100 |
|---|---|---|
| committer | tpart <tpart120@proton.me> | 2026-02-26 20:49:14 +0100 |
| commit | 1e084092ca43ee63733ffe7540501665e6cf248d (patch) | |
| tree | 314a231ec876c64f3feceaa6b482c00a2e68ffbd | |
| parent | 3eed0cc4fe0553524fdeafd4b2800b7c89ff5a08 (diff) | |
| download | hurrycurry-1e084092ca43ee63733ffe7540501665e6cf248d.tar hurrycurry-1e084092ca43ee63733ffe7540501665e6cf248d.tar.bz2 hurrycurry-1e084092ca43ee63733ffe7540501665e6cf248d.tar.zst | |
client-side can_interact logic
| -rw-r--r-- | test-client/main.ts | 17 | ||||
| -rw-r--r-- | test-client/tiles.ts | 5 |
2 files changed, 14 insertions, 8 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index 317eee27..120a556d 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -407,12 +407,17 @@ function toggle_chat() { } export function can_interact_with_tile(t: TileData, hand: ItemSlot) { - // TODO - return true - // return t.item - // || (!hand.item && data.tile_interactable_empty.includes(t.kind)) - // || (hand.item && !data.tile_placeable_items[t.kind]) - // || (hand.item && data.tile_placeable_items[t.kind]?.includes(hand.item?.kind)) + if (t.item) return true + let can_interact = false + for (const part of t.parts) { + if (hand.item && data.tile_placeable_items[part]) + can_interact = data.tile_placeable_items[part].includes(hand.item.kind) + if (hand.item && data.tile_placeable_any) + can_interact = true + if (!hand.item && data.tile_interactable_empty.includes(part)) + can_interact = true + } + return can_interact } export function get_interact_target(): V2 | undefined { diff --git a/test-client/tiles.ts b/test-client/tiles.ts index f4c3c5f4..6bc587fd 100644 --- a/test-client/tiles.ts +++ b/test-client/tiles.ts @@ -189,14 +189,15 @@ const TILES: { [key in TileName]: (param: string) => Component } = { "path": () => base("rgb(100, 80, 55)"), "conveyor": () => base("rgb(107, 62, 128)"), "tree": () => base("rgb(1, 82, 4)"), - "cutting-board": () => rect(0.3, "rgb(158, 236, 68)", "rgb(158, 236, 68)", 0.2), + "cutting-board": () => rect(0.3, "#9eec44ff", "#9eec44ff", 0.2), + "rolling-board": () => rect(0.3, "#ece644ff", "#ece644ff", 0.2), "trash": () => c => (circle(0.4, "rgb(20, 20, 20)")(c), cross(0.3, "rgb(90, 36, 36)")(c)), "sink": () => base("rgb(131, 129, 161)", "rgb(177, 174, 226)", 0.2), "oven": () => base("rgb(241, 97, 61)", "rgb(109, 84, 84)", 0.3), "freezer": () => base("rgb(61, 97, 241)", "rgb(84, 88, 109)", 0.3), "stove": () => c => (counter(c), circle(0.4, "#444", "#999")(c)), "book": () => c => (counter(c), rect(0.2, "rgb(88, 44, 7)")(c)), - "lamp": () => c => rect(0.3, "rgb(255, 217, 127)", "rgb(32, 32, 32)", 0.1), + "lamp": () => rect(0.3, "rgb(255, 217, 127)", "rgb(32, 32, 32)", 0.1), "crate": name => c => (base("#60701e", "#b9da37", 0.05)(c), iref(name)(c)) } |