Verse Library verse

10 Final Code For Puzzle Verse

Defines the main component class managing puzzle state and descendant entity references.

extracted-snippets/documentation/en-us/fortnite/lights-and-bridges-02-puzzle-component-in-fortnite/10-final-code-for-puzzle-verse.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/lights-and-bridges-02-puzzle-component-in-fortnite
# Local doc:  epic-docs/documentation/en-us/fortnite/lights-and-bridges-02-puzzle-component-in-fortnite.md
# Section:    Final Code for Puzzle.verse
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/SceneGraph }
using { Logging }
puzzle_solved_event<public> := class(scene_event){}
# Scene Graph component handling puzzle component triggered events and when the puzzle is solved.
puzzle_component := class<final_super>(component):
# Is this puzzle component solved
var<private> Solved<public>:logic = false
# Map of puzzle pieces and whether they have been "solved"
var<private> TriggerableEntities<private>:[]entity = array{}
# Disable puzzle pieces triggering once puzzle is solved
@editable
DisablePuzzleTriggerablesWhenSolved<private>:logic = false
# Initialize array of triggerable entities
InitializeTriggereableDescendantEntities<private>()<transacts>:void=
for:
DescendantEntity : Entity.FindDescendantEntities(entity))
DescendantEntityComponent : DescendantEntity.GetComponents()
CastToTriggerable := triggerable[DescendantEntityComponent]
CastToTriggerable.PuzzlePiece?
do:
set TriggerableEntities += array{DescendantEntity}
# Decides whether puzzle is solved
IsPuzzleSolved<private>()<decides><transacts>:void=
for:
TriggerableEntity : TriggerableEntities

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in