From 1b60e3144bd7815b9119a62e5a7855be4f155efb Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Fri, 26 May 2023 18:03:31 +0800 Subject: [PATCH] perf: :zap: make viewRange and so on readonly --- docs/CAPI接口(cpp).md | 2 +- docs/CAPI接口(python).md | 2 +- docs/版本更新说明.md | 6 ++- .../GameObj/Character/Character.Skill.cs | 2 +- .../GameClass/GameObj/Character/Character.cs | 42 +++---------------- 5 files changed, 14 insertions(+), 40 deletions(-) diff --git a/docs/CAPI接口(cpp).md b/docs/CAPI接口(cpp).md index 10cd707..3b96dad 100644 --- a/docs/CAPI接口(cpp).md +++ b/docs/CAPI接口(cpp).md @@ -6,6 +6,7 @@ ### 主动指令 - 每帧最多发送50条主动指令 - EndAllAction 及 Move 指令调用数总和一帧内不超过 10 次 +- 指令执行失败可能会使你返回idle状态,而非简单的无效 #### 移动 - `std::future Move(int64_t timeInMilliseconds, double angleInRadian)`:移动,`timeInMilliseconds` 为移动时间,单位毫秒;`angleInRadian` 表示移动方向,单位弧度,使用极坐标,**竖直向下方向为 x 轴,水平向右方向为 y 轴**。因为移动过程中你会受到多种干扰使得移动结果不符合你的预期;因此建议小步移动,边移动边考虑之后的行为。 @@ -18,7 +19,6 @@ #### 人物 - `std::future EndAllAction()`:可以使不处在不可行动状态中的玩家终止当前行动 - 在指令仍在进行时,重复发出同一类型的交互指令和移动指令是无效的,你需要先发出 EndAllAction 指令终止进行的指令 - - 实际上唤醒或勉励不同的人是有效的 #### 攻击 - `std::future Attack(double angleInRadian)`:`angleInRadian` 为攻击方向 diff --git a/docs/CAPI接口(python).md b/docs/CAPI接口(python).md index c8918ea..a26195a 100644 --- a/docs/CAPI接口(python).md +++ b/docs/CAPI接口(python).md @@ -7,6 +7,7 @@ ### 主动指令 - 每帧最多发送 50 条主动指令 - EndAllAction 及 Move 指令调用数总和一帧内不超过 10 次 +- 指令执行失败可能会使你返回idle状态,而非简单的无效 #### 移动 @@ -22,7 +23,6 @@ - `def EndAllAction(self) -> Future[bool]`:可以使不处在不可行动状态中的玩家终止当前行动 - 在指令仍在进行时,重复发出同一类型的交互指令和移动指令是无效的,你需要先发出 EndAllAction 指令终止进行的指令 - - 实际上唤醒或勉励不同的人是有效的 - EndAllAction 及 Move 指令调用数总和一帧内不超过 10 次 #### 攻击 diff --git a/docs/版本更新说明.md b/docs/版本更新说明.md index ae232c6..3842b21 100644 --- a/docs/版本更新说明.md +++ b/docs/版本更新说明.md @@ -91,5 +91,9 @@ # 5月26日12:00更新 - fix:修复了救人中断后不继续沉迷的问题 +# 5月26日14:00更新 +- improve:优化CD逻辑 + # 5月26日更新 -- improve:优化CD逻辑 \ No newline at end of file +- docs:指令执行失败可能会使你返回idle状态,而非简单的无效 +- docs:删除了“实际上唤醒或勉励不同的人是有效的” \ No newline at end of file diff --git a/logic/GameClass/GameObj/Character/Character.Skill.cs b/logic/GameClass/GameObj/Character/Character.Skill.cs index 252c0ff..cc8e98c 100644 --- a/logic/GameClass/GameObj/Character/Character.Skill.cs +++ b/logic/GameClass/GameObj/Character/Character.Skill.cs @@ -40,7 +40,7 @@ namespace GameClass.GameObj this.BulletOfPlayer = this.OriBulletOfPlayer = Occupation.InitBullet; this.concealment = Occupation.Concealment; this.alertnessRadius = Occupation.AlertnessRadius; - this.ViewRange = Occupation.ViewRange; + this.viewRange = Occupation.ViewRange; this.characterType = characterType; this.SpeedOfOpeningOrLocking = Occupation.SpeedOfOpeningOrLocking; this.SpeedOfClimbingThroughWindows = Occupation.SpeedOfClimbingThroughWindows; diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index 7cf40c6..95df5c5 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -157,44 +157,14 @@ namespace GameClass.GameObj bgmDictionary[bgm] = value; } - private int alertnessRadius; - public int AlertnessRadius - { - get => alertnessRadius; - set - { - lock (gameObjLock) - { - alertnessRadius = value; - } - } - } + private readonly int alertnessRadius; + public int AlertnessRadius => alertnessRadius; - private double concealment; - public double Concealment - { - get => concealment; - set - { - lock (gameObjLock) - { - concealment = value; - } - } - } + private readonly double concealment; + public double Concealment => concealment; - private int viewRange; - public int ViewRange - { - get => viewRange; - set - { - lock (gameObjLock) - { - viewRange = (value > 0) ? value : 0; - } - } - } + private readonly int viewRange; + public int ViewRange => viewRange; #endregion #region 交互相关的基本属性及方法 private int speedOfOpeningOrLocking;