InteractableStep
交互步骤接口(遗留)
基本信息
| 属性 | 值 |
|---|---|
| 路径 | com.gtnewhorizons.navigator.api.model.steps.InteractableStep |
| 行数 | 43 |
| 继承 | extends LocationInteractableStep |
遗留定位(源码注释 :12-13)
New non-waypoint layers should use LocationInteractableStep. This interface remains for source and binary compatibility and for layers that intentionally use the default double-click waypoint behavior.
即本接口只为兼容旧图层保留,新代码不要用。
⚠️ 「binary compatibility」意味着已有 mod 的实现类不会失效 —— 它们的类仍能编译、仍能工作。
4 个 default 方法
| 方法 | 行 | 返回 |
|---|---|---|
onKeyPressed(int keyCode) |
:21-~22 |
覆写默认派发(见下) |
getLocation() |
:30-~32 |
IWaypointAndLocationProvider |
getLocationProvider() |
:40-~42 |
同上(第二个入口) |
(继承)onClick(...) |
— | false |
⚠️ getLocation() 与 getLocationProvider() 是两个方法返回同一个类型
—— 重复的 API 入口。getLocationProvider() 很可能是
getLocation() 的别名(default 委托)。
⚠️ getLocation() 的返回类型被协变收窄:
RenderStep 里是 ILocationProvider,
本接口改成 IWaypointAndLocationProvider(其子类型)
—— 合法,但覆写时要注意不能反向放宽。
三个 default 的关系
RenderStep.getLocation() → ILocationProvider (null)
└─ InteractableStep.getLocation() → IWaypointAndLocationProvider
└─ InteractableStep.getLocationProvider() → IWaypointAndLocationProvider
推荐实现
UniversalInteractableStep(21 行)——
README.md 说明
or UniversalInteractableStep when double-click should toggle a waypoint。
⚠️ 两者按「双击是否切换路点」区分:
| 实现 | 双击行为 |
|---|---|
| UniversalLocationInteractableStep | 无路点语义 |
| UniversalInteractableStep | 切换路点 |
相关
- LocationInteractableStep - 父接口(推荐直接用)
- RenderStep - 祖父接口
- UniversalInteractableStep - 推荐实现
- IWaypointAndLocationProvider - 返回类型