Files
Net.Project.B/Src/WorldNode/UnitySeatNode.cs
CortexCore b07ae4fea7 1
2025-02-24 23:02:49 +08:00

58 lines
1.6 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.WorldNode;
#if UNITY_5_3_OR_NEWER
using BITKit.Entities;
using UnityEngine;
using UnityEngine.Events;
#endif
namespace Net.Project.B.WorldNode
{
[Serializable]
public class UnitySeatNode :IWorldNode
{
public int Id { get; set; }
public object WorldObject { get; set; }
#if UNITY_5_3_OR_NEWER
[SerializeField]private float cameraDistance= 2;
public Rigidbody Rigidbody;
public Transform SeatObject;
public Transform CameraObject;
public Transform ExitObject;
public IEntity Occupant
{
get => _occupant;
set
{
if(Equals(_occupant,value))return;
_occupant = value;
onOccupantChanged.Invoke(_occupant);
onOccupantArrived.Invoke(_occupant!=null);
}
}
private IEntity _occupant;
[SerializeField]private UnityEvent<bool> onOccupantArrived;
[SerializeField]private UnityEvent<IEntity> onOccupantChanged;
public event Action<bool> OnOccupantArrived
{
add => onOccupantArrived.AddListener(value.Invoke);
remove => onOccupantArrived.RemoveListener(value.Invoke);
}
public event Action<IEntity> OnOccupantChanged
{
add => onOccupantChanged.AddListener(value.Invoke);
remove => onOccupantChanged.RemoveListener(value.Invoke);
}
public float CameraDistance => cameraDistance;
#endif
}
}