Skip to content

Commit

Permalink
Merging from Kronian Titans and Molten Winds. Some bugfixes, some new…
Browse files Browse the repository at this point in the history
… features
  • Loading branch information
panthavma committed Jun 18, 2023
1 parent 739d28d commit 6d07a82
Show file tree
Hide file tree
Showing 14 changed files with 489 additions and 379 deletions.
15 changes: 15 additions & 0 deletions editor/CastagneEditor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ func GetCurrentlySelectedBattleInitData():
else:
return configData.GetModuleSlot(Castagne.MODULE_SLOTS_BASE.FLOW).EditorGetCurrentBattleInitData(self, $MainMenu/FlowPanel/Custom/VBox)

func StartBattle(battleInitData = null):
if(battleInitData == null):
battleInitData = GetCurrentlySelectedBattleInitData()
queue_free()
var ce = Castagne.InstanceCastagneEngine(battleInitData, configData)
get_tree().get_root().add_child(ce)


func _on_CharacterEditNew_pressed():
EnterSubmenu("CharacterSet", null, "CharAdd")
Expand All @@ -253,6 +260,10 @@ func _on_Characters_item_activated(_index):
# Just copied from the started, a bit of a code smell lol
func _on_StartGame_pressed():
call_deferred("LoadLevel", configData.Get("PathMainMenu"))
func _on_StartGameMatch_pressed():
pass # Replace with function body.
func _on_StartGameTraining_pressed():
StartBattle()
func LoadLevel(path):
var ps = load(path)
var s = ps.instance()
Expand Down Expand Up @@ -281,3 +292,7 @@ func FlowCreateAdvancedWindow(flowRoot):

func _on_FlowNewBID_pressed():
EnterSubmenu("FlowSetup")




