Eisuke114
(Eisuke114)
1
I want to cancel a listenable await. In the following code, the MutetDisable
method is used to disable it, but the await remains. What should I do?
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
TaxiJob_device := class(creative_device):
@editable
TaxiSalary:int = 100
@editable
JobZone:[]mutator_zone_device = array{}
@editable
taxi:vehicle_spawner_taxi_device = vehicle_spawner_taxi_device{}
SuccessEvent<public>:event(int) = event(int){}
var count : int = 0
var isEnd : logic = false
OnBegin<override>()<suspends>:void=
MutetDisable()
taxi.AgentEntersVehicleEvent.Subscribe(OnStartJob)
taxi.AgentExitsVehicleEvent.Subscribe(OnEndJob)
OnStartJob(Agent : agent):void=
Print("TaxiJob started")
set isEnd = false
spawn { OnJobbing() }
OnEndJob(Agent : agent):void=
Print("TaxiJob ended")
set isEnd = true
MutetDisable
OnJobbing()<suspends>:void=
Print("TaxiJob jobbing")
rand := GetRandomInt(0, JobZone.Length-1)
NextActiveZone(rand)
NextActiveZone(nowRand : int)<suspends>:void=
nextRand := GetDiffrentRandomValue(nowRand)
if (nowZone := JobZone[nowRand]):
nowZone.Enable()
nowZone.AgentEntersEvent.Await()
nowZone.Disable()
Print("TaxiJob Success!!")
if (isEnd = false):
Salary := TaxiSalary + count
SuccessEvent.Signal(Salary)
set count += 1
NextActiveZone(nextRand)
else:
Print("TaxiJob End")
return
GetDiffrentRandomValue(value : int):int=
rand := GetRandomInt(0, JobZone.Length-1)
if (rand = value):
return GetDiffrentRandomValue(value)
return rand
MutetDisable()<suspends>:void=
for (zone : JobZone):
zone.Disable()
If you assign the subscription to a variable you can call cancel using that variable.
DamageSubscribe := Fort.DamagedEvent().Subscribe(OnPlayerDamaged)
DamageSubscribe.Cancel()
Eisuke114
(Eisuke114)
4
Sorry, my information was insufficient.
I am trying to cancel Await
in the following part.
nowZone.Enable()
AgentEntersEvent.Await()
Disable()
Eisuke114
(Eisuke114)
5
By the way, I tried changing from Await to using Subscribe but it did not work properly.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
TaxiJob_device := class(creative_device):
@editable
TaxiSalary:int = 10000
@editable
EnableOrder:int = 0
@editable
JobZone:[]mutator_zone_device = array{}
@editable
taxi:vehicle_spawner_taxi_device = vehicle_spawner_taxi_device{}
SuccessEvent<public>:event(int) = event(int){}
var count : int = 0
var isEnd : logic = false
var defaultTransform : transform = transform{}
var ControlChangeSubscription:?cancelable = false
var Zone : mutator_zone_device = mutator_zone_device{}
var NextRand : int = 0
OnBegin<override>()<suspends>:void=
GetTaxiTransform()
MoveTaxi()
MutetDisable()
for (zone : JobZone):
zone.Disable()
taxi.AgentEntersVehicleEvent.Subscribe(OnStartJob)
taxi.AgentExitsVehicleEvent.Subscribe(OnEndJob)
GetTaxiTransform()<suspends>:void=
set defaultTransform = taxi.GetTransform()
MoveTaxi()<suspends>:void=
NewRotation := rotation{}
vec := vector3{X:=1000.0, Y:=1000.0, Z:=0.0}
if(taxi.TeleportTo[vec, NewRotation]):
Print("MoveTrigger")
ReturnTaxi()<suspends>:void=
if(taxi.TeleportTo[defaultTransform]):
taxi.RespawnVehicle()
Print("ReturnTrigger")
OnStartJob(Agent : agent):void=
Print("TaxiJob started")
set isEnd = false
spawn { OnJobbing() }
OnEndJob(Agent : agent):void=
Print("TaxiJob ended")
set isEnd = true
MutetDisable
OnJobbing()<suspends>:void=
Print("TaxiJob jobbing")
rand := GetRandomInt(0, JobZone.Length-1)
NextActiveZone(rand)
NextActiveZone(nowRand : int)<suspends>:void=
nextRand := GetDiffrentRandomValue(nowRand)
set NextRand = nextRand
if (nowZone := JobZone[nowRand]):
nowZone.Enable()
set Zone = nowZone
Temp:cancelable = Zone.AgentEntersEvent.Subscribe(ZoneSubscribe)
set ControlChangeSubscription = option { Temp }
ZoneSubscribe(Agent : agent):void=
Zone.Disable()
Print("TaxiJob Success!!")
if (isEnd = false):
Salary := TaxiSalary + count
SuccessEvent.Signal(Salary)
set count += 1000
spawn {NextActiveZone(NextRand)}
else:
Print("TaxiJob End")
return
GetDiffrentRandomValue(value : int):int=
rand := GetRandomInt(0, JobZone.Length-1)
if (rand = value):
return GetDiffrentRandomValue(value)
return rand
MutetDisable()<suspends>:void=
if (Subscription := ControlChangeSubscription?):
Print("TaxiJob Disable")
Subscription.Cancel()
Zone.Disable()
GetOrder<public>():int=
return EnableOrder
Enable<public>():void=
spawn { ReturnTaxi() }
Print(“TaxiJob Disable”)` is no longer called in the following code section.
MutetDisable()<suspends>:void=
if (Subscription := ControlChangeSubscription?):
Print("TaxiJob Disable")
Subscription.Cancel()
Zone.Disable()