bool GetSpawnPositionFromInteriors(out TransformDataStruct transformData) { transformData = World.Cell.GetEnexExitTransform( World.Cell.Instance.GetEnexesFromLoadedInteriors() .ToList() .RandomElement()); return(true); }
public virtual bool GetSpawnPosition(Player player, out TransformDataStruct transformData) { if (null == World.Cell.Instance || World.Cell.Instance.HasExterior) { return(SpawnManager.GetSpawnPositionFromFocus(out transformData)); } else { return(SpawnManager.GetSpawnPositionFromInteriors(out transformData)); } }
public bool GetSpawnPosition(out TransformDataStruct transformData) { if (null == World.Cell.Instance || World.Cell.Instance.HasExterior) { return(GetSpawnPositionFromFocus(out transformData)); } else { return(GetSpawnPositionFromInteriors(out transformData)); } }
bool GetSpawnPositionFromFocus(out TransformDataStruct transformData) { Transform focusPos = GetSpawnFocusPos(); if (null == focusPos) { transformData = new TransformDataStruct(); return(false); } transformData = new TransformDataStruct( focusPos.position + Random.insideUnitCircle.ToVector3XZ() * 15f, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); return(true); }
List <TransformDataStruct> GetSpawnPositionsFromFocus() { var spawns = new List <TransformDataStruct>(); Transform focusPos = GetSpawnFocusPos(); if (null == focusPos) { return(spawns); } for (int i = 0; i < 5; i++) { var transformData = new TransformDataStruct(focusPos.position + Random.insideUnitCircle.ToVector3XZ() * 15f); spawns.Add(transformData); } return(spawns); }
public static Ped SpawnPlayer(Player player, TransformDataStruct spawnPlace) { if (player.OwnedPed != null) { return(null); } var ped = Ped.SpawnPed(Ped.RandomPedId, spawnPlace.position, spawnPlace.rotation, false); ped.NetPlayerOwnerGameObject = player.gameObject; ped.WeaponHolder.autoAddWeapon = true; // this ped should not be destroyed when he gets out of range ped.gameObject.DestroyComponent <OutOfRangeDestroyer>(); NetManager.Spawn(ped.gameObject); player.OwnedPed = ped; Debug.LogFormat("Spawned ped {0} for player {1}, time: {2}", ped.DescriptionForLogging, player.DescriptionForLogging, F.CurrentDateForLogging); return(ped); }