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

69 lines
1.7 KiB
C#
Raw Normal View History

2025-10-16 10:24:29 +09:00
using Simulator.Data;
2025-12-16 17:57:20 +09:00
using System;
2025-10-16 10:24:29 +09:00
using UnityEngine;
2025-11-11 11:27:39 +09:00
using UnityEngine.EventSystems;
2025-10-16 10:24:29 +09:00
using UVC.Data.Core;
public enum ComponentType
{
Source,
Sink,
2025-11-04 11:02:02 +09:00
Rack,
Queue,
2025-12-08 10:59:29 +09:00
ASRS,
2025-12-11 18:26:09 +09:00
RobotArm,
Processor,
Worker
2025-10-16 10:24:29 +09:00
}
2025-11-11 11:27:39 +09:00
public class ComponentBase : MonoBehaviour,IPointerClickHandler
2025-10-16 10:24:29 +09:00
{
protected ComponentDataBase data;
protected ModelDataBase modelData;
public ComponentType componentType;
2025-12-24 17:36:01 +09:00
public Action<ComponentType,ComponentDataBase> onComponentClicked;
2025-10-16 10:24:29 +09:00
public void SetPosition()
{
2025-11-11 09:42:47 +09:00
transform.position = new Vector3(data.physical.position.x, data.physical.position.z, -data.physical.position.y);
2025-10-16 10:24:29 +09:00
}
public virtual void GetModelData(DataObject modelData)
{
}
2025-11-04 11:02:02 +09:00
public virtual void DecreaseEntity(Entity entity)
{
}
2025-11-11 11:27:39 +09:00
2025-12-17 11:42:57 +09:00
public virtual void getpath()
{
}
2025-11-11 11:27:39 +09:00
protected void FitCollider()
{
var renderers = GetComponentsInChildren<Renderer>();
if (renderers.Length == 0) return;
Bounds bounds = renderers[0].bounds;
foreach (var r in renderers)
bounds.Encapsulate(r.bounds);
BoxCollider collider = GetComponent<BoxCollider>();
if (!collider) collider = gameObject.AddComponent<BoxCollider>();
collider.center = transform.InverseTransformPoint(bounds.center);
collider.size = transform.InverseTransformVector(bounds.size);
collider.size = new Vector3(Mathf.Abs(collider.size.x), Mathf.Abs(collider.size.y), Mathf.Abs(collider.size.z));
collider.isTrigger = true;
}
public void OnPointerClick(PointerEventData eventData)
{
2025-12-24 17:36:01 +09:00
GameObject clickedObject = eventData.pointerCurrentRaycast.gameObject;
Debug.Log(clickedObject.name);
2025-12-17 11:42:57 +09:00
getpath();
2025-11-11 11:27:39 +09:00
}
2025-10-16 10:24:29 +09:00
}