Verse Library verse

02 Device

Creates a timer that signals a custom round-ended event for system decoupling.

verse-library/verse-events-decoupling/02-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

round_manager := class(creative_device):

    @editable
    RoundTimer : timer_device = timer_device{}

    # Our own announcement: "the round is over."
    RoundEndedEvent : event() = event(){}

    OnBegin<override>()<suspends> : void =
        # When the timer succeeds, we'll announce the round ended.
        RoundTimer.SuccessEvent.Subscribe(OnTimerDone)

    # The timer's SuccessEvent carries an optional agent (?agent).
    OnTimerDone(Agent : ?agent) : void =
        Print("Round timer finished.")
        # Make ONE announcement. We don't touch any other system.
        RoundEndedEvent.Signal()

Comments

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