stuff less important than the shader
This commit is contained in:
+63
-48
@@ -2,57 +2,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UntitledLogicGame.Gates;
|
||||
|
||||
public class Gate : MonoBehaviour
|
||||
namespace UntitledLogicGame
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
private bool HasState;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public List<Anchor> Anchors { get; set; }
|
||||
public IEnumerable<Anchor> InputAnchors => Anchors.Where(a => a.IsInput);
|
||||
public IEnumerable<Anchor> OutputAnchors => Anchors.Where(a => !a.IsInput);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
public class Gate : MonoBehaviour
|
||||
{
|
||||
Utils.RandomName("Gate", gameObject);
|
||||
Anchors = GetComponentsInChildren<Anchor>().ToList();
|
||||
}
|
||||
#region Unity Properties
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
public bool HasState;
|
||||
public GateType GateType;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public List<Anchor> Anchors { get; set; }
|
||||
public IEnumerable<Anchor> InputAnchors => Anchors.Where(a => a.IsInput);
|
||||
public IEnumerable<Anchor> OutputAnchors => Anchors.Where(a => !a.IsInput);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private GateDefinition _definition;
|
||||
private int _lastState = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName(GateType.ToString(), gameObject);
|
||||
Anchors = GetComponentsInChildren<Anchor>().ToList();
|
||||
_definition = GateDefinition.Get(GateType, this);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
var state = _definition.GetState(this).ToInt();
|
||||
if(state != _lastState)
|
||||
{
|
||||
_definition.Compute(this);
|
||||
_lastState = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
return !HasState && (
|
||||
InputAnchors.Contains(target) ||
|
||||
InputAnchors.Any(a => a.HasInputAnchor(target))
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
return !HasState && (
|
||||
InputAnchors.Contains(target) ||
|
||||
InputAnchors.Any(a => a.HasInputAnchor(target))
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user