split into multiple assemblies
This commit is contained in:
63
Assets/Engine/Runtime/SpaceTile.cs
Normal file
63
Assets/Engine/Runtime/SpaceTile.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum TileLocation
|
||||
{
|
||||
NW, N, NE,
|
||||
W, C, E,
|
||||
SW, S, SE
|
||||
}
|
||||
|
||||
public class SpaceTile : MonoBehaviour
|
||||
{
|
||||
public static HashSet<TileLocation> EveryTileLocation => new(new[]
|
||||
{
|
||||
TileLocation.NW, TileLocation.N, TileLocation.NE,
|
||||
TileLocation.W, TileLocation.C, TileLocation.E,
|
||||
TileLocation.SW, TileLocation.S, TileLocation.SE
|
||||
});
|
||||
|
||||
[BoxGroup("Style Prefabs")] [SerializeField]
|
||||
private UDictionary<TileLocation, GameObject> tilePrefabs;
|
||||
[BoxGroup("Style Prefabs")] [SerializeField]
|
||||
private Material material;
|
||||
|
||||
public TileLocation showTile;
|
||||
|
||||
private GameObject _tile;
|
||||
private TileLocation _showTile;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetTile();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_showTile != showTile)
|
||||
{
|
||||
SetTile();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTile()
|
||||
{
|
||||
if (_tile)
|
||||
{
|
||||
Destroy(_tile);
|
||||
}
|
||||
|
||||
_tile = Instantiate(tilePrefabs[showTile], transform);
|
||||
_tile.isStatic = true;
|
||||
_tile.GetComponent<MeshRenderer>().material = material;
|
||||
|
||||
_showTile = showTile;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user