胡萝卜牛肉汤ceshi3 存数据 退出
This commit is contained in:
1 parent
6a35cee4be
commit
d662cca0c5
1 file changed
+5
-34
@@ -62,7 +62,7 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
def __init__(self, namespace, systemName):
|
def __init__(self, namespace, systemName):
|
||||||
super(CookingService, self).__init__(namespace, systemName)
|
super(CookingService, self).__init__(namespace, systemName)
|
||||||
print "===== CookingService init ====="
|
print "===== CookingService init ====="
|
||||||
self.stirData = {} # 翻炒数据字典
|
self.stirData = {}
|
||||||
self.ListenEvent()
|
self.ListenEvent()
|
||||||
|
|
||||||
def Destroy(self):
|
def Destroy(self):
|
||||||
@@ -102,11 +102,9 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# 从内存或方块数据加载翻炒进度
|
# 从内存或方块数据加载翻炒进度
|
||||||
stirInfo = self.stirData.get(key)
|
stirInfo = self.stirData.get(key, {})
|
||||||
if stirInfo is None:
|
if stirInfo:
|
||||||
stirInfo = self.loadStirData(playerId, pos, dim, recipe)
|
self.stirData[key] = stirInfo
|
||||||
if stirInfo:
|
|
||||||
self.stirData[key] = stirInfo
|
|
||||||
|
|
||||||
if recipe.get("needFinished") is True and not stirInfo.get("finished"):
|
if recipe.get("needFinished") is True and not stirInfo.get("finished"):
|
||||||
return
|
return
|
||||||
@@ -272,40 +270,13 @@ class CookingService(BlueFoxServerSystem):
|
|||||||
# ==================== 翻炒数据持久化 ====================
|
# ==================== 翻炒数据持久化 ====================
|
||||||
|
|
||||||
def loadStirData(self, playerId, pos, dim, recipe):
|
def loadStirData(self, playerId, pos, dim, recipe):
|
||||||
"""从方块上读取之前保存的翻炒进度"""
|
|
||||||
try:
|
|
||||||
blockComp = comp.CreateBlockInfo(playerId)
|
|
||||||
blockData = blockComp.GetBlockEntityData(pos, dim)
|
|
||||||
if blockData and "rtdd_sc" in blockData:
|
|
||||||
return {
|
|
||||||
"count": blockData.get("rtdd_sc", 0),
|
|
||||||
"lastTime": blockData.get("rtdd_slt", 0.0),
|
|
||||||
"finished": blockData.get("rtdd_sf", False),
|
|
||||||
"dropIfDone": recipe.get("dropIfDone", []),
|
|
||||||
"dropIfNot": recipe.get("dropIfNot", []),
|
|
||||||
}
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def saveStirData(self, playerId, pos, dim, data):
|
def saveStirData(self, playerId, pos, dim, data):
|
||||||
"""把翻炒进度保存到方块上,退游戏再进也不会丢"""
|
pass
|
||||||
try:
|
|
||||||
comp.CreateBlockInfo(playerId).SetBlockEntityData(pos, dim, {
|
|
||||||
"rtdd_sc": data["count"],
|
|
||||||
"rtdd_slt": data["lastTime"],
|
|
||||||
"rtdd_sf": data["finished"],
|
|
||||||
})
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def clearStirData(self, key, playerId, pos, dim):
|
def clearStirData(self, key, playerId, pos, dim):
|
||||||
"""清除内存和方块上的翻炒数据"""
|
|
||||||
self.stirData.pop(key, None)
|
self.stirData.pop(key, None)
|
||||||
try:
|
|
||||||
comp.CreateBlockInfo(playerId).SetBlockEntityData(pos, dim, {})
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# ==================== 拆方块处理 ====================
|
# ==================== 拆方块处理 ====================
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user