From bbfd3cf88127449aee20177b816d951406cc69bc Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 29 Nov 2023 00:48:55 +0900 Subject: [PATCH] open/cave mix control via tile survey --- assets/locales/koKR/terrarum_sentences.json | 2 +- assets/mods/basegame/materials/materials.csv | 55 ++++++++++--------- src/net/torvald/terrarum/audio/AudioMixer.kt | 4 +- .../torvald/terrarum/blockstats/TileSurvey.kt | 8 +-- .../terrarum/itemproperties/Material.kt | 3 + .../terrarum/modulebasegame/TerrarumIngame.kt | 23 ++++++++ .../terrarum/worlddrawer/FeaturesDrawer.kt | 4 +- 7 files changed, 65 insertions(+), 34 deletions(-) diff --git a/assets/locales/koKR/terrarum_sentences.json b/assets/locales/koKR/terrarum_sentences.json index a7d79b9b6..e560f39f8 100644 --- a/assets/locales/koKR/terrarum_sentences.json +++ b/assets/locales/koKR/terrarum_sentences.json @@ -18,7 +18,7 @@ "MENU_IO_WORLDGEN_GROWING_MINERALS": "광물을 키우는 중...", "MENU_IO_WORLDGEN_POSITIONING_ROCKS": "바위들의 위치 조정 중...", "MENU_IO_WORLDGEN_RETICULATING_SPLINES": "망상 구조 결합 중...", - "MENU_LABEL_AUDIO_BUFFER_INSTRUCTION": "오디오 끊김이 들리지 않는 선에서 가장 작은 값으로 설정해주십시오.\n오디오에 끊김이 있다면 더 큰 값으로 설정하고 게임을 재시작하십시오.\n더 큰 값은 오디오 처리의 안정성을 증가시키지만 딜레이도 더 늘어나게 합니다.", + "MENU_LABEL_AUDIO_BUFFER_INSTRUCTION": "오디오 끊김이 들리지 않는 선에서 가장 작은 값으로 설정해주십시오.\n오디오에 끊김이 있다면 더 큰 값으로 설정하고 게임을 재시작하십시오.\n더 큰 값은 오디오 처리의 안정성을 증가시키지만 처리 지연도 더 늘립니다.", "MENU_LABEL_KEYCONFIG_HELP1": "키캡을 클릭해 컨트롤을 배정하십시오", "MENU_LABEL_SAVE_WILL_BE_DELETED": "선택된 세이브가 삭제됩니다.", "MENU_LABEL_UNSAVED_PROGRESS_WILL_BE_LOST": "저장하지 않은 진행 상황을 잃게 됩니다.", diff --git a/assets/mods/basegame/materials/materials.csv b/assets/mods/basegame/materials/materials.csv index 7b480a22b..582efc759 100644 --- a/assets/mods/basegame/materials/materials.csv +++ b/assets/mods/basegame/materials/materials.csv @@ -1,28 +1,31 @@ -idst;tens;impf;dsty;fmod;endurance;tcond;reach;rcs;comments -WOOD;10;10;800;1;0.173;0.17;5;18;just a generic wood -ROCK;15;210;3000;1;0.42;2.9;5;48;data is that of marble -OORE;15;210;3000;1;0.42;2.9;5;100;data is that of marble -OGEM;15;210;3000;1;0.42;2.9;5;80;data is that of marble -CUPR;210;770;8960;2;1.00;401.0;5;120;copper -EGLS;33;1000;2325;4;0.82;1.0;6;10;elven glass/moldavite -IRON;350;1085;7874;5;1.42;80.4;6;120;not wrought iron,just natural iron -ARGN;170;595;10490;9;0.91;429.0;6;120;argentum/silver -AURM;120;350;19300;9;0.88;318.0;6;120;aurum/gold -STAL;531;2520;7874;14;1.73;26.0;7;120;steel -EAUR;768;0;8192;21;1.36;1.0;7;120;elven aurichalcum -TIAL;900;0;4420;33;2.16;1.0;8;120;titanium alloy (Ti6Al4V) -ADMT;2000;4090;2700;71;3.42;1.0;8;120;adamant -OOZE;20;0;1000;1;0.08;0.5;0;10;genetic ooze,data is about human skin -BONE;130;0;2000;1;0.23;0.55;4;10;data is that of bovine bone -BRAS;315;1015;8530;3;1.00;120;5;120;brass -BRNZ;310;843;8770;3;1.20;75;5;120;bronze -TINN;220;350;7310;2;1.00;69;5;120;tin -ZINC;90;525;7140;2;1.00;116;5;120;zinc -DIRT;1;1;1400;0.0;0.0;36;0;10;dirt -PLST;1;1;1400;0.0;0.0;36;0;16;TODO plastic (polyethylene) -AIIR;1;1;1;0.0;0.0;36;0;1;air -SAND;1;1;2400;0.0;0.0;36;0;36;sand -GRVL;1;1;2400;0.0;0.0;36;0;36;gravel +idst;tens;impf;dsty;fmod;endurance;tcond;reach;rcs;sondrefl;comments +WOOD;10;10;800;1;0.173;0.17;5;18;0.5;just a generic wood +ROCK;15;210;3000;1;0.42;2.9;5;48;1.0;data is that of marble +GLSS;15;210;3000;1;0.42;2.9;5;48;1.0;glass +OORE;15;210;3000;1;0.42;2.9;5;100;0.2;data is that of marble +OGEM;15;210;3000;1;0.42;2.9;5;80;0.2;data is that of marble +CUPR;210;770;8960;2;1.00;401.0;5;120;1.0;copper +EGLS;33;1000;2325;4;0.82;1.0;6;10;1.0;elven glass/moldavite +IRON;350;1085;7874;5;1.42;80.4;6;120;1.0;not wrought iron,just natural iron +ARGN;170;595;10490;9;0.91;429.0;6;120;1.0;argentum/silver +AURM;120;350;19300;9;0.88;318.0;6;120;1.0;aurum/gold +STAL;531;2520;7874;14;1.73;26.0;7;120;1.0;steel +EAUR;768;0;8192;21;1.36;1.0;7;120;1.0;elven aurichalcum +TIAL;900;0;4420;33;2.16;1.0;8;120;1.0;titanium alloy (Ti6Al4V) +ADMT;2000;4090;2700;71;3.42;1.0;8;120;1.0;adamant +OOZE;20;0;1000;1;0.08;0.5;0;10;0.0;genetic ooze,data is about human skin +BONE;130;0;2000;1;0.23;0.55;4;10;0.1;data is that of bovine bone +BRAS;315;1015;8530;3;1.00;120;5;120;1.0;brass +BRNZ;310;843;8770;3;1.20;75;5;120;1.0;bronze +TINN;220;350;7310;2;1.00;69;5;120;1.0;tin +ZINC;90;525;7140;2;1.00;116;5;120;1.0;zinc +DIRT;1;1;1400;0.0;0.0;36;0;10;0.25;dirt +SAND;1;1;2400;0.0;0.0;36;0;36;0.25;sand +GRVL;1;1;2400;0.0;0.0;36;0;36;0.25;gravel +PLST;1;1;1400;0.0;0.0;36;0;16;0.5;TODO plastic (polyethylene) +GRSS;1;1;1400;0.0;0.0;36;0;10;-0.03;dirt +AIIR;1;1;1;0.0;0.0;36;0;1;-0.03;air +NULL;1;1;1;0.0;0.0;36;0;1;-0.03;air # idst: ID_STRING, ALL CAPS # @@ -46,6 +49,8 @@ GRVL;1;1;2400;0.0;0.0;36;0;36;gravel # # rcs: Radar Cross Section -- how well the material reflects the radio wave used by the Ground Penetrating Radar. # +# sondrefl: Sound Reflective Power. Hard surface (glass) is 1.0 +# # Comments: do nothing;do not parse # diff --git a/src/net/torvald/terrarum/audio/AudioMixer.kt b/src/net/torvald/terrarum/audio/AudioMixer.kt index d14b9a690..0909882ed 100644 --- a/src/net/torvald/terrarum/audio/AudioMixer.kt +++ b/src/net/torvald/terrarum/audio/AudioMixer.kt @@ -230,14 +230,14 @@ object AudioMixer: Disposable { it.pan = (it.pan - 0.001f).coerceIn(-1f, 1f) } }*/ - if (Gdx.input.isKeyPressed(Input.Keys.UP)) { + /*if (Gdx.input.isKeyPressed(Input.Keys.UP)) { convolveBusOpen.volume = (convolveBusOpen.volume + 0.001).coerceIn(0.0, 1.0) convolveBusCave.volume = 1.0 - convolveBusOpen.volume } else if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) { convolveBusOpen.volume = (convolveBusOpen.volume - 0.001).coerceIn(0.0, 1.0) convolveBusCave.volume = 1.0 - convolveBusOpen.volume - } + }*/ diff --git a/src/net/torvald/terrarum/blockstats/TileSurvey.kt b/src/net/torvald/terrarum/blockstats/TileSurvey.kt index 500313db9..47996e136 100644 --- a/src/net/torvald/terrarum/blockstats/TileSurvey.kt +++ b/src/net/torvald/terrarum/blockstats/TileSurvey.kt @@ -20,11 +20,11 @@ object TileSurvey { val height: Int, val spatialGranularity: Int, // 1: survey every (w*h) tile, 2: survey every other (w*h/4) tile ... val temporalGranularity: Int, // 1: survey every frame, 2: every other frame ... - val predicate: (GameWorld, Int, Int) -> Boolean + val predicate: (GameWorld, Int, Int) -> Float ) private val proposals = HashMap() - private val results = HashMap>() // (matching tiles/actually surveyed tiles) + private val results = HashMap>() // (ratio of accumulated data to total tile count / raw accumulated data) fun submitProposal(proposal: SurveyProposal) { proposals[proposal.surveyIdentifier] = proposal @@ -54,11 +54,11 @@ object TileSurvey { val for_x_end = ceil(player.intTilewiseHitbox.centeredX + proposal.width / 2.0).toInt() val for_y_end = ceil(player.intTilewiseHitbox.centeredY + proposal.height / 2.0).toInt() - var akku = 0 + var akku = 0f for (y in for_y_start until for_y_end step proposal.spatialGranularity) { for (x in for_x_start until for_x_end step proposal.spatialGranularity) { - if (proposal.predicate(world, x, y)) akku += 1 + akku += proposal.predicate(world, x, y) } } diff --git a/src/net/torvald/terrarum/itemproperties/Material.kt b/src/net/torvald/terrarum/itemproperties/Material.kt index 670e169ae..fcd93d749 100644 --- a/src/net/torvald/terrarum/itemproperties/Material.kt +++ b/src/net/torvald/terrarum/itemproperties/Material.kt @@ -31,6 +31,8 @@ class Material { var rcs: Int = 10 + var sondrefl: Float = 0f + /** * Mainly intended to be used by third-party modules */ @@ -73,6 +75,7 @@ class MaterialCodex { prop.identifier = it.get("idst").toUpperCase() prop.toolReach = it.intVal("reach") prop.rcs = it.intVal("rcs") + prop.sondrefl = it.floatVal("sondrefl") materialProps[prop.identifier] = prop diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index 62a428462..f0fbe068e 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -278,6 +278,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { CREATE_NEW, LOAD_FROM } + private val soundReflectiveMaterials = hashSetOf( + "" + ) + override fun show() { //initViewPort(AppLoader.terrarumAppConfig.screenW, AppLoader.terrarumAppConfig.screenH) @@ -295,6 +299,17 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { super.show() // this function sets gameInitialised = true + + TileSurvey.submitProposal( + TileSurvey.SurveyProposal( + "basegame.Ingame.audioReflection", 72, 48, 2, 4 + ) { world, x, y -> + val tileProp = BlockCodex[world.getTileFromTerrain(x, y)] + val wallProp = BlockCodex[world.getTileFromWall(x, y)] + val prop = if (tileProp.isSolid && !tileProp.isActorBlock) tileProp else wallProp + MaterialCodex[prop.material].sondrefl + } + ) } data class NewGameParams( @@ -869,9 +884,17 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) { oldCamX = WorldCamera.x oldPlayerX = actorNowPlaying?.hitbox?.canonicalX ?: 0.0 + // update audio mixer + val ratio = (TileSurvey.getRatio("basegame.Ingame.audioReflection") ?: 0.0).coerceIn(0.0, 1.0) + AudioMixer.convolveBusCave.volume = ratio + AudioMixer.convolveBusOpen.volume = 1.0 - ratio + + + WORLD_UPDATE_TIMER += 1 + // run benchmark if F2 is on if (KeyToggler.isOn(Input.Keys.F2)) { deltaTeeBenchmarks.appendHead(1f / Gdx.graphics.deltaTime) diff --git a/src/net/torvald/terrarum/worlddrawer/FeaturesDrawer.kt b/src/net/torvald/terrarum/worlddrawer/FeaturesDrawer.kt index 1f9807b00..d72b2bc34 100644 --- a/src/net/torvald/terrarum/worlddrawer/FeaturesDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/FeaturesDrawer.kt @@ -33,12 +33,12 @@ object FeaturesDrawer { TileSurvey.submitProposal( TileSurvey.SurveyProposal( "basegame.FeaturesDrawer.coldTiles", 72, 48, 2, 2 - ) { world, x, y -> BlockCodex[world.getTileFromTerrain(x, y)].hasTag("COLD") } + ) { world, x, y -> BlockCodex[world.getTileFromTerrain(x, y)].hasTag("COLD").toInt().toFloat() } ) TileSurvey.submitProposal( TileSurvey.SurveyProposal( "basegame.FeaturesDrawer.warmTiles", 72, 48, 2, 2 - ) { world, x, y -> BlockCodex[world.getTileFromTerrain(x, y)].hasTag("WARM") } + ) { world, x, y -> BlockCodex[world.getTileFromTerrain(x, y)].hasTag("WARM").toInt().toFloat() } ) }