Running some updated tests, I’m seeing some really strange results.
For context, I’m running this in a solo session, there are no other players in the playspace.
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Playspace := GetPlayspace()
set AllPlayers = Playspace.GetPlayers()
Playspace.PlayerAddedEvent().Subscribe(OnPlayerAdded)
Print("Running on begin")
Print(ToString(AllPlayers.Length))
var PrevPlayer : ?player = false
for (Player: AllPlayers):
if (Player = PrevPlayer?):
Print("Expected")
Print("Add player to resource manager without hook")
AddPlayerCustom(Player)
set PrevPlayer = option{Player}
OnPlayerAdded(Player: player) : void =
Print("OnPlayerAdded Hook Called")
set PlayerCount += 1
# add player to resource manager
AddPlayerCustom(Player)
I ran this under the assumption that maybe players present exactly at game start (which would be true for me in a uefn test session) aren’t picked up by the PlayerAddedEvent, since that is registered after I’ve already joined.
IF that’s the case, that makes sense, and I would expect to have to register the event for future players, and grab the current playspace and set the original players manually.
However, my output actually shows 2 players now in the playspace.
This is the output I get from this:
Running on begin
2
Add Player to resource manager without hook
Add player to resource manager without hook
Somehow my uefn session is picking up two players in the playspace. It’s also considering them unique players, otherwise that check in the for loop would have printed out “Expected”. Has anyone encountered this?