refactor modules
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using NaughtyAttributes;
|
||||
using Station46.Runtime;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Station46.Dispenser.Scripts
|
||||
{
|
||||
[Serializable]
|
||||
public struct DispenserLightRow
|
||||
{
|
||||
public bool[] lights;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This component controls the grid of lights on the dispenser.
|
||||
/// </summary>
|
||||
public class DispenserLights : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Control the pattern of lights on a dispenser.")]
|
||||
[SerializeField]
|
||||
private DispenserLightRow[] lights;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private GameObject lightPrefab;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Vector2Int gridDimensions;
|
||||
[BoxGroup("Internal")] [SerializeField]
|
||||
private Vector2 lightOffset;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for (var y = 0; y < gridDimensions.y; y++)
|
||||
{
|
||||
var row = lights[y].lights;
|
||||
for (var x = 0; x < gridDimensions.x; x++)
|
||||
{
|
||||
var instance = Instantiate(lightPrefab, transform, false);
|
||||
instance.transform.localPosition = new Vector3(-x * lightOffset.x, 0, y * lightOffset.y);
|
||||
instance.GetComponent<Emission>().active = row[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user