Browse Source

fix: 🐛 fix the bug about Removing

tags/0.1.0
shangfengh 2 years ago
parent
commit
38de6c480b
2 changed files with 6 additions and 4 deletions
  1. +5
    -4
      logic/GameClass/GameObj/Map/Map.cs
  2. +1
    -0
      logic/Gaming/CharacterManager .cs

+ 5
- 4
logic/GameClass/GameObj/Map/Map.cs View File

@@ -203,7 +203,7 @@ namespace GameClass.GameObj
} }
public bool Remove(GameObj gameObj) public bool Remove(GameObj gameObj)
{ {
bool flag = false;
GameObj? ToDel = null;
GameObjLockDict[gameObj.Type].EnterWriteLock(); GameObjLockDict[gameObj.Type].EnterWriteLock();
try try
{ {
@@ -211,8 +211,7 @@ namespace GameClass.GameObj
{ {
if (gameObj.ID == obj.ID) if (gameObj.ID == obj.ID)
{ {
GameObjDict[gameObj.Type].Remove(obj);
flag = true;
ToDel = obj;
break; break;
} }
} }
@@ -221,7 +220,9 @@ namespace GameClass.GameObj
{ {
GameObjLockDict[gameObj.Type].ExitWriteLock(); GameObjLockDict[gameObj.Type].ExitWriteLock();
} }
return flag;
if (ToDel == null) return false;
GameObjDict[gameObj.Type].Remove(ToDel);
return true;
} }
public bool RemoveJustFromMap(GameObj gameObj) public bool RemoveJustFromMap(GameObj gameObj)
{ {


+ 1
- 0
logic/Gaming/CharacterManager .cs View File

@@ -379,6 +379,7 @@ namespace Gaming
#if DEBUG #if DEBUG
Debugger.Output(player, "die."); Debugger.Output(player, "die.");
#endif #endif
if (player.PlayerState == PlayerStateType.Deceased) return;
player.RemoveFromGame(PlayerStateType.Deceased); player.RemoveFromGame(PlayerStateType.Deceased);


for (int i = 0; i < GameData.maxNumOfPropInPropInventory; i++) for (int i = 0; i < GameData.maxNumOfPropInPropInventory; i++)


Loading…
Cancel
Save