BITFALL/Assets/Artists/Scripts/Scenes/PlayerSpawnPointService.cs

52 lines
1.4 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using BITFALL.Scene;
using BITKit;
using Unity.Mathematics;
using UnityEngine;
namespace BITFALL.Scenes
{
[Serializable]
public class PlayerSpawnPointSingleton : SpawnPointServiceImplement
{
protected override ISpawnPointService _spawnPointServiceImplementation=>PlayerSpawnPointService.Singleton;
}
public class PlayerSpawnPointService : MonoBehaviour,ISpawnPointService
{
internal static ISpawnPointService Singleton { get; private set; }
internal static readonly List<PlayerSpawnPoint> _spawnPoints=new();
internal static readonly Queue<float4x4> _spawnPointQueue=new();
private static int offset;
public static float4x4 RequestSpawnPoint(params object[] tags)
{
offset++;
if(offset>_spawnPoints.Count-1)offset=0;
return _spawnPoints[offset].GetSpawnPoint();
// if (_spawnPointQueue.Count is not 0) return _spawnPointQueue.Dequeue();
// var list = new List<PlayerSpawnPoint>(_spawnPoints);
// for (var i = 0; i < list.Count; i++)
// {
// var random = _spawnPoints.Random();
//
// list.Remove(random);
//
// _spawnPointQueue.Enqueue(random.GetSpawnPoint());
// }
// return _spawnPointQueue.Dequeue();
}
private void Awake()
{
Singleton = this;
}
private void OnDestroy()
{
_spawnPointQueue.Clear();
}
float4x4 ISpawnPointService.RequestSpawnPoint(params object[] tags)=>RequestSpawnPoint(tags);
}
}