From c168b12fc19a84c1359709b4520b5a0eb48e3651 Mon Sep 17 00:00:00 2001 From: SpaiR Date: Thu, 31 Jan 2019 23:37:00 +0300 Subject: [PATCH] render scripts --- render/build.gradle.kts | 2 +- .../github/spair/tauwebmap/configuration.kt | 42 +++- .../io/github/spair/tauwebmap/render.kt | 2 +- render/src/main/resources/common_render.json | 63 ------ render/src/main/resources/config.json | 42 +++- .../main/resources/renders/common_render.json | 61 ++++++ .../equal_more_1f995d5f7.json} | 27 +-- .../scripts/adjust_window_color.var.groovy | 16 ++ .../scripts/airlock_overlay.img.groovy | 19 ++ .../scripts/color_window.glob.groovy | 35 ++++ .../resources/scripts/color_window.var.groovy | 16 ++ .../equal_887f80dff/smooth_carpet.var.groovy | 58 ++++++ .../equal_887f80dff/smooth_table.var.groovy | 190 +++++++++++++++++ .../adjust_cleanable_blood_color.var.groovy | 6 + .../smooth_carpet.var.groovy | 52 +++++ .../smooth_table.var.groovy | 192 ++++++++++++++++++ .../handle_random_flora.var.groovy | 8 + .../handle_random_tool_color.var.groovy | 19 ++ .../handle_random_tool_supply.var.groovy | 5 + .../scripts/hide_content_in_closet.var.groovy | 8 + .../resources/scripts/init_posters.var.groovy | 10 + .../scripts/posters_amount.glob.groovy | 2 + .../scripts/random_tools_icons.glob.groovy | 14 ++ .../scripts/smooth_carpet.var.groovy | 52 +++++ .../resources/scripts/smooth_wall.var.groovy | 16 ++ .../scripts/smooth_window.var.groovy | 28 +++ 26 files changed, 895 insertions(+), 90 deletions(-) delete mode 100644 render/src/main/resources/common_render.json create mode 100644 render/src/main/resources/renders/common_render.json rename render/src/main/resources/{specific_render/from_1f995d5f7.json => renders/equal_more_1f995d5f7.json} (58%) create mode 100644 render/src/main/resources/scripts/adjust_window_color.var.groovy create mode 100644 render/src/main/resources/scripts/airlock_overlay.img.groovy create mode 100644 render/src/main/resources/scripts/color_window.glob.groovy create mode 100644 render/src/main/resources/scripts/color_window.var.groovy create mode 100644 render/src/main/resources/scripts/equal_887f80dff/smooth_carpet.var.groovy create mode 100644 render/src/main/resources/scripts/equal_887f80dff/smooth_table.var.groovy create mode 100644 render/src/main/resources/scripts/equal_more_0bc341bb0/adjust_cleanable_blood_color.var.groovy create mode 100644 render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_carpet.var.groovy create mode 100644 render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_table.var.groovy create mode 100644 render/src/main/resources/scripts/equal_more_82304ea90/handle_random_flora.var.groovy create mode 100644 render/src/main/resources/scripts/handle_random_tool_color.var.groovy create mode 100644 render/src/main/resources/scripts/handle_random_tool_supply.var.groovy create mode 100644 render/src/main/resources/scripts/hide_content_in_closet.var.groovy create mode 100644 render/src/main/resources/scripts/init_posters.var.groovy create mode 100644 render/src/main/resources/scripts/posters_amount.glob.groovy create mode 100644 render/src/main/resources/scripts/random_tools_icons.glob.groovy create mode 100644 render/src/main/resources/scripts/smooth_carpet.var.groovy create mode 100644 render/src/main/resources/scripts/smooth_wall.var.groovy create mode 100644 render/src/main/resources/scripts/smooth_window.var.groovy diff --git a/render/build.gradle.kts b/render/build.gradle.kts index 928c0c2..285803f 100644 --- a/render/build.gradle.kts +++ b/render/build.gradle.kts @@ -13,7 +13,7 @@ application { dependencies { implementation(kotlin("stdlib-jdk8")) - implementation(group = "io.github.spair", name = "byond-dmm-util", version = "1.0.1") + implementation(group = "io.github.spair", name = "byond-dmm-util", version = "1.1") implementation(group = "com.eclipsesource.minimal-json", name = "minimal-json", version = "0.9.5") } diff --git a/render/src/main/kotlin/io/github/spair/tauwebmap/configuration.kt b/render/src/main/kotlin/io/github/spair/tauwebmap/configuration.kt index d0b3bd7..d8390e6 100644 --- a/render/src/main/kotlin/io/github/spair/tauwebmap/configuration.kt +++ b/render/src/main/kotlin/io/github/spair/tauwebmap/configuration.kt @@ -2,6 +2,8 @@ package io.github.spair.tauwebmap import com.eclipsesource.json.Json import com.eclipsesource.json.JsonObject +import java.io.File +import java.lang.Exception private const val CONFIG_FILE = "config.json" @@ -12,6 +14,7 @@ private const val LESS_ENTRY = "<" private const val LESS_EQUAL_ENTRY = "<=" val RENDER_CONFIG = mutableMapOf>() +val SCRIPT_CONFIG = mutableMapOf>() fun readConfigForRevisions(revisionList: List) { val configJson = Json.parse(readResource(CONFIG_FILE)).asObject() @@ -19,6 +22,7 @@ fun readConfigForRevisions(revisionList: List) { configJson.entryForEach(MORE_EQUAL_ENTRY) { config -> for (revision in revisionList) { addToRenderConfig(revision, config) + addToScriptConfig(revision, config) if (config.getRevision() == revision) { break } @@ -30,12 +34,14 @@ fun readConfigForRevisions(revisionList: List) { break } addToRenderConfig(revision, config) + addToScriptConfig(revision, config) } } configJson.entryForEach(EQUAL_ENTRY) { config -> for (revision in revisionList) { if (config.getRevision() == revision) { addToRenderConfig(revision, config) + addToScriptConfig(revision, config) } } } @@ -45,11 +51,13 @@ fun readConfigForRevisions(revisionList: List) { break } addToRenderConfig(revision, config) + addToScriptConfig(revision, config) } } configJson.entryForEach(LESS_EQUAL_ENTRY) { config -> for (revision in revisionList.reversed()) { addToRenderConfig(revision, config) + addToScriptConfig(revision, config) if (config.getRevision() == revision) { break } @@ -58,11 +66,31 @@ fun readConfigForRevisions(revisionList: List) { } private fun addToRenderConfig(revision: String, config: JsonObject) { - if (config.renderExcluded(revision)) + if (config.excluded(revision)) return RENDER_CONFIG.getOrPut(revision) { mutableListOf() }.let { list -> - config.getRender().forEach { renderFileName -> - list.add(renderFileName.asString()) + config.getRender()?.forEach { renderFileName -> + try { + list.add(renderFileName.asString()) + } catch (e: Exception) { + println("exception with $renderFileName") + throw e + } + } + } +} + +private fun addToScriptConfig(revision: String, config: JsonObject) { + if (config.excluded(revision)) + return + SCRIPT_CONFIG.getOrPut(revision) { mutableListOf() }.let { list -> + config.getScript()?.forEach { scriptFileName -> + try { + list.add(resourceFile(scriptFileName.asString())) + } catch (e: Exception) { + println("exception with $scriptFileName") + throw e + } } } } @@ -71,11 +99,12 @@ private fun JsonObject.entryForEach(entryName: String, action: (JsonObject) -> ( get(entryName)?.asArray()?.forEach { action(it.asObject()) } } -private fun JsonObject.getRender() = get("render").asArray() +private fun JsonObject.getRender() = get("render")?.asArray() +private fun JsonObject.getScript() = get("script")?.asArray() private fun JsonObject.getRevision() = get("revision").asString() -private fun JsonObject.renderExcluded(revision: String): Boolean { - val exclude = get("render_exclude")?.asArray() +private fun JsonObject.excluded(revision: String): Boolean { + val exclude = get("exclude")?.asArray() if (exclude != null) { for (excl in exclude) { if (revision == excl.asString()) { @@ -88,3 +117,4 @@ private fun JsonObject.renderExcluded(revision: String): Boolean { internal class Resource fun readResource(path: String) = Resource::class.java.classLoader.getResource(path).readText() +fun resourceFile(path: String) = File(Resource::class.java.classLoader.getResource(path).file) diff --git a/render/src/main/kotlin/io/github/spair/tauwebmap/render.kt b/render/src/main/kotlin/io/github/spair/tauwebmap/render.kt index 2c85e4b..8466293 100644 --- a/render/src/main/kotlin/io/github/spair/tauwebmap/render.kt +++ b/render/src/main/kotlin/io/github/spair/tauwebmap/render.kt @@ -76,7 +76,7 @@ private fun generateMapImage(typesToUse: Array): BufferedImage { val dmm = Dmm(dmmData, dme) return if (typesToUse.isEmpty()) { - DmmDrawer.drawMap(dmm, FilterMode.IGNORE, *IGNORE_TYPES) + DmmDrawer.drawMap(dmm, SCRIPT_CONFIG[CURRENT_REVISION], FilterMode.IGNORE, *IGNORE_TYPES) } else { DmmDrawer.drawMap(dmm, FilterMode.INCLUDE, *typesToUse) } diff --git a/render/src/main/resources/common_render.json b/render/src/main/resources/common_render.json deleted file mode 100644 index d4361a7..0000000 --- a/render/src/main/resources/common_render.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "definitions": [ - { - "type": "/turf/simulated/floor/plating", - "parent": "/turf/simulated/floor", - "subtypes": [], - "vars": { - "layer": 1.98 - } - }, - { - "type": "/obj/machinery/navbeacon", - "parent": "/obj/machinery", - "subtypes": [], - "vars": { - "layer": 1.988 - } - }, - { - "type": "/obj/structure/disposalpipe", - "parent": "/obj/structure", - "subtypes": [], - "vars": { - "layer": 1.99 - } - }, - { - "type": "/obj/machinery/atmospherics/pipe/simple/hidden", - "parent": "/obj/machinery/atmospherics/pipe/simple", - "subtypes": [], - "vars": { - "layer": 1.999, - "alpha": 255 - } - }, - { - "type": "/obj/machinery/atmospherics/pipe/manifold/hidden", - "parent": "/obj/machinery/atmospherics/pipe/manifold", - "subtypes": [], - "vars": { - "layer": 1.999, - "alpha": 255 - } - }, - { - "type": "/obj/machinery/atmospherics/pipe/manifold4w/hidden", - "parent": "/obj/machinery/atmospherics/pipe/manifold4w", - "subtypes": [], - "vars": { - "layer": 1.999, - "alpha": 255 - } - }, - { - "type": "/obj/structure/cable", - "parent": "/obj/structure", - "subtypes": [], - "vars": { - "layer": 1.9999 - } - } - ] -} diff --git a/render/src/main/resources/config.json b/render/src/main/resources/config.json index 3bd9546..5d9aac9 100644 --- a/render/src/main/resources/config.json +++ b/render/src/main/resources/config.json @@ -3,13 +3,51 @@ { "revision": "887f80dff", "render": [ - "common_render.json" + "renders/common_render.json" + ], + "script": [ + "scripts/posters_amount.glob.groovy", + "scripts/color_window.glob.groovy", + "scripts/random_tools_icons.glob.groovy", + "scripts/adjust_window_color.var.groovy", + "scripts/airlock_overlay.img.groovy", + "scripts/color_window.var.groovy", + "scripts/handle_random_tool_color.var.groovy", + "scripts/handle_random_tool_supply.var.groovy", + "scripts/hide_content_in_closet.var.groovy", + "scripts/init_posters.var.groovy", + "scripts/smooth_carpet.var.groovy", + "scripts/smooth_wall.var.groovy", + "scripts/smooth_window.var.groovy" ] }, { "revision": "1f995d5f7", "render": [ - "specific_render/from_1f995d5f7.json" + "renders/equal_more_1f995d5f7.json" + ] + }, + { + "revision": "82304ea90", + "script": [ + "scripts/equal_more_82304ea90/handle_random_flora.var.groovy" + ] + }, + { + "revision": "0bc341bb0", + "script": [ + "scripts/equal_more_0bc341bb0/adjust_cleanable_blood_color.var.groovy", + "scripts/equal_more_0bc341bb0/smooth_table.var.groovy", + "scripts/equal_more_0bc341bb0/smooth_carpet.var.groovy" + ] + } + ], + "==": [ + { + "revision": "887f80dff", + "script": [ + "scripts/equal_887f80dff/smooth_table.var.groovy", + "scripts/equal_887f80dff/smooth_carpet.var.groovy" ] } ] diff --git a/render/src/main/resources/renders/common_render.json b/render/src/main/resources/renders/common_render.json new file mode 100644 index 0000000..add3fc0 --- /dev/null +++ b/render/src/main/resources/renders/common_render.json @@ -0,0 +1,61 @@ +{ + "definitions": [ + { + "type": "/turf/simulated/floor/plating", + "vars": { + "layer": 1.98 + } + }, + { + "type": "/obj/machinery/navbeacon", + "vars": { + "layer": 1.988 + } + }, + { + "type": "/obj/structure/disposalpipe", + "vars": { + "layer": 1.99 + } + }, + { + "type": "/obj/machinery/atmospherics/pipe/simple/hidden", + "vars": { + "layer": 1.999, + "alpha": 255 + } + }, + { + "type": "/obj/machinery/atmospherics/pipe/manifold/hidden", + "vars": { + "layer": 1.999, + "alpha": 255 + } + }, + { + "type": "/obj/machinery/atmospherics/pipe/manifold4w/hidden", + "vars": { + "layer": 1.999, + "alpha": 255 + } + }, + { + "type": "/obj/structure/cable", + "vars": { + "layer": 1.9999 + } + }, + { + "type": "/obj/machinery/atmospherics/components/unary/vent_scrubber/on", + "vars": { + "icon_state": "{text}on" + } + }, + { + "type": "/obj/machinery/atmospherics/components/unary/vent_pump/on", + "vars": { + "icon_state": "{text}out" + } + } + ] +} diff --git a/render/src/main/resources/specific_render/from_1f995d5f7.json b/render/src/main/resources/renders/equal_more_1f995d5f7.json similarity index 58% rename from render/src/main/resources/specific_render/from_1f995d5f7.json rename to render/src/main/resources/renders/equal_more_1f995d5f7.json index d87e04b..9ea2488 100644 --- a/render/src/main/resources/specific_render/from_1f995d5f7.json +++ b/render/src/main/resources/renders/equal_more_1f995d5f7.json @@ -2,43 +2,36 @@ "definitions": [ { "type": "/turf/simulated/floor", - "parent": "/turf/simulated", - "subtypes": [], "vars": { "plane": -1 } - },{ + }, + { "type": "/obj/machinery/ai_slipper", - "parent": "/obj/machinery", - "subtypes": [], "vars": { "plane": -1 } - },{ + }, + { "type": "/obj/machinery/hologram/holopad", - "parent": "/obj/machinery/hologram", - "subtypes": [], "vars": { "plane": -1 } - },{ + }, + { "type": "/obj/machinery/igniter", - "parent": "/obj/machinery", - "subtypes": [], "vars": { "plane": -1 } - },{ + }, + { "type": "/obj/structure/lattice", - "parent": "/obj/structure", - "subtypes": [], "vars": { "plane": -1 } - },{ + }, + { "type": "/obj/structure/alien/weeds", - "parent": "/obj/structure/alien", - "subtypes": [], "vars": { "plane": -1 } diff --git a/render/src/main/resources/scripts/adjust_window_color.var.groovy b/render/src/main/resources/scripts/adjust_window_color.var.groovy new file mode 100644 index 0000000..c4fc1bf --- /dev/null +++ b/render/src/main/resources/scripts/adjust_window_color.var.groovy @@ -0,0 +1,16 @@ +if (!src.isType('/obj/structure/window') && !src.isType('/obj/machinery/door/window')) + return + +def currentArea = dmm.getTile(src.x, src.y).getArea() +def colored = false + +areaColorsLists.each { areaColorList -> + if (colored) return + areaColorList.each { areaList, color -> + if (colored) return + if (currentArea.type in areaList) { + src.color = color + colored = true + } + } +} diff --git a/render/src/main/resources/scripts/airlock_overlay.img.groovy b/render/src/main/resources/scripts/airlock_overlay.img.groovy new file mode 100644 index 0000000..bb4d30d --- /dev/null +++ b/render/src/main/resources/scripts/airlock_overlay.img.groovy @@ -0,0 +1,19 @@ +if (!src.isType('/obj/machinery/door/airlock')) + return sprite + +def filling_overlay + +if (src.inner_material) { + filling_overlay = getCachedDmi(src.overlays_file).getSprite("${src.inner_material}_closed") +} else { + filling_overlay = getCachedDmi(src.icon).getSprite('fill_closed') +} + +if (filling_overlay) { + sprite.graphics.with { + drawImage(filling_overlay, 0, 0, null) + dispose() + } +} + +return sprite diff --git a/render/src/main/resources/scripts/color_window.glob.groovy b/render/src/main/resources/scripts/color_window.glob.groovy new file mode 100644 index 0000000..57c32bd --- /dev/null +++ b/render/src/main/resources/scripts/color_window.glob.groovy @@ -0,0 +1,35 @@ +def wcRed = pick(['#aa0808', '#990707', '#e50909', '#e50909']) +def wcBar = pick(['#0d8395', '#58b5c3', '#58c366', '#90d79a', '#3399ff', '#00ffff', '#ff6600', '#ffffff']) +def wcPurple = pick(['#ba62b1', '#Ba3fad', '#a54f9e', '#b549d1']) +def wcBrown = pick(['#9e5312', '#99761e', '#a56b00', '#d87f2b']) +def wcGreen = pick(['#aed18b', '#7bce23', '#5a9619', '#709348']) +def wcBlue = pick(['#8dbdd7', '#299bd8', '#1e719e', '#2bb8ff']) + +def wcRedList = [['/area/security/armoury', '/area/security/brig', '/area/security/detectives_office', + '/area/security/hos', '/area/security/lobby', '/area/security/main', '/area/security/prison', + '/area/security/warden', '/area/security/range', '/area/security/forensic_office', '/area/security/checkpoint' + ]: wcRed] +def wcPurpleList = [['/area/rnd/lab', '/area/crew_quarters/hor', '/area/rnd/hallway', '/area/rnd/xenobiology', '/area/rnd/storage', + '/area/rnd/test_area', '/area/rnd/mixing', '/area/rnd/misc_lab', '/area/rnd/telesci', '/area/rnd/scibreak', + '/area/toxins/server', '/area/assembly/chargebay', '/area/assembly/robotics', '/area/toxins/brainstorm_center', + '/area/research_outpost/hallway', '/area/research_outpost/gearstore', '/area/research_outpost/maint', '/area/research_outpost/iso1', + '/area/research_outpost/iso2', '/area/research_outpost/harvesting', '/area/research_outpost/outpost_misc_lab', + '/area/research_outpost/anomaly', '/area/research_outpost/med', '/area/research_outpost/entry', '/area/research_outpost/longtermstorage', + '/area/research_outpost/tempstorage', '/area/research_outpost/maintstore2' + ]: wcPurple] +def wcBrownList = [['/area/quartermaster/office', '/area/quartermaster/storage', '/area/quartermaster/qm', + '/area/quartermaster/recycler', '/area/quartermaster/recycleroffice', '/area/quartermaster/miningbreaktime', + '/area/quartermaster/miningoffice', '/area/mine/production', '/area/mine/eva', + '/area/mine/living_quarters', '/area/mine/maintenance', '/area/mine/west_outpost' + ]: wcBrown] +def wcGreenList = [['/area/medical/psych', '/area/medical/patients_rooms', '/area/medical/patient_a', '/area/medical/patient_b', + '/area/medical/medbreak', '/area/medical/surgeryobs', '/area/medical/surgery', '/area/medical/surgery2', + '/area/medical/hallway/outbranch', '/area/medical/virology', '/area/hydroponics', + '/area/research_outpost/maintstore1', '/area/research_outpost/sample' + ]: wcGreen] +def wcBlueList = [['/area/medical/reception', '/area/medical/morgue', '/area/medical/hallway', + '/area/medical/genetics_cloning', '/area/medical/genetics', '/area/medical/cmo' + ]: wcBlue] +def wcBarList = [['/area/crew_quarters/bar']: wcBar] + +setGlobal('areaColorsLists', [wcRedList, wcPurpleList, wcBrownList, wcGreenList, wcBlueList, wcBarList]) diff --git a/render/src/main/resources/scripts/color_window.var.groovy b/render/src/main/resources/scripts/color_window.var.groovy new file mode 100644 index 0000000..4227179 --- /dev/null +++ b/render/src/main/resources/scripts/color_window.var.groovy @@ -0,0 +1,16 @@ +if (!src.isType('/obj/structure/window') && !src.isType('/obj/machinery/door/window')) + return + +def currentArea = dmm.getTile(src.x, src.y).getArea() +def colored = false + +areaColorsLists.each { areaColorList -> + if (colored) return + areaColorList.each { areaList, color -> + if (colored) return + if (currentArea in areaList) { + src.color = color + colored = true + } + } +} diff --git a/render/src/main/resources/scripts/equal_887f80dff/smooth_carpet.var.groovy b/render/src/main/resources/scripts/equal_887f80dff/smooth_carpet.var.groovy new file mode 100644 index 0000000..9f2f811 --- /dev/null +++ b/render/src/main/resources/scripts/equal_887f80dff/smooth_carpet.var.groovy @@ -0,0 +1,58 @@ +import io.github.spair.byond.dmm.TileItem + +import static io.github.spair.byond.dmi.SpriteDir.* + +if (!src.isType('/turf/simulated/floor/carpet')) + return + +if (src.icon_state == "carpetsymbol") + return + +int connectDir = 0 + +for (direction in [1, 2, 4, 8]) { + def loc = getStep(src, direction).getLoc() + if (isCarpetFloor(loc)) { + connectDir |= direction + } +} + +int diagonalConnect = 0 + +// Northeast +if (connectDir & NORTH.dirValue && connectDir & EAST.dirValue) { + def loc = getStep(src, NORTHEAST.dirValue).getLoc() + if (isCarpetFloor(loc)) { + diagonalConnect |= 1 + } +} + +// Southeast +if (connectDir & SOUTH.dirValue && connectDir & EAST.dirValue) { + def loc = getStep(src, SOUTHEAST.dirValue).getLoc() + if (isCarpetFloor(loc)) { + diagonalConnect |= 2 + } +} + +// Northwest +if (connectDir & NORTH.dirValue && connectDir & WEST.dirValue) { + def loc = getStep(src, NORTHWEST.dirValue).getLoc() + if (isCarpetFloor(loc)) { + diagonalConnect |= 4 + } +} + +// Southwest +if (connectDir & SOUTH.dirValue && connectDir & WEST.dirValue) { + def loc = getStep(src, SOUTHWEST.dirValue).getLoc() + if (isCarpetFloor(loc)) { + diagonalConnect |= 8 + } +} + +src.icon_state = "carpet$connectDir-$diagonalConnect" + +boolean isCarpetFloor(TileItem item) { + return item.floor_type?.contains('/obj/item/stack/tile/carpet') +} \ No newline at end of file diff --git a/render/src/main/resources/scripts/equal_887f80dff/smooth_table.var.groovy b/render/src/main/resources/scripts/equal_887f80dff/smooth_table.var.groovy new file mode 100644 index 0000000..9d0251a --- /dev/null +++ b/render/src/main/resources/scripts/equal_887f80dff/smooth_table.var.groovy @@ -0,0 +1,190 @@ +package scripts.equal_more_0bc341bb0 + +if (!src.isType('/obj/structure/table')) + return + +int dirSum = 0 + +for (direction in [1, 2, 4, 8, 5, 6, 9, 10]) { + def skipSum = false + + for (W in dmm.getTile(src.x, src.y).tileItems) { + if (W.isType('/obj/structure/window')) { + if (W.dir == direction) { + skipSum = true + break + } + } + } + + int inv_direction + switch (direction) { + case 1: + inv_direction = 2 + break + case 2: + inv_direction = 1 + break + case 4: + inv_direction = 8 + break + case 8: + inv_direction = 4 + break + case 5: + inv_direction = 10 + break + case 6: + inv_direction = 9 + break + case 9: + inv_direction = 6 + break + case 10: + inv_direction = 5 + break + } + + for (W in getStep(src, direction)) { + if (W.isType('/obj/structure/window')) { + if (W.dir == inv_direction) { + skipSum = true + break + } + } + } + + if (!skipSum) { + if (locate('/obj/structure/table', getStep(src, direction))) { + if (direction < 5) { + dirSum += direction + } else { + if (direction == 5) + dirSum += 16 + else if (direction == 6) + dirSum += 32 + else if (direction == 8) + dirSum += 8 + else if (direction == 10) + dirSum += 64 + else if (direction == 9) + dirSum += 128 + } + } + } +} + +def tableType = 0 + +if (dirSum % 16 in [1, 2, 4, 8]) { + tableType = 1 + dirSum %= 16 +} + +if (dirSum % 16 in [3, 12]) { + tableType = 2 + if (dirSum % 16 == 3) + dirSum = 2 + else if (dirSum % 16 == 12) + dirSum = 4 +} + +if (dirSum % 16 in [5, 6, 9, 10]) { + if (locate('/obj/structure/table', getStep(src, dirSum % 16))) + tableType = 3 + else + tableType = 2 + dirSum %= 16 +} + +if (dirSum % 16 in [13, 14, 7, 11]) { + tableType = 5 + switch (dirSum % 16) { + case 7: + if (dirSum == 23) { + tableType = 6 + dirSum = 8 + } else if (dirSum == 39) { + dirSum = 4 + tableType = 6 + } else if (dirSum == 55 || dirSum == 119 || dirSum == 247 || dirSum == 183) { + dirSum = 4 + tableType = 3 + } else { + dirSum = 4 + } + break + case 11: + if (dirSum == 75) { + dirSum = 5 + tableType = 6 + } else if (dirSum == 139) { + dirSum = 9 + tableType = 6 + } else if (dirSum == 203 || dirSum == 219 || dirSum == 251 || dirSum == 235) { + dirSum = 8 + tableType = 3 + } else + dirSum = 8 + break + case 13: + if (dirSum == 29) { + dirSum = 10 + tableType = 6 + } else if (dirSum == 141) { + dirSum = 6 + tableType = 6 + } else if (dirSum == 189 || dirSum == 221 || dirSum == 253 || dirSum == 157) { + dirSum = 1 + tableType = 3 + } else + dirSum = 1 + break + case 14: + if (14) + if (dirSum == 46) { + dirSum = 1 + tableType = 6 + } else if (dirSum == 78) { + dirSum = 2 + tableType = 6 + } else if (dirSum == 110 || dirSum == 254 || dirSum == 238 || dirSum == 126) { + dirSum = 2 + tableType = 3 + } else + dirSum = 2 + break + } +} + +if (dirSum % 16 == 15) { + tableType = 4 +} + +switch (tableType) { + case 0: break + case 1: + src.icon_state = "${src.icon_state}_1tileendtable" + break + case 2: + src.icon_state = "${src.icon_state}_1tilethick" + break + case 3: + src.icon_state = "${src.icon_state}_dir" + break + case 4: + src.icon_state = "${src.icon_state}_middle" + break + case 5: + src.icon_state = "${src.icon_state}_dir2" + break + case 6: + src.icon_state = "${src.icon_state}_dir3" + break +} + +if (dirSum in [1, 2, 4, 8, 5, 6, 9, 10]) { + src.dir = dirSum +} else { + src.dir = 2 +} diff --git a/render/src/main/resources/scripts/equal_more_0bc341bb0/adjust_cleanable_blood_color.var.groovy b/render/src/main/resources/scripts/equal_more_0bc341bb0/adjust_cleanable_blood_color.var.groovy new file mode 100644 index 0000000..367301d --- /dev/null +++ b/render/src/main/resources/scripts/equal_more_0bc341bb0/adjust_cleanable_blood_color.var.groovy @@ -0,0 +1,6 @@ +package scripts.from_0bc341bb0 + +if (!src.isType('/obj/effect/decal/cleanable/blood')) + return + +src.color = env.getItem(src.basedatum).color diff --git a/render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_carpet.var.groovy b/render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_carpet.var.groovy new file mode 100644 index 0000000..b4ac154 --- /dev/null +++ b/render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_carpet.var.groovy @@ -0,0 +1,52 @@ +import static io.github.spair.byond.dmi.SpriteDir.* + +if (!src.isType('/turf/simulated/floor/carpet')) + return + +if (src.icon_state in ['carpetsymbol', 'blackcarpetsymbol', 'purplecarpetsymbol', 'orangecarpetsymbol', 'greencarpetsymbol', 'bluecarpetsymbol', 'blue2carpetsymbol', 'redcarpetsymbol', 'cyancarpetsymbol']) + return + +int connectDir = 0 + +for (direction in [1, 2, 4, 8]) { + def loc = getStep(src, direction).getLoc() + if (src.type == loc.type) { + connectDir |= direction + } +} + +int diagonalConnect = 0 + +// Northeast +if (connectDir & NORTH.dirValue && connectDir & EAST.dirValue) { + def loc = getStep(src, NORTHEAST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 1 + } +} + +// Southeast +if (connectDir & SOUTH.dirValue && connectDir & EAST.dirValue) { + def loc = getStep(src, SOUTHEAST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 2 + } +} + +// Northwest +if (connectDir & NORTH.dirValue && connectDir & WEST.dirValue) { + def loc = getStep(src, NORTHWEST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 4 + } +} + +// Southwest +if (connectDir & SOUTH.dirValue && connectDir & WEST.dirValue) { + def loc = getStep(src, SOUTHWEST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 8 + } +} + +src.icon_state = "${src.icon_state}$connectDir-$diagonalConnect" diff --git a/render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_table.var.groovy b/render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_table.var.groovy new file mode 100644 index 0000000..f31ae3f --- /dev/null +++ b/render/src/main/resources/scripts/equal_more_0bc341bb0/smooth_table.var.groovy @@ -0,0 +1,192 @@ +package scripts.equal_more_0bc341bb0 + +if (!src.isType('/obj/structure/table')) + return + +int dirSum = 0 + +for (direction in [1, 2, 4, 8, 5, 6, 9, 10]) { + def skipSum = false + + for (W in dmm.getTile(src.x, src.y).tileItems) { + if (W.isType('/obj/structure/window')) { + if (W.dir == direction) { + skipSum = true + break + } + } + } + + int inv_direction + switch (direction) { + case 1: + inv_direction = 2 + break + case 2: + inv_direction = 1 + break + case 4: + inv_direction = 8 + break + case 8: + inv_direction = 4 + break + case 5: + inv_direction = 10 + break + case 6: + inv_direction = 9 + break + case 9: + inv_direction = 6 + break + case 10: + inv_direction = 5 + break + } + + for (W in getStep(src, direction)) { + if (W.isType('/obj/structure/window')) { + if (W.dir == inv_direction) { + skipSum = true + break + } + } + } + + if (!skipSum) { + def T = locate('/obj/structure/table', getStep(src, direction)) + if (T && T.canconnect && src.canconnect) { + if (direction < 5) { + dirSum += direction + } else { + if (direction == 5) + dirSum += 16 + else if (direction == 6) + dirSum += 32 + else if (direction == 8) + dirSum += 8 + else if (direction == 10) + dirSum += 64 + else if (direction == 9) + dirSum += 128 + } + } + } +} + +def tableType = 0 + +if (dirSum % 16 in [1, 2, 4, 8]) { + tableType = 1 + dirSum %= 16 +} + +if (dirSum % 16 in [3, 12]) { + tableType = 2 + if (dirSum % 16 == 3) + dirSum = 2 + else if (dirSum % 16 == 12) + dirSum = 4 +} + +if (dirSum % 16 in [5, 6, 9, 10]) { + def T = locate('/obj/structure/table', getStep(src, dirSum % 16)) + if (T && T.canconnect && src.canconnect) + tableType = 3 + else + tableType = 2 + dirSum %= 16 +} + +if (dirSum % 16 in [13, 14, 7, 11]) { + tableType = 5 + switch (dirSum % 16) { + case 7: + if (dirSum == 23) { + tableType = 6 + dirSum = 8 + } else if (dirSum == 39) { + dirSum = 4 + tableType = 6 + } else if (dirSum == 55 || dirSum == 119 || dirSum == 247 || dirSum == 183) { + dirSum = 4 + tableType = 3 + } else { + dirSum = 4 + } + break + case 11: + if (dirSum == 75) { + dirSum = 5 + tableType = 6 + } else if (dirSum == 139) { + dirSum = 9 + tableType = 6 + } else if (dirSum == 203 || dirSum == 219 || dirSum == 251 || dirSum == 235) { + dirSum = 8 + tableType = 3 + } else + dirSum = 8 + break + case 13: + if (dirSum == 29) { + dirSum = 10 + tableType = 6 + } else if (dirSum == 141) { + dirSum = 6 + tableType = 6 + } else if (dirSum == 189 || dirSum == 221 || dirSum == 253 || dirSum == 157) { + dirSum = 1 + tableType = 3 + } else + dirSum = 1 + break + case 14: + if (14) + if (dirSum == 46) { + dirSum = 1 + tableType = 6 + } else if (dirSum == 78) { + dirSum = 2 + tableType = 6 + } else if (dirSum == 110 || dirSum == 254 || dirSum == 238 || dirSum == 126) { + dirSum = 2 + tableType = 3 + } else + dirSum = 2 + break + } +} + +if (dirSum % 16 == 15) { + tableType = 4 +} + +switch (tableType) { + case 0: break + case 1: + src.icon_state = "${src.icon_state}_1tileendtable" + break + case 2: + src.icon_state = "${src.icon_state}_1tilethick" + break + case 3: + src.icon_state = "${src.icon_state}_dir" + break + case 4: + src.icon_state = "${src.icon_state}_middle" + break + case 5: + src.icon_state = "${src.icon_state}_dir2" + break + case 6: + src.icon_state = "${src.icon_state}_dir3" + break +} + +if (dirSum in [1, 2, 4, 8, 5, 6, 9, 10]) { + src.dir = dirSum +} else { + src.dir = 2 +} diff --git a/render/src/main/resources/scripts/equal_more_82304ea90/handle_random_flora.var.groovy b/render/src/main/resources/scripts/equal_more_82304ea90/handle_random_flora.var.groovy new file mode 100644 index 0000000..c6411a6 --- /dev/null +++ b/render/src/main/resources/scripts/equal_more_82304ea90/handle_random_flora.var.groovy @@ -0,0 +1,8 @@ +package scripts.from_82304ea90 + +if (!src.isType('/obj/structure/flora/plant/random')) + return + +def plant = env.getItem(pick(env.getItem('/obj/structure/flora/pottedplant').getSubtypes())) +src.icon = "'$plant.icon'" +src.icon_state = plant.icon_state diff --git a/render/src/main/resources/scripts/handle_random_tool_color.var.groovy b/render/src/main/resources/scripts/handle_random_tool_color.var.groovy new file mode 100644 index 0000000..2dfcd6d --- /dev/null +++ b/render/src/main/resources/scripts/handle_random_tool_color.var.groovy @@ -0,0 +1,19 @@ +if (src.isType('/obj/item/weapon/wirecutters')) { + if (src.random_color) { + def paramColor = src.param_color + if (!paramColor) { + paramColor = pick(['yellow', 'red', 'orange']) + } + src.icon_state = "cutters_$paramColor" + } +} else if (src.isType('/obj/item/weapon/screwdriver')) { + if (src.random_color) { + def paramColor = src.param_color + if (!paramColor) { + paramColor = pick(['red', 'blue', 'purple', 'brown', 'green', 'cyan', 'yellow' ]) + } + src.icon_state = "screwdriver_$paramColor" + } + src.pixel_y = rand(-6, 6) + src.pixel_x = rand(-4, 4) +} diff --git a/render/src/main/resources/scripts/handle_random_tool_supply.var.groovy b/render/src/main/resources/scripts/handle_random_tool_supply.var.groovy new file mode 100644 index 0000000..4d96af9 --- /dev/null +++ b/render/src/main/resources/scripts/handle_random_tool_supply.var.groovy @@ -0,0 +1,5 @@ +if (src.isType('/obj/random/tools/tech_supply')) { + def icon = randomToolsIcons[pick(randomToolsNames)] + src.icon = "'$icon.icon'" + src.icon_state = pick(icon.states) +} diff --git a/render/src/main/resources/scripts/hide_content_in_closet.var.groovy b/render/src/main/resources/scripts/hide_content_in_closet.var.groovy new file mode 100644 index 0000000..3a4d9e0 --- /dev/null +++ b/render/src/main/resources/scripts/hide_content_in_closet.var.groovy @@ -0,0 +1,8 @@ +if (!src.isType('/obj/structure/closet')) + return + +dmm.getTile(src.x, src.y).tileItems.eachForTypeOnly('/obj/item') { I -> + if (!I.density && !I.anchored) { + I.alpha = 0 + } +} diff --git a/render/src/main/resources/scripts/init_posters.var.groovy b/render/src/main/resources/scripts/init_posters.var.groovy new file mode 100644 index 0000000..900d38b --- /dev/null +++ b/render/src/main/resources/scripts/init_posters.var.groovy @@ -0,0 +1,10 @@ +if (!src.isType('/obj/structure/sign/poster')) + return + +def serialNumber = rand(1, src.official ? legitPostersAmount : contrabandPostersAmount) + +if (src.official) { + src.icon_state = "poster${serialNumber}_legit" +} else { + src.icon_state = "poster$serialNumber" +} diff --git a/render/src/main/resources/scripts/posters_amount.glob.groovy b/render/src/main/resources/scripts/posters_amount.glob.groovy new file mode 100644 index 0000000..e6f5963 --- /dev/null +++ b/render/src/main/resources/scripts/posters_amount.glob.groovy @@ -0,0 +1,2 @@ +setGlobal('contrabandPostersAmount', (env.getGlobalVar('contrabandposters') =~ /list\(/).size() - 1) +setGlobal('legitPostersAmount', (env.getGlobalVar('legitposters') =~ /list\(/).size() - 1) diff --git a/render/src/main/resources/scripts/random_tools_icons.glob.groovy b/render/src/main/resources/scripts/random_tools_icons.glob.groovy new file mode 100644 index 0000000..733f45e --- /dev/null +++ b/render/src/main/resources/scripts/random_tools_icons.glob.groovy @@ -0,0 +1,14 @@ +setGlobal('randomToolsNames', ['powercell', 'technology_scanner', 'packageWrap', 'bomb_supply', 'extinguisher', 'gloves', 'cable_coil', 'toolbox', 'belt_utility', 'flashlight']) +setGlobal('randomToolsIcons', [ + 'powercell': [icon: 'icons/obj/power.dmi', states: ['cell', 'scell', 'hcell', 'hpcell', 'bscell']], + 'technology_scanner': [icon: 'icons/obj/device.dmi', states: ['t-ray0', 'walkietalkie', 'atmos', 'multitool']], + 'packageWrap': [icon: 'icons/obj/items.dmi', states: ['deliveryPaper']], + 'bomb_supply': [icon: 'icons/obj/assemblies/new_assemblies.dmi', states: ['igniter', 'prox', 'signaller']], + 'extinguisher': [icon: 'icons/obj/items.dmi', states: ['fire_extinguisher0']], + 'gloves': [icon: 'icons/obj/clothing/gloves.dmi', states: ['yellow']], + 'cable_coil': [icon: 'icons/obj/power.dmi', states: ['coil']], + 'toolbox': [icon: 'icons/obj/storage.dmi', states: ['blue', 'yellow', 'emergency']], + 'belt_utility': [icon: 'icons/obj/clothing/belts.dmi', states: ['utilitybelt']], + 'tool': [icon: 'icons/obj/tools.dmi', states: ['screwdriver_red', 'cutters_orange', 'welder', 'crowbar', 'wrench']], + 'flashlight': [icon: 'icons/obj/lighting.dmi', states: ['flashlight']] +]) diff --git a/render/src/main/resources/scripts/smooth_carpet.var.groovy b/render/src/main/resources/scripts/smooth_carpet.var.groovy new file mode 100644 index 0000000..b4ac154 --- /dev/null +++ b/render/src/main/resources/scripts/smooth_carpet.var.groovy @@ -0,0 +1,52 @@ +import static io.github.spair.byond.dmi.SpriteDir.* + +if (!src.isType('/turf/simulated/floor/carpet')) + return + +if (src.icon_state in ['carpetsymbol', 'blackcarpetsymbol', 'purplecarpetsymbol', 'orangecarpetsymbol', 'greencarpetsymbol', 'bluecarpetsymbol', 'blue2carpetsymbol', 'redcarpetsymbol', 'cyancarpetsymbol']) + return + +int connectDir = 0 + +for (direction in [1, 2, 4, 8]) { + def loc = getStep(src, direction).getLoc() + if (src.type == loc.type) { + connectDir |= direction + } +} + +int diagonalConnect = 0 + +// Northeast +if (connectDir & NORTH.dirValue && connectDir & EAST.dirValue) { + def loc = getStep(src, NORTHEAST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 1 + } +} + +// Southeast +if (connectDir & SOUTH.dirValue && connectDir & EAST.dirValue) { + def loc = getStep(src, SOUTHEAST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 2 + } +} + +// Northwest +if (connectDir & NORTH.dirValue && connectDir & WEST.dirValue) { + def loc = getStep(src, NORTHWEST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 4 + } +} + +// Southwest +if (connectDir & SOUTH.dirValue && connectDir & WEST.dirValue) { + def loc = getStep(src, SOUTHWEST.dirValue).getLoc() + if (src.type == loc.type) { + diagonalConnect |= 8 + } +} + +src.icon_state = "${src.icon_state}$connectDir-$diagonalConnect" diff --git a/render/src/main/resources/scripts/smooth_wall.var.groovy b/render/src/main/resources/scripts/smooth_wall.var.groovy new file mode 100644 index 0000000..fe3eb49 --- /dev/null +++ b/render/src/main/resources/scripts/smooth_wall.var.groovy @@ -0,0 +1,16 @@ +import static java.lang.Math.abs + +if (!src.isType('/turf/simulated/wall')) + return + +int junction = 0 + +oRange(src, 1).eachForTypeOnly('/turf/simulated/wall') { W -> + if (abs(src.x - W.x) - abs(src.y - W.y)) { + if (src.mineral == W.mineral) { + junction |= getDir(src, W) + } + } +} + +src.icon_state = "${src.walltype}$junction" diff --git a/render/src/main/resources/scripts/smooth_window.var.groovy b/render/src/main/resources/scripts/smooth_window.var.groovy new file mode 100644 index 0000000..317cd5d --- /dev/null +++ b/render/src/main/resources/scripts/smooth_window.var.groovy @@ -0,0 +1,28 @@ +import static java.lang.Math.abs +import io.github.spair.byond.dmm.TileItem + +if (!src.isType('/obj/structure/window')) + return + +if (!isFulltile(src)) { + src.icon_state = src.basestate + return +} + +int junction = 0 + +if (src.anchored) { + oRange(src, 1).eachForTypeOnly('/obj/structure/window') { W -> + if (W.anchored && W.density && isFulltile(W) && W.can_merge) { + if (abs(src.x - W.x) - abs(src.y - W.y)) { + junction |= getDir(src, W) + } + } + } +} + +src.icon_state = "${src.basestate}$junction" + +boolean isFulltile(TileItem item) { + return (item.dir & (item.dir - 1)) +}