Browse Source

Merge pull request #620 from eesast/dev

perf: 🔒 add a lock for the bgm
tags/v0.1.0
shangfengh GitHub 2 years ago
parent
commit
28eec82ddd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions
  1. +7
    -10
      logic/GameClass/GameObj/Character/Character.cs

+ 7
- 10
logic/GameClass/GameObj/Character/Character.cs View File

@@ -141,23 +141,20 @@ namespace GameClass.GameObj
}*/
#endregion
#region 感知相关的基本属性及方法
private Dictionary<BgmType, double> bgmDictionary = new();
private readonly object bgmLock = new();
private Dictionary<BgmType, double> bgmDictionary = new() { { BgmType.GhostIsComing, 0 }, { BgmType.StudentIsApproaching, 0 }, { BgmType.GeneratorIsBeingFixed, 0 } };
public Dictionary<BgmType, double> BgmDictionary
{
get => bgmDictionary;
private set
get
{
lock (gameObjLock)
{
bgmDictionary = value;
}
lock (bgmLock)
return bgmDictionary;
}
}
public void AddBgm(BgmType bgm, double value)
{
if (BgmDictionary.ContainsKey(bgm))
BgmDictionary[bgm] = value;
else BgmDictionary.Add(bgm, value);
lock (bgmLock)
bgmDictionary[bgm] = value;
}

private int alertnessRadius;


Loading…
Cancel
Save