油锅 5 加入更好的提示
This commit is contained in:
1 parent
b69e487b10
commit
5627e040ce
7 files changed
+98
-138
No files matched your search
+3
-37
@@ -141,7 +141,7 @@ class YouguoTimerService(BlueFoxServerSystem):
|
||||
tdur = blockData["rtdd_tdur"]
|
||||
|
||||
if time.time() - tstart >= tdur:
|
||||
self._finishTimer(dim, pos, rule, blockData)
|
||||
self._finishTimer(dim, pos, rule)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -154,14 +154,9 @@ class YouguoTimerService(BlueFoxServerSystem):
|
||||
tp = ""
|
||||
self._notifyIfOnline(tp, "§c油锅下的炉灶移走了, 暂停炸制")
|
||||
|
||||
def _finishTimer(self, dim, pos, rule, data):
|
||||
def _finishTimer(self, dim, pos, rule):
|
||||
"""到点转换(计时结束提示已取消, 只保留放料时的开始提示; 炉灶移走提示走 _handleBelowBroken)"""
|
||||
try:
|
||||
# 先取出发起玩家(下方 replaceBlock/_clearTimerData 会把实体数据清掉, 必须提前读)
|
||||
tp = ""
|
||||
try:
|
||||
tp = data["rtdd_tp"] or ""
|
||||
except Exception:
|
||||
tp = ""
|
||||
cur = comp.CreateBlockInfo(LevelId).GetBlockNew(pos, dim)
|
||||
if cur and cur.get("name") != rule["source"]:
|
||||
self._clearTimerData(dim, pos)
|
||||
@@ -169,12 +164,6 @@ class YouguoTimerService(BlueFoxServerSystem):
|
||||
# 到点转换
|
||||
self.replaceBlock(pos, dim, rule["target"], None)
|
||||
self._clearTimerData(dim, pos)
|
||||
# 计时结束提示: 发给发起玩家; 发起者不在/未知则提示附近
|
||||
tip = rule.get("doneTip", "")
|
||||
if tip:
|
||||
self._notifyIfOnline(tp, tip)
|
||||
if not tp:
|
||||
self._notifyNearby(dim, pos, tip)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -221,29 +210,6 @@ class YouguoTimerService(BlueFoxServerSystem):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _notifyNearby(self, dim, pos, tip, radius=6):
|
||||
"""完成提示兜底: 发起玩家不在/未知时, 提示该方块附近(三维距离)的在线玩家"""
|
||||
if not tip:
|
||||
return
|
||||
try:
|
||||
r2 = radius * radius
|
||||
for pid in comp.CreateGame(LevelId).GetAllPlayerIds():
|
||||
try:
|
||||
if comp.CreateDimension(pid).GetEntityDimensionId() != dim:
|
||||
continue
|
||||
fp = comp.CreatePos(pid).GetFootPos()
|
||||
if fp is None:
|
||||
continue
|
||||
dx = fp[0] - pos[0]
|
||||
dy = fp[1] - pos[1]
|
||||
dz = fp[2] - pos[2]
|
||||
if dx * dx + dy * dy + dz * dz <= r2:
|
||||
comp.CreateMsg(pid).NotifyOneMessage(pid, tip)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ============================================================================
|
||||
# 六、工具方法:替换方块
|
||||
# ============================================================================
|
||||
|
||||
Reference in new issue
Block a user