-
Notifications
You must be signed in to change notification settings - Fork 378
Add townies system with occasional helpers #2129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
73930f3
47b8621
55b953e
dee61be
f12051e
b9a8ad6
2996980
5f0dd09
e5a7cf6
c404a15
1ca9bdd
d867c0c
fc14f35
446ff47
6e7dcee
11b3bf7
4b625e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # SPDX-FileCopyrightText: The Threadbare Authors | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| @tool | ||
| class_name HelperCharacterState | ||
| extends Resource | ||
|
|
||
| ## The type of help, matching the magical threads type. | ||
| ## This is left to game designers interpretation but usually: | ||
| ## [br][br] | ||
| ## - Memory is about expanding the lore of the game.[br] | ||
| ## - Imagination is about making things appear in the level.[br] | ||
| ## - Spirit is about reducing the difficulty of an action-based puzzle.[br] | ||
| @export var helper_type: InventoryItem.ItemType = InventoryItem.ItemType.NONE | ||
|
|
||
| ## The seed to display a character with same visual features when offering help. | ||
| @export var character_seed: int = 0 | ||
|
|
||
|
|
||
| ## Consume the help. | ||
| func clear() -> void: | ||
| helper_type = InventoryItem.ItemType.NONE | ||
| character_seed = 0 | ||
| emit_changed() | ||
|
|
||
|
|
||
| ## Obtain the help. | ||
| func obtain(new_helper_type: InventoryItem.ItemType, new_character_seed: int) -> void: | ||
| helper_type = new_helper_type | ||
| character_seed = new_character_seed | ||
| emit_changed() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://yu6cw51sylfu |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,18 @@ | |
| extends PanelContainer | ||
|
|
||
| const ITEM_SLOT: PackedScene = preload("uid://1mjm4atk2j6e") | ||
| const TOWNIE = preload("uid://dgrrudegturnw") | ||
|
|
||
| @onready var items_container: HBoxContainer = %ItemsContainer | ||
| @onready var helper_container: CenterContainer = %HelperContainer | ||
| @onready var helper_marker: Marker2D = %HelperMarker | ||
| @onready var helper_color: ColorRect = %HelperColor | ||
|
|
||
|
|
||
| func _ready() -> void: | ||
| GameState.global.helper.changed.connect(_on_helper_state_changed) | ||
| _on_helper_state_changed() | ||
|
|
||
| var n := 0 | ||
| if GameState.quest: | ||
| n = GameState.quest.quest.threads_to_collect | ||
|
|
@@ -31,6 +38,22 @@ func _ready() -> void: | |
| GameState.global.item_consumed.connect(self._on_item_consumed) | ||
|
|
||
|
|
||
| func _on_helper_state_changed() -> void: | ||
| var has_helper := bool(GameState.global.helper.character_seed) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So here you're not using the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh… but it's so that you can connect to the Maybe it's clear enough as you have it, don't feel the need to rewrite it all.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me try without the NONE before merging.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wjt I made it work identifying null as the lack of helper, and is much better. I added a new signal Sorry that it took me some time. I had to run the whole game again, because my state snapshots for quick testing didn't work anymore.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something I took away from a Bippinbits talk (perhaps that you shared?) was the value of a custom "run" button that lets you choose the state of the game to run. That might be useful! BTW you can also change the GameState of the running game in the inspector quite easily now. |
||
| helper_container.visible = has_helper | ||
| if has_helper: | ||
| var helper_character: CharacterRandomizer = TOWNIE.instantiate() | ||
| add_child(helper_character) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems weird at first glance to instantiate a scene, fish out its head, and delete it again. I guess this is because the seed is used for the townie as a whole.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, is only because of that. Do you think this could be done with a separate scene for the head?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having thought about it a bit, I think this is fine – it ensures that the HUD head is the same as the corresponding townie. You could imagine splitting the townie scene up into a resource for the components + corresponding colours which is input for the scene... but I don't think it's worth it. |
||
| helper_character.character_seed = GameState.global.helper.character_seed | ||
| helper_character.apply_character_randomizations() | ||
| var head := helper_character.head | ||
| head.global_position = helper_marker.global_position | ||
| head.reparent(helper_container) | ||
| head.process_mode = Node.PROCESS_MODE_DISABLED | ||
| remove_child(helper_character) | ||
| helper_color.color = InventoryItem.COLORS_PER_TYPE[GameState.global.helper.helper_type] | ||
|
|
||
|
|
||
| func _on_item_collected(item: InventoryItem) -> void: | ||
| for child in items_container.get_children(): | ||
| var item_slot := child as ItemSlot | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you put
NONEat the end because you didn't want to have to update every instance in the game. OK! Perhaps we can later reorder this and update all resources.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to have
GameState.global.helperbenullwhen there is no helper. Then you would not need to introduce theNONEmember here, which is a potential source of bugs if someone setsNONEon aCollectibleItem.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I couldn't find another way in the prior game state. But now with resources, it looks like I should be able to get rid of the NONE enum and use null on the whole helper state. Thanks! Let me try it.