Skip to content

Commit

Permalink
path stones percent
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Nov 30, 2023
1 parent 9ac01f3 commit d33dcc6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Autoload/Cube.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const rngCube = {
#"EarthPathUnderneath" : [25,26,27,28,29], # This is apparently unnecessary, it'll just flood the column indexes
}

const stoneRatio = 0.15

enum {
SIDE_NORTH = 0,
SIDE_EAST = 1,
Expand Down
5 changes: 5 additions & 0 deletions Autoload/Settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var listOfSettings = [
"placing_tutorial",
"chance_effect_water",
"chance_effect_lava",
"chance_path_stone",
"auto_open_map_settings",
"fortify",
"automatic_torch_slabs",
Expand Down Expand Up @@ -400,6 +401,10 @@ func game_setting(doWhat,string,value):
var oLavaEffectPercent = $'../Main/Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer2/LavaEffectPercent'
if doWhat == SET: oLavaEffectPercent.value = value
if doWhat == GET: return oLavaEffectPercent.value
"chance_path_stone":
var oPathStonePercent = $'../Main/Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer3/PathStonePercent'
if doWhat == SET: oPathStonePercent.value = value
if doWhat == GET: return oPathStonePercent.value
"auto_open_map_settings":
var oCheckBoxNewMapAutoOpensMapSettings = $'../Main/Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabUI/VBoxContainer/CheckBoxNewMapAutoOpensMapSettings'
if doWhat == SET: oCheckBoxNewMapAutoOpensMapSettings.pressed = value
Expand Down
22 changes: 22 additions & 0 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2466,6 +2466,27 @@ value = 2.5
suffix = "%"
script = ExtResource( 81 )

[node name="HBoxContainer3" type="HBoxContainer" parent="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer"]
margin_top = 35.0
margin_right = 532.0
margin_bottom = 66.0

[node name="Label" type="Label" parent="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer3"]
margin_top = 5.0
margin_right = 149.0
margin_bottom = 26.0
text = "Place Path stones"

[node name="PathStonePercent" type="SpinBox" parent="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer3"]
margin_left = 458.0
margin_right = 532.0
margin_bottom = 31.0
size_flags_horizontal = 10
step = 0.1
value = 15.0
suffix = "%"
script = ExtResource( 81 )

[node name="BridgesOnlyOnLiquidCheckbox" type="CheckBox" parent="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer"]
margin_top = 70.0
margin_right = 532.0
Expand Down Expand Up @@ -7057,6 +7078,7 @@ script = SubResource( 20 )
[connection signal="toggled" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabFiles/VBoxContainer/CheckBoxAlwaysDecompress" to="Ui/UiSystem/PreferencesWindow" method="_on_CheckBoxAlwaysDecompress_toggled"]
[connection signal="value_changed" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer/WaterEffectPercent" to="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements" method="_on_WaterEffectPercent_value_changed"]
[connection signal="value_changed" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer2/LavaEffectPercent" to="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements" method="_on_LavaEffectPercent_value_changed"]
[connection signal="value_changed" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/HBoxContainer3/PathStonePercent" to="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements" method="_on_PathStonePercent_value_changed"]
[connection signal="toggled" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/BridgesOnlyOnLiquidCheckbox" to="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements" method="_on_BridgesOnlyOnLiquidCheckbox_toggled"]
[connection signal="toggled" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/OwnableNaturalTerrain" to="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements" method="_on_OwnableNaturalTerrain_toggled"]
[connection signal="toggled" from="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements/MarginContainer/VBoxContainer/EditableBordersCheckbox" to="Ui/UiSystem/PreferencesWindow/VBoxContainer/TabSettings/TabPlacements" method="_on_EditableBordersCheckbox_toggled"]
Expand Down
15 changes: 15 additions & 0 deletions Scenes/SlabPlacement.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ onready var oRoundGoldNearPath = Nodelist.list["oRoundGoldNearPath"]
onready var oRoundGoldNearLiquid = Nodelist.list["oRoundGoldNearLiquid"]
onready var oRoundWaterNearLava = Nodelist.list["oRoundWaterNearLava"]
onready var oAutomaticTorchSlabsCheckbox = Nodelist.list["oAutomaticTorchSlabsCheckbox"]
onready var oPathStonePercent = Nodelist.list["oPathStonePercent"]

enum dir {
s = 0
Expand Down Expand Up @@ -571,10 +572,24 @@ func place_general(xSlab, ySlab, slabID, ownership, surrID, surrOwner, bitmaskTy
if slabID == Slabs.LAVA: # Just hardcode the random FloorTexture for lava. I think it only looks different in the editor.
for i in constructedFloor.size():
constructedFloor[i] = Random.choose([546,547])
elif slabID == Slabs.PATH:
randomize_path_cubes(constructedColumns)



set_columns(xSlab, ySlab, constructedColumns, constructedFloor)
oPlaceThingWithSlab.place_slab_objects(xSlab, ySlab, slabID, ownership, slabsetIndexGroup, bitmask, surrID, bitmaskType)

func randomize_path_cubes(constructedColumns):
var pthClean = Cube.rngCube["PathClean"]
var pthStones = Cube.rngCube["PathWithStones"]
for i in 9:
var cubeID = constructedColumns[i][0]
if cubeID in pthClean or cubeID in pthStones:
if Random.rng.randf_range(0.0, 100.0) < oPathStonePercent.value:
constructedColumns[i][0] = Random.choose(pthStones)
else:
constructedColumns[i][0] = Random.choose(pthClean)

func get_constructed_slab_data(columnsetIndexList):
var constructedColumns = []
Expand Down
6 changes: 6 additions & 0 deletions Scenes/SlabSettingsWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ func _on_LavaEffectPercent_value_changed(value):
func _on_WaterEffectPercent_value_changed(value):
Settings.set_setting("chance_effect_water", value)


func _on_PathStonePercent_value_changed(value):
Settings.set_setting("chance_path_stone", value)


func _on_PlaceThingsAnywhere_toggled(value):
Settings.set_setting("place_things_anywhere", value)


func _on_AutomaticTorchSlabsCheckbox_toggled(value):
Settings.set_setting("automatic_torch_slabs", value)

0 comments on commit d33dcc6

Please sign in to comment.