init: cs player_status CDK demo
This commit is contained in:
21
logic/state_manager.py
Normal file
21
logic/state_manager.py
Normal file
@@ -0,0 +1,21 @@
|
||||
class StateManager:
|
||||
|
||||
def __init__(self):
|
||||
self.previous = None
|
||||
|
||||
|
||||
def update(self, current):
|
||||
|
||||
if current is None or current.get("health") is None:
|
||||
return None, None
|
||||
|
||||
# 第一次收到有效数据,只记录,不触发事件
|
||||
if self.previous is None:
|
||||
self.previous = current
|
||||
return None, None
|
||||
|
||||
old = self.previous
|
||||
|
||||
self.previous = current
|
||||
|
||||
return old, current
|
||||
Reference in New Issue
Block a user