Hello!
I have three classes:
- A “Device Manager” that is used to handle groups of creative devices and functions that go along with those devices.
- A “Custom Player” class that maps the individual player stats.
- A “Game Manager” device that handles all of the classes combined (I have way more that I am using but they are irrelevant to this question.)
My issue is that when I call a function in my “Game Manager” from a “Device Manager” and then try to access a function in my custom player map, the code is never run. (See “HelloWorldFunc” below).
Just to clarify:
- I call “HelloWorld” in my general game manager from a device manager. This works great.
- After that HelloWorld function is called, I tried to access a function in my custom player map and it never works. I also get no error.
Does anyone know how I can solve this?
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation/Tags }
GameManager := class<unique>(creative_device):
HelloWorld(Agent : agent):void=return
DeviceManager := class<unique>():
GameStarted()<suspends>:void=return
spawner := class(tag){}
game_manager := class(GameManager):
var CustomPlayers : [player]custom_player = map{}
@editable CustomDevices : []custom_device = array{}
OnBegin<override>()<suspends>:void=
GetPlayspace().PlayerRemovedEvent().Subscribe(OnPlayerLeft)
InitSpawners()
for (CD : CustomDevices):
spawn. CD.GameStarted()
InitSpawners():void=
Spawners := GetCreativeObjectsWithTag(spawner{})
for (Obj : Spawners):
if (Spawner := player_spawner_device[Obj]) {Spawner.SpawnedEvent.Subscribe(OnPlayerSpawned)}
OnPlayerSpawned(Agent : agent):void=
if (Player := player[Agent]) {InitPlayer(Player)}
OnPlayerLeft(PlayerLeaving : player):void=
if (CustomPlayer := CustomPlayers[PlayerLeaving]):
CustomPlayer.Dispose()
var NewCustomPlayerMap : [player]custom_player = map{}
for (Key -> Value : CustomPlayers, Key <> PlayerLeaving):
set NewCustomPlayerMap = ConcatenateMaps(NewCustomPlayerMap, map{Key => Value})
set CustomPlayers = NewCustomPlayerMap
InitPlayer(Player : player):void=
if:
Agent := agent[Player]
Fort := Agent.GetFortCharacter[]
then:
if (Existing := CustomPlayers[Player]){}
else:
CustomPlayer := custom_player{Player := Player}
CustomPlayer.Init()
if (set CustomPlayers[Player] = CustomPlayer) {}
HelloWorld<override>(Agent : agent):void=
Print("This will Print")
if:
Player := player[Agent]
CustomPlayer := CustomPlayers[Player]
then (CustomPlayer.HelloWorldFunc(Agent))
custom_player := class<unique>():
Player : player
Init():void=
Print("This Will Print!")
Dispose():void=
Print("This Will Print!")
HelloWorldFunc(Agent : agent):void=
Print("This Will Not Print")
#####
##### HERE DOWNWARD WOULD BE A NEW VERSE FILE, ONLY MISSING "using"s
#####
custom_device := class<concrete>(DeviceManager):
@editable GameManagerEditable : game_manager = game_manager{}
@editable RandomMutator : mutator_zone_device = mutator_zone_device{}
GameStarted<override>()<suspends>:void=
Print("This Will Print!")
RandomMutator.AgentEntersEvent.Subscribe(RunFunction)
RunFunction(Agent : agent):void=
Print("This Will Print!")
GameManagerEditable.HelloWorld(Agent)