using Fie.Object; using Fie.Ponies; using Fie.User; using UnityEngine; namespace Fie.Manager { [FieManagerExists(FieManagerExistSceneFlag.OUTGAME)] public class FieLobbyGameCharacterGenerateManager : FieManagerBehaviour { public delegate void LobbyGameCharacterCreatedCallback(); private Vector3 _playerInitPosition = Vector3.zero; public Vector3 playerInitPosition => _playerInitPosition; protected override void StartUpEntity() { FiePlayerSpawnPoint[] array = UnityEngine.Object.FindObjectsOfType(); if (array != null && array.Length > 0) { int num = 2147483647; for (int i = 0; i < array.Length; i++) { if (array[i].spawnPointNumber < num) { _playerInitPosition = array[i].transform.position; } } } } public void RequestToCreateGameCharacter(FieUser user, LobbyGameCharacterCreatedCallback lobbyCallback) where T : FieGameCharacter { FieGameCharacterManager.GameCharacterCreatedCallback callback = delegate(T gameCharacter) { user.usersCharacter = gameCharacter; if (FieManagerBehaviour.I.myHash == user.userHash) { FieManagerBehaviour.I.StartUp(); FieManagerBehaviour.I.ReloadUIOwner(); FieManagerBehaviour.I.ShowHeaderFooter(); FieManagerBehaviour.I.SetUserCharacter(FieManagerBehaviour.I.getUserNumberByHash(FieManagerBehaviour.I.myHash), gameCharacter); FieManagerBehaviour.I.ValidateUserName(FieManagerBehaviour.I.myPlayerNumber); gameCharacter.InitializeIntelligenceSystem(FieGameCharacter.IntelligenceType.Controllable); } else if (!PhotonNetwork.offlineMode) { gameCharacter.InitializeIntelligenceSystem(FieGameCharacter.IntelligenceType.Connection); } else { gameCharacter.InitializeIntelligenceSystem(FieGameCharacter.IntelligenceType.AI); } Vector3 origin = _playerInitPosition + Vector3.up; Vector3 normalized = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)).normalized; Vector3 vector = _playerInitPosition + normalized * 1f; int layerMask = 1049088; if (Physics.Raycast(origin, normalized, out RaycastHit hitInfo, 1f, layerMask)) { vector = hitInfo.point; } layerMask = 512; if (Physics.Raycast(vector, Vector3.down, out hitInfo, 20f, layerMask) && hitInfo.collider.tag == "Floor") { vector = hitInfo.point; } gameCharacter.position = vector; gameCharacter.transform.SetParent(FieManagerBehaviour.I.transform); user.usersCharacter = gameCharacter; gameCharacter.SetOwnerUser(user); gameCharacter.getStateMachine().setState(typeof(FieStateMachinePoniesArrival), isForceSet: true); FieManagerBehaviour.I.RebuildPlayerInformationCommand(); if (lobbyCallback != null) { lobbyCallback(); } }; FieManagerBehaviour.I.CreateGameCharacter(callback); } } }