65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Net.Project.B.Interaction
|
||
|
{
|
||
|
|
||
|
public enum WorldInteractionProcess
|
||
|
{
|
||
|
None,
|
||
|
Hover,
|
||
|
Started,
|
||
|
Tap,
|
||
|
Hold,
|
||
|
Performed,
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 可互动类型
|
||
|
/// </summary>
|
||
|
public interface IWorldInteractable
|
||
|
{
|
||
|
public int Id { get; }
|
||
|
public IWorldInteractable Root { get; }
|
||
|
public IWorldInteractionType InteractionType { get; }
|
||
|
public object WorldObject { get; set; }
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 世界互动服务
|
||
|
/// </summary>
|
||
|
public interface IWorldInteractionService
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 注册可互动对象
|
||
|
/// </summary>
|
||
|
/// <param name="interactable"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool Register(IWorldInteractable interactable);
|
||
|
/// <summary>
|
||
|
/// 注销可互动对象
|
||
|
/// </summary>
|
||
|
/// <param name="interactable"></param>
|
||
|
/// <returns></returns>
|
||
|
public bool Unregister(IWorldInteractable interactable);
|
||
|
/// <summary>
|
||
|
/// 尝试获取互动
|
||
|
/// </summary>
|
||
|
/// <param name="id">通常是Collider InstanceId</param>
|
||
|
/// <param name="interactable">可互动对象</param>
|
||
|
/// <returns></returns>
|
||
|
public bool TryGetValue(int id, out IWorldInteractable interactable);
|
||
|
/// <summary>
|
||
|
/// 互动
|
||
|
/// </summary>
|
||
|
/// <param name="sender">互动者</param>
|
||
|
/// <param name="interactable">互动对象</param>
|
||
|
/// <param name="process">过程,例如开始,完成,结束</param>
|
||
|
/// <returns>是否互动成功</returns>
|
||
|
bool Interaction(object sender,IWorldInteractable interactable,WorldInteractionProcess process=WorldInteractionProcess.Performed);
|
||
|
/// <summary>
|
||
|
/// 互动回调
|
||
|
/// </summary>
|
||
|
public event Action<object,IWorldInteractable,WorldInteractionProcess,object> OnInteraction;
|
||
|
}
|
||
|
}
|