139 changes: 80 additions & 59 deletions editor/CastagneEditor.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ __meta__ = {

[node name="GameIcon" type="TextureRect" parent="MainMenu/Header"]
margin_right = 128.0
margin_bottom = 71.0
margin_bottom = 120.0
rect_min_size = Vector2( 128, 0 )
texture = ExtResource( 7 )
expand = true
Expand All @@ -86,29 +86,29 @@ __meta__ = {

[node name="GameTitle" type="Label" parent="MainMenu/Header"]
margin_left = 132.0
margin_top = 20.0
margin_right = 470.0
margin_bottom = 51.0
margin_top = 44.0
margin_right = 758.0
margin_bottom = 75.0
size_flags_horizontal = 3
text = "GAME NAME
GAME VERSION"
valign = 1

[node name="CastagneTitle" type="Label" parent="MainMenu/Header"]
margin_left = 474.0
margin_top = 20.0
margin_right = 812.0
margin_bottom = 51.0
margin_left = 762.0
margin_top = 44.0
margin_right = 1388.0
margin_bottom = 75.0
size_flags_horizontal = 3
text = "Castagne v0.0
text = "Castagne v0.0
2022-00-00 [MAIN]"
align = 2
valign = 1

[node name="CastagneLogo" type="TextureRect" parent="MainMenu/Header"]
margin_left = 816.0
margin_right = 1072.0
margin_bottom = 71.0
margin_left = 1392.0
margin_right = 1648.0
margin_bottom = 120.0
rect_min_size = Vector2( 256, 0 )
texture = ExtResource( 8 )
expand = true
Expand All @@ -131,100 +131,119 @@ __meta__ = {
}

[node name="Label" type="Label" parent="MainMenu/Menu"]
margin_top = 114.0
margin_right = 508.0
margin_bottom = 128.0
margin_top = 240.0
margin_right = 796.0
margin_bottom = 254.0
text = "---- Castagne ----"
align = 1

[node name="Tutorials" type="Button" parent="MainMenu/Menu"]
margin_top = 132.0
margin_right = 508.0
margin_bottom = 150.0
margin_top = 258.0
margin_right = 796.0
margin_bottom = 276.0
text = "Castagne Tutorials"

[node name="Documentation" type="Button" parent="MainMenu/Menu"]
margin_top = 154.0
margin_right = 508.0
margin_bottom = 172.0
margin_top = 280.0
margin_right = 796.0
margin_bottom = 298.0
size_flags_stretch_ratio = 0.5
text = "Documentation"

[node name="Updater" type="Button" parent="MainMenu/Menu"]
margin_top = 176.0
margin_right = 508.0
margin_bottom = 194.0
margin_top = 302.0
margin_right = 796.0
margin_bottom = 320.0
size_flags_horizontal = 3
text = "Updater"

[node name="Label2" type="Label" parent="MainMenu/Menu"]
margin_top = 198.0
margin_right = 508.0
margin_bottom = 229.0
margin_top = 324.0
margin_right = 796.0
margin_bottom = 355.0
text = "
---- Settings ----"
align = 1

[node name="Config" type="HBoxContainer" parent="MainMenu/Menu"]
margin_top = 233.0
margin_right = 508.0
margin_bottom = 251.0
margin_top = 359.0
margin_right = 796.0
margin_bottom = 377.0
size_flags_horizontal = 3
alignment = 1

[node name="Config" type="Button" parent="MainMenu/Menu/Config"]
margin_right = 426.0
margin_right = 714.0
margin_bottom = 18.0
size_flags_horizontal = 3
text = "Config Editor"

[node name="ConfigAdv" type="Button" parent="MainMenu/Menu/Config"]
margin_left = 430.0
margin_right = 508.0
margin_left = 718.0
margin_right = 796.0
margin_bottom = 18.0
text = "Advanced"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label3" type="Label" parent="MainMenu/Menu"]
margin_top = 255.0
margin_right = 508.0
margin_bottom = 286.0
margin_top = 381.0
margin_right = 796.0
margin_bottom = 412.0
text = "
---- Game ----"
align = 1

[node name="CharacterEdit" type="Button" parent="MainMenu/Menu"]
margin_top = 290.0
margin_right = 508.0
margin_bottom = 322.0
margin_top = 416.0
margin_right = 796.0
margin_bottom = 448.0
rect_min_size = Vector2( 0, 32 )
size_flags_horizontal = 3
text = "Character Editor"

[node name="CharEditOptions" type="HBoxContainer" parent="MainMenu/Menu"]
margin_top = 326.0
margin_right = 508.0
margin_bottom = 344.0
margin_top = 452.0
margin_right = 796.0
margin_bottom = 470.0

[node name="CharacterEditNew" type="Button" parent="MainMenu/Menu/CharEditOptions"]
margin_right = 252.0
margin_right = 396.0
margin_bottom = 18.0
size_flags_horizontal = 3
text = "New Character"

[node name="CharacterEditSafe" type="Button" parent="MainMenu/Menu/CharEditOptions"]
margin_left = 256.0
margin_right = 508.0
margin_left = 400.0
margin_right = 796.0
margin_bottom = 18.0
size_flags_horizontal = 3
text = "Character Editor (Safemode)"

[node name="StartGameModes" type="HBoxContainer" parent="MainMenu/Menu"]
margin_top = 474.0
margin_right = 796.0
margin_bottom = 492.0

[node name="StartGameTraining" type="Button" parent="MainMenu/Menu/StartGameModes"]
margin_right = 396.0
margin_bottom = 18.0
size_flags_horizontal = 3
text = "Start Training Mode"

[node name="StartGameMatch" type="Button" parent="MainMenu/Menu/StartGameModes"]
margin_left = 400.0
margin_right = 796.0
margin_bottom = 18.0
size_flags_horizontal = 3
disabled = true
text = "Start Normal Match"

[node name="StartGame" type="Button" parent="MainMenu/Menu"]
margin_top = 348.0
margin_right = 508.0
margin_bottom = 366.0
margin_top = 496.0
margin_right = 796.0
margin_bottom = 514.0
size_flags_horizontal = 3
disabled = true
text = "Start Game Normally (Locked until v0.55)"
Expand Down Expand Up @@ -367,27 +386,27 @@ align = 1
valign = 1

[node name="TmpOut" type="Label" parent="MainMenu/FlowPanel"]
margin_top = 211.0
margin_right = 508.0
margin_bottom = 225.0
margin_top = 348.0
margin_right = 796.0
margin_bottom = 362.0
size_flags_horizontal = 3
size_flags_vertical = 6
text = "Disabled at the moment."
align = 1
valign = 1

[node name="HSeparator" type="HSeparator" parent="MainMenu/FlowPanel"]
margin_top = 440.0
margin_right = 508.0
margin_bottom = 444.0
margin_top = 715.0
margin_right = 796.0
margin_bottom = 719.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="FlowAdvanced" type="Button" parent="MainMenu/FlowPanel"]
margin_top = 448.0
margin_right = 508.0
margin_bottom = 480.0
margin_top = 723.0
margin_right = 796.0
margin_bottom = 755.0
rect_min_size = Vector2( 0, 32 )
toggle_mode = true
text = "Advanced Flow Setup"
Expand Down Expand Up @@ -1041,8 +1060,8 @@ margin_right = -8.0
margin_bottom = -8.0

[node name="VBox" type="VBoxContainer" parent="FlowSetup/BID"]
margin_right = 598.4
margin_bottom = 528.0
margin_right = 905.6
margin_bottom = 816.0
size_flags_horizontal = 3
size_flags_vertical = 3

Expand Down Expand Up @@ -1286,6 +1305,8 @@ __meta__ = {
[connection signal="pressed" from="MainMenu/Menu/CharacterEdit" to="." method="_on_CharacterEdit_pressed"]
[connection signal="pressed" from="MainMenu/Menu/CharEditOptions/CharacterEditNew" to="." method="_on_CharacterEditNew_pressed"]
[connection signal="pressed" from="MainMenu/Menu/CharEditOptions/CharacterEditSafe" to="." method="_on_CharacterEditSafe_pressed"]
[connection signal="pressed" from="MainMenu/Menu/StartGameModes/StartGameTraining" to="." method="_on_StartGameTraining_pressed"]
[connection signal="pressed" from="MainMenu/Menu/StartGameModes/StartGameMatch" to="." method="_on_StartGameMatch_pressed"]
[connection signal="pressed" from="MainMenu/Menu/StartGame" to="." method="_on_StartGame_pressed"]
[connection signal="pressed" from="MainMenu/FlowPanel/Generic/VBox/Setup/FlowNewBID" to="." method="_on_FlowNewBID_pressed"]
[connection signal="toggled" from="MainMenu/FlowPanel/FlowAdvanced" to="." method="_on_FlowAdvanced_toggled"]
Expand Down
3 changes: 2 additions & 1 deletion editor/CastagneEditorCharacterEdit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,8 @@ func _on_Code_cursor_changed():

func CompileGizmos():
if(get_node("BottomPanel/BMiniPanel/HBox/Middle/TopBar/Other/HideGizmos").pressed):
engine.editorModule.currentGizmos = []
if(engine != null):
engine.editorModule.currentGizmos = []
return

# Temporary, but good enough for now
Expand Down
21 changes: 16 additions & 5 deletions engine/CastagneEngine.gd
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func EngineTick(previousMemory, playerInputs):
memory.GlobalSet("_TrueFrameID", memory.GlobalGet("_TrueFrameID")+1)
memory.GlobalSet("_SkipFrame", false)

var previousGameStateHandle = CreateStateHandle(previousMemory)
var gameStateHandle = CreateStateHandle(memory)

gameStateHandle.GlobalSet("_InputsRaw", playerInputs)
Expand All @@ -114,6 +113,8 @@ func EngineTick(previousMemory, playerInputs):
var activeEIDs = gameStateHandle.GlobalGet("_ActiveEntities")
for module in modules:
module.ResetVariables(gameStateHandle, activeEIDs)
#var inputPhaseFunction = funcref(configData.GetModuleSlot(Castagne.MODULE_SLOTS_BASE.INPUT), "InputPhase")
#ExecuteInternalPhase("Input", activeEIDs, gameStateHandle, inputPhaseFunction)
ExecuteScriptPhase("Freeze", activeEIDs, gameStateHandle)
return memory

Expand Down Expand Up @@ -144,7 +145,7 @@ func EngineTick(previousMemory, playerInputs):

# 3. Input Internal Phase
var inputPhaseFunction = funcref(configData.GetModuleSlot(Castagne.MODULE_SLOTS_BASE.INPUT), "InputPhase")
ExecuteInternalPhase("Input", activeEIDs, gameStateHandle, previousGameStateHandle, inputPhaseFunction)
ExecuteInternalPhase("Input", activeEIDs, gameStateHandle, inputPhaseFunction)

# 4. Action Script Phase
for module in modules:
Expand All @@ -153,7 +154,7 @@ func EngineTick(previousMemory, playerInputs):

# 5. Physics Internal Phase
var physicsPhaseFunction = funcref(configData.GetModuleSlot(Castagne.MODULE_SLOTS_BASE.PHYSICS), "PhysicsPhase")
ExecuteInternalPhase("Physics", activeEIDs, gameStateHandle, previousGameStateHandle, physicsPhaseFunction)
ExecuteInternalPhase("Physics", activeEIDs, gameStateHandle, physicsPhaseFunction)


# 6. Resolution Script Phase
Expand All @@ -180,14 +181,14 @@ func ExecuteScriptPhase(phaseName, eids, gameStateHandle):
funcref(m, phaseName+"PhaseEndEntity").call_func(gameStateHandle)
funcref(m, phaseName+"PhaseEnd").call_func(gameStateHandle)

func ExecuteInternalPhase(phaseName, activeEIDs, gameStateHandle, previousGameStateHandle, phaseFunction):
func ExecuteInternalPhase(phaseName, activeEIDs, gameStateHandle, phaseFunction):
# :TODO:Panthavma:20220126:Optimize this by making the funcrefs beforehand
for m in modules:
funcref(m, phaseName+"PhaseStart").call_func(gameStateHandle)
for eid in activeEIDs:
gameStateHandle.PointToEntity(eid)
funcref(m, phaseName+"PhaseStartEntity").call_func(gameStateHandle)
phaseFunction.call_func(gameStateHandle, previousGameStateHandle, activeEIDs)
phaseFunction.call_func(gameStateHandle, activeEIDs)
for m in modules:
for eid in activeEIDs:
gameStateHandle.PointToEntity(eid)
Expand Down Expand Up @@ -500,6 +501,16 @@ var _memories = []
var MAX_MEMORIES_IN_MEMORY = 16
var _nextMemoryID = 0
func CreateMemory(copyFrom = null):
if(_memories.empty()):
var newMemory = Node.new()
newMemory.set_script(_prefabMemory)
newMemory.InitMemory()
add_child(newMemory)
_memories.push_back(newMemory)
return _memories[0]


# :TODO:Panthavma:20230617:Put back actual memory management back in when we go faster for rollback
if(_memories.size() < MAX_MEMORIES_IN_MEMORY):
var newMemory = Node.new()
newMemory.set_script(_prefabMemory)
Expand Down
Loading

0 comments on commit 6d07a82

Please sign in to comment.