/// <inheritdoc /> protected override void OnEventFired(object source, SelfPlayerSpawnEventArgs args) { EntityFieldDataCollection <EntityDataFieldType> entityData = CreateEntityDataCollectionFromPayload(args.CreationData.InitialFieldValues); //Don't do any checks for now, we just spawn GameObject playerGameObject = PlayerFactory.Create(new DefaultEntityCreationContext(args.CreationData.EntityGuid, args.CreationData.InitialMovementData, EntityPrefab.LocalPlayer, entityData)); //Broadcast that the player has spawned. OnLocalPlayerSpawned?.Invoke(this, new LocalPlayerSpawnedEventArgs(args.CreationData.EntityGuid)); }
protected override void OnEntityCreationFinished(EntityCreationFinishedEventArgs args) { //Obviously, we only fire the event if the spawned entity is the local player. if (IsSpawningEntityLocalPlayer(args.EntityGuid)) { OnLocalPlayerSpawned?.Invoke(this, new LocalPlayerSpawnedEventArgs(args.EntityGuid)); //Also, once we've encountered the local player spawn we can actually unsubscribe from this event Unsubscribe(); } }