diff --git a/js/format-c2g.js b/js/format-c2g.js index db7579b..df22a14 100644 --- a/js/format-c2g.js +++ b/js/format-c2g.js @@ -857,6 +857,14 @@ const TILE_ENCODING = { name: 'fire_sticks', is_extension: true, }, + 0xef: { + name: 'turntable_cw', + is_extension: true, + }, + 0xf0: { + name: 'turntable_ccw', + is_extension: true, + }, }; const REVERSE_TILE_ENCODING = {}; for (let [tile_byte, spec] of Object.entries(TILE_ENCODING)) { diff --git a/js/main-editor.js b/js/main-editor.js index bc8a9ea..5c05aae 100644 --- a/js/main-editor.js +++ b/js/main-editor.js @@ -1602,6 +1602,8 @@ const EDITOR_PALETTE = [{ 'global_cycler', 'halo', 'fire_sticks', + 'turntable_cw', + 'turntable_ccw', ], }]; @@ -2192,6 +2194,14 @@ const EDITOR_TILE_DESCRIPTIONS = { name: "Dormant Lava", desc: "Acts like dirt. However, fireballs will enter it and turn it into Fire in the process.", }, + turntable_cw: { + name: "Turntable (Clockwise)", + desc: "Rotates anything entering this tile clockwise. Frame blocks are rotated too. If connected to wire, only functions while receiving power.", + }, + turntable_ccw: { + name: "Turntable (Counterclockwise)", + desc: "Rotates anything entering this tile counterclockwise. Frame blocks are rotated too. If connected to wire, only functions while receiving power.", + }, }; const SPECIAL_PALETTE_ENTRIES = { @@ -2439,6 +2449,7 @@ for (let cycle of [ ['ice_nw', 'ice_ne', 'ice_se', 'ice_sw'], ['swivel_nw', 'swivel_ne', 'swivel_se', 'swivel_sw'], ['terraformer_n', 'terraformer_e', 'terraformer_s', 'terraformer_w'], + ['turntable_cw', 'turntable_ccw'], ]) { for (let [i, name] of cycle.entries()) { let left = cycle[(i - 1 + cycle.length) % cycle.length]; diff --git a/js/tileset.js b/js/tileset.js index 7c98388..7a63b9c 100644 --- a/js/tileset.js +++ b/js/tileset.js @@ -1038,7 +1038,16 @@ export const LL_TILESET_LAYOUT = Object.assign({}, CC2_TILESET_LAYOUT, { global_cycler: [4, 43], halo: [5, 43], fire_sticks: [6, 43], - + turntable_cw: { + __special__: 'visual-state', + active: [7, 43], + inactive: [9, 43], + }, + turntable_ccw: { + __special__: 'visual-state', + active: [8, 43], + inactive: [10, 43], + }, }); export const TILESET_LAYOUTS = { diff --git a/js/tiletypes.js b/js/tiletypes.js index 511c82e..c28b7b6 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -705,6 +705,68 @@ const TILE_TYPES = { } }, }, + turntable_cw: { + layer: LAYERS.terrain, + //note: should be wireable in exactly the same way as a transmogrifier + wire_propagation_mode: 'none', + on_begin(me, level) { + // TODO if wire destruction is ever allowed, this will need to update somehow + me.is_wired = level.is_tile_wired(me, false); + me.is_active = ! me.is_wired; + }, + on_arrive(me, level, other) { + if (! me.is_active) + return; + other.direction = DIRECTIONS[other.direction].right; + if (other.type.on_rotate) { + other.type.on_rotate(other, level, 'right'); + } + }, + on_power(me, level) { + if (me.is_wired) { + level._set_tile_prop(me, 'is_active', true); + } + }, + on_depower(me, level) { + if (me.is_wired) { + level._set_tile_prop(me, 'is_active', false); + } + }, + visual_state(me) { + return ! me || me.is_active ? 'active' : 'inactive'; + }, + }, + turntable_ccw: { + layer: LAYERS.terrain, + //note: should be wireable in exactly the same way as a transmogrifier + wire_propagation_mode: 'none', + on_begin(me, level) { + // TODO if wire destruction is ever allowed, this will need to update somehow + me.is_wired = level.is_tile_wired(me, false); + me.is_active = ! me.is_wired; + }, + on_arrive(me, level, other) { + if (! me.is_active) + return; + other.direction = DIRECTIONS[other.direction].left; + if (other.type.on_rotate) { + other.type.on_rotate(other, level, 'left'); + } + }, + on_power(me, level) { + if (me.is_wired) { + level._set_tile_prop(me, 'is_active', true); + } + }, + on_depower(me, level) { + if (me.is_wired) { + level._set_tile_prop(me, 'is_active', false); + } + }, + visual_state(me) { + return ! me || me.is_active ? 'active' : 'inactive'; + }, + }, // Hazards fire: { diff --git a/tileset-lexy.png b/tileset-lexy.png index 0956538..ab5965c 100644 Binary files a/tileset-lexy.png and b/tileset-lexy.png differ