-
Notifications
You must be signed in to change notification settings - Fork 261
InkCombatRound6: Implement Sequential Filling Mechanic #1865
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
base: main
Are you sure you want to change the base?
Changes from all commits
03608a8
566ebec
4a51929
d233f85
1c1ec84
70c6083
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -37,8 +37,11 @@ const FILLING_NAME_ANIMATION: StringName = &"filling" | |||||
| @export var color: Color: | ||||||
| set = _set_color | ||||||
|
|
||||||
| var is_locked: bool = false | ||||||
|
|
||||||
| var _amount: int = 0 | ||||||
|
|
||||||
| @onready var barrel_glow: AnimatedSprite2D = $BarrelGlow | ||||||
| @onready var animated_sprite_2d: AnimatedSprite2D = %AnimatedSprite2D | ||||||
| @onready var animation_player: AnimationPlayer = %AnimationPlayer | ||||||
| @onready var collision_shape_2d: CollisionShape2D = %CollisionShape2D | ||||||
|
|
@@ -70,10 +73,29 @@ func _ready() -> void: | |||||
| animated_sprite_2d.animation = FILLING_NAME_ANIMATION | ||||||
| animated_sprite_2d.frame = 0 | ||||||
|
|
||||||
| if barrel_glow: | ||||||
|
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. You have this line above: @onready var barrel_glow: AnimatedSprite2D = $BarrelGlow
You should do one of the following two things:
(You may ask, why does |
||||||
| barrel_glow.visible = false | ||||||
|
|
||||||
|
|
||||||
| func set_locked_state(locked: bool) -> void: | ||||||
|
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.
Suggested change
|
||||||
| is_locked = locked | ||||||
|
|
||||||
| if is_locked: | ||||||
| modulate = Color(0.5, 0.5, 0.5, 1) | ||||||
|
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. Perhaps define a |
||||||
| if barrel_glow: | ||||||
| barrel_glow.visible = false | ||||||
| else: | ||||||
| modulate = Color(1, 1, 1, 1) | ||||||
|
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.
Suggested change
|
||||||
| if barrel_glow: | ||||||
| barrel_glow.visible = true | ||||||
| barrel_glow.play("glowing") | ||||||
|
|
||||||
|
|
||||||
| ## Increment the amount and play an animation. If completed, also play the completed | ||||||
| ## animation and remove this barrel from the current scene. | ||||||
| func increment(by: int = 1) -> void: | ||||||
| if is_locked: | ||||||
| return | ||||||
| if _amount >= needed_amount: | ||||||
| return | ||||||
| animation_player.play(&"increment") | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| [remap] | ||
|
|
||
| importer="texture" | ||
| type="CompressedTexture2D" | ||
| uid="uid://brranfy51i56n" | ||
| path="res://.godot/imported/barrel_glow.png-05ec822d59b536030b7c5094e7b8b456.ctex" | ||
| metadata={ | ||
| "vram_texture": false | ||
| } | ||
|
|
||
| [deps] | ||
|
|
||
| source_file="res://scenes/quests/lore_quests/quest_003/2_ink_drinker_levels/components/barrel_glow/barrel_glow.png" | ||
| dest_files=["res://.godot/imported/barrel_glow.png-05ec822d59b536030b7c5094e7b8b456.ctex"] | ||
|
|
||
| [params] | ||
|
|
||
| compress/mode=0 | ||
| compress/high_quality=false | ||
| compress/lossy_quality=0.7 | ||
| compress/uastc_level=0 | ||
| compress/rdo_quality_loss=0.0 | ||
| compress/hdr_compression=1 | ||
| compress/normal_map=0 | ||
| compress/channel_pack=0 | ||
| mipmaps/generate=false | ||
| mipmaps/limit=-1 | ||
| roughness/mode=0 | ||
| roughness/src_normal="" | ||
| process/channel_remap/red=0 | ||
| process/channel_remap/green=1 | ||
| process/channel_remap/blue=2 | ||
| process/channel_remap/alpha=3 | ||
| process/fix_alpha_border=true | ||
| process/premult_alpha=false | ||
| process/normal_map_invert_y=false | ||
| process/hdr_as_srgb=false | ||
| process/hdr_clamp_exposure=false | ||
| process/size_limit=0 | ||
| detect_3d/compress_to=1 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||
| # SPDX-FileCopyrightText: The Threadbare Authors | ||||||
| # SPDX-License-Identifier: MPL-2.0 | ||||||
| class_name BarrelUnlockSequence | ||||||
| extends Node | ||||||
|
|
||||||
| @export var barrels: Array[FillingBarrel] | ||||||
| @export var auto_start: bool = true | ||||||
|
|
||||||
| var current_target_index: int = 0 | ||||||
|
|
||||||
|
|
||||||
| func _ready() -> void: | ||||||
| if auto_start: | ||||||
| call_deferred("start_sequence") | ||||||
|
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.
Suggested change
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. But why do you need to defer this? |
||||||
|
|
||||||
|
|
||||||
| func start_sequence() -> void: | ||||||
| randomize() | ||||||
|
|
||||||
|
Comment on lines
+18
to
+19
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.
Suggested change
|
||||||
| if barrels.is_empty(): | ||||||
| push_warning("BarrelUnlockSequence: No barrels assigned.") | ||||||
| return | ||||||
|
|
||||||
| barrels.shuffle() | ||||||
|
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. I don't think the order should necessarily be shuffled. The order of the barrels is part of the level design - for example, you could imagine designing a level where it would be impossible to get across a bridge until the first barrel is filled. Another way of looking at this is: if the order is random each time the level is played, then why do I (the level designer) have to manually assign the barrels to this node, rather than this component discovering the barrels in the scene by itself?
Some ideas:
|
||||||
|
|
||||||
| for barrel in barrels: | ||||||
| if not barrel.completed.is_connected(_on_barrel_completed): | ||||||
| barrel.completed.connect(_on_barrel_completed) | ||||||
|
|
||||||
| # Initial state: all locked | ||||||
| barrel.set_locked_state(true) | ||||||
|
|
||||||
| unlock_next_barrel() | ||||||
|
|
||||||
|
|
||||||
| func unlock_next_barrel() -> void: | ||||||
| if current_target_index < barrels.size(): | ||||||
| var target: FillingBarrel = barrels[current_target_index] | ||||||
|
|
||||||
| if is_instance_valid(target): | ||||||
|
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. I'm always a bit suspicious of |
||||||
| target.set_locked_state(false) | ||||||
|
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. If you add the
Suggested change
|
||||||
|
|
||||||
|
|
||||||
| func _on_barrel_completed() -> void: | ||||||
| current_target_index += 1 | ||||||
| unlock_next_barrel() | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uid://en37d2lad0px |
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.
Please document this field.
Uh oh!
There was an error while loading. Please reload this page.
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.
Also make the
set_locked_statefunction a setter for this field:(I suggest renaming the method below.)