Verse Library verse

01 Snippet

Interface for integrating Fort Round gameplay simulation lifecycle with UE Scene Graph components.

extracted-snippets/community/snippets/558p/fortnite-fort-round-gameplay-interface-for-scene-graph-components/01-snippet.verse

# Source URL: https://dev.epicgames.com/community/snippets/558p/fortnite-fort-round-gameplay-interface-for-scene-graph-components
# Local doc:  epic-docs/community/snippets/558p/fortnite-fort-round-gameplay-interface-for-scene-graph-components.md
  using. /Fortnite.com/Game
  using. /Verse.org/Concurrency
  using. /Verse.org/SceneGraph
  using. /Verse.org/Simulation
  fort_round_simulate_interface<public> := interface {
  var<private> FortRoundManagerSubscriptions<private> : []cancelable = array{}
  var<private> _CancelFortRoundGameplayEvent<private> : ?event() = false
  var<private> _FortRoundGameplayHandlerTask<private> : ?task(void) = false
  var<private> IsFortRoundSimulating<public><final> : logic = false
  var<private> _FortRoundStartEvent<private> : ?event() = false
  var<private> _FortRoundEndEvent<private> : ?event() = false
  IsFortRoundGameplayActive<public><final>()<computes><decides><reads>:void = _FortRoundGameplayHandlerTask?
  <# Start listening to Fort Round Events. Calling this before OnAddedToScene will silently fail.
  If Fort Round is already running, will trigger the FortRoundSimulate callbacks immediately. #>
  StartFortRoundGameplay<public><final>():void = {
  SelfComponent := if (_SelfComponent := component[Self]). _SelfComponent else. return
  if (not SelfComponent.IsInScene[]). return
  if (IsFortRoundSimulating?). OnFortRoundStartInternal()
  if (IsFortRoundGameplayActive[]). return
  if (FortRoundManager := SelfComponent.Entity.GetFortRoundManager[]) {
  InitializeEventsInternal()
  # Keeping the Round Subscriptions cached so they do not get garbage collected
  set FortRoundManagerSubscriptions = array{
  FortRoundManager.SubscribeRoundStarted(OnFortRoundStartInternal)
  FortRoundManager.SubscribeRoundEnded(OnFortRoundEndInternal)
  }
  # Keeping the Task cached so it does not get garbage collected
  FortRoundGameplayHandlerTask := spawn { FortRoundGameplayHandler() }

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