refactoring2
This commit is contained in:
89
Assets/Scripts/Simulator/Components/ComponentUIBinder.cs
Normal file
89
Assets/Scripts/Simulator/Components/ComponentUIBinder.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user