Files
XRLib/Assets/Scripts/Simulator/Components/ComponentUIBinder.cs

90 lines
3.8 KiB
C#
Raw Normal View History

2026-02-26 14:04:33 +09:00
using UnityEngine;
namespace Simulator.Data
{
public class ComponentUIBinder
{
private ProgressPopupView _progressPopupView;
private SourceProperty _sourceProperty;
private SinkProperty _sinkProperty;
private RackProperty _rackProperty;
private QueueProperty _queueProperty;
private ASRSProperty _asrsProperty;
private RobotArmProperty _robotArmProperty;
private ProcessorProperty _processorProperty;
private ConveyorProperty _conveyorProperty;
private NodeProperty _nodeProperty;
public void Initialize()
{
_progressPopupView = Object.FindAnyObjectByType<ProgressPopupView>(FindObjectsInactive.Include);
_sourceProperty = Object.FindAnyObjectByType<SourceProperty>();
_sinkProperty = Object.FindAnyObjectByType<SinkProperty>();
_rackProperty = Object.FindAnyObjectByType<RackProperty>();
_queueProperty = Object.FindAnyObjectByType<QueueProperty>();
_asrsProperty = Object.FindAnyObjectByType<ASRSProperty>();
_robotArmProperty = Object.FindAnyObjectByType<RobotArmProperty>();
_processorProperty = Object.FindAnyObjectByType<ProcessorProperty>();
_conveyorProperty = Object.FindAnyObjectByType<ConveyorProperty>();
_nodeProperty = Object.FindAnyObjectByType<NodeProperty>();
}
public void BindStandardComponent(ComponentBase component)
{
switch (component.componentType)
{
case ComponentType.Source:
if (_sourceProperty != null)
component.onComponentClicked += _sourceProperty.SetPropertyWindow;
if (_progressPopupView != null)
component.onComponentClicked += _progressPopupView.Show;
break;
case ComponentType.Sink:
if (_sinkProperty != null)
component.onComponentClicked += _sinkProperty.SetPropertyWindow;
if (_progressPopupView != null)
component.onComponentClicked += _progressPopupView.Show;
break;
case ComponentType.Processor:
if (_processorProperty != null)
component.onComponentClicked += _processorProperty.SetPropertyWindow;
if (_progressPopupView != null)
component.onComponentClicked += _progressPopupView.Show;
break;
case ComponentType.Rack:
if (_rackProperty != null)
component.onComponentClicked += _rackProperty.SetPropertyWindow;
break;
case ComponentType.Queue:
if (_queueProperty != null)
component.onComponentClicked += _queueProperty.SetPropertyWindow;
break;
case ComponentType.ASRS:
if (_asrsProperty != null)
component.onComponentClicked += _asrsProperty.SetPropertyWindow;
break;
case ComponentType.RobotArm:
if (_robotArmProperty != null)
component.onComponentClicked += _robotArmProperty.SetPropertyWindow;
break;
case ComponentType.Worker:
break;
}
}
public void BindConveyor(ConveyorComponent conveyor)
{
if (_conveyorProperty != null)
conveyor.onConveyorClicked += _conveyorProperty.SetPropertyWindow;
}
public void BindNode(NodeComponent node)
{
if (_nodeProperty != null)
node.onConveyorClicked += _nodeProperty.SetPropertyWindow;
}
}
}