Skip to content

Instantly share code, notes, and snippets.

@spilth
Created March 29, 2023 03:26
Show Gist options
  • Save spilth/8e8b12214ba2aecab592e7969367b0dd to your computer and use it in GitHub Desktop.
Save spilth/8e8b12214ba2aecab592e7969367b0dd to your computer and use it in GitHub Desktop.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
capture_barrier := class<concrete>:
@editable
CaptureItemSpawnerDevice:capture_item_spawner_device = capture_item_spawner_device{}
@editable
BarrierDevice:barrier_device = barrier_device{}
capture_barrier_manager_device := class(creative_device):
@editable
CaptureBarriers:[]capture_barrier = array{}
var RandomIndex:int = 0
OnBegin<override>()<suspends>:void=
Print("CaptureBarrierManagerDevice")
for(Index:= 0..CaptureBarriers.Length):
Print("{Index}")
if (CaptureBarrier := CaptureBarriers[Index]):
Print("Subscribing {Index}")
CaptureBarrier.CaptureItemSpawnerDevice.ItemReturnedEvent.Subscribe(OnItemReturned)
CaptureBarrier.CaptureItemSpawnerDevice.ItemReturnedEvent.Subscribe(OnItemDropped)
EnableRandomBarrier()
OnItemDropped(Player:agent):void=
Print("Item Dropped!")
OnItemReturned(Player:agent):void=
Print("Item Returned!")
EnableRandomBarrier()
EnableRandomBarrier():void=
# Re-enable the current one
if (CaptureBarrier := CaptureBarriers[RandomIndex]):
CaptureBarrier.BarrierDevice.Enable()
# Disable a new random one
set RandomIndex = GetRandomInt(0, CaptureBarriers.Length - 1)
if (CaptureBarrier := CaptureBarriers[RandomIndex]):
Print("Disabling {RandomIndex}")
CaptureBarrier.BarrierDevice.Disable()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment