1
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
"GUID:9354affc93e0f3e4a904785e7d4c0f59",
|
||||
"GUID:1235ca61e7f433b408ed5a68767e7123",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b",
|
||||
"GUID:7efac18f239530141802fb139776f333"
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:be8fc6f1c44f14943887ab6381170c28"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
21
Assets/Artists/Scripts/Scenes/PlayerSpawnPoint.cs
Normal file
21
Assets/Artists/Scripts/Scenes/PlayerSpawnPoint.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Scenes
|
||||
{
|
||||
public class PlayerSpawnPoint : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
PlayerSpawnPointService._spawnPoints.Add(this);
|
||||
destroyCancellationToken.Register(Dispose);
|
||||
}
|
||||
private void Dispose()
|
||||
{
|
||||
PlayerSpawnPointService._spawnPoints.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
Assets/Artists/Scripts/Scenes/PlayerSpawnPointService.cs
Normal file
31
Assets/Artists/Scripts/Scenes/PlayerSpawnPointService.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
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();
|
||||
public static float4x4 RequestSpawnPoint(params object[] tags)
|
||||
{
|
||||
var point = _spawnPoints.Random().transform;
|
||||
return Matrix4x4.TRS(point.position, point.rotation, point.localScale);
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
Singleton = this;
|
||||
}
|
||||
float4x4 ISpawnPointService.RequestSpawnPoint(params object[] tags)=>RequestSpawnPoint(tags);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user