修复隐身bug
This commit is contained in:
parent
f17bab8a48
commit
0f04e72f41
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* @Author: 白哉
|
||||
* @Description: 可隐匿技能
|
||||
* 同时承担"移动前后 HideState 状态变化检测 + 出发格播 Fog"职责:
|
||||
* BeforeMove → 快照 HideState 状态 + 出发格 id
|
||||
* OnAnyUnitMove → 比对状态变化,必要时在出发格播 Fog
|
||||
* (不放在 HideStateSkill 是因为"本无 HideState → 移动后获得"的场景下 HideStateSkill 此时还没挂在单位身上)
|
||||
* @Date: 2026年03月06日
|
||||
* @Modify:
|
||||
*/
|
||||
@ -20,6 +24,14 @@ namespace Logic.Skill
|
||||
[MemoryPackIgnore]
|
||||
private bool _hasMovedThisTurn;
|
||||
|
||||
// 移动前是否处于 HideState:用于在 OnAnyUnitMove 派发完毕后比对状态变化
|
||||
[MemoryPackIgnore]
|
||||
private bool _hideStateBeforeMove;
|
||||
|
||||
// 移动前的出发格 GridId:状态变化时用它定位 Fog 播放位置
|
||||
[MemoryPackIgnore]
|
||||
private uint _startGridIdBeforeMove;
|
||||
|
||||
public CanHideSkill()
|
||||
{
|
||||
IsPermanent = true;
|
||||
@ -38,6 +50,14 @@ namespace Logic.Skill
|
||||
_hasMovedThisTurn = false;
|
||||
}
|
||||
|
||||
// 在所有 OnMove 派发之前快照 HideState 与出发格
|
||||
public override void BeforeMove(UnitData self, GridData grid, MapData mapData, MoveType moveType, List<Vector2Int> path = null)
|
||||
{
|
||||
_hideStateBeforeMove = self.GetSkill(SkillType.HideState, out _);
|
||||
var fromGrid = self.Grid(mapData);
|
||||
_startGridIdBeforeMove = fromGrid?.Id ?? 0;
|
||||
}
|
||||
|
||||
public override void OnMove(UnitData self, GridData grid, MapData mapData, MoveType moveType, List<Vector2Int> path = null)
|
||||
{
|
||||
if (_hasMovedThisTurn)
|
||||
@ -55,16 +75,42 @@ namespace Logic.Skill
|
||||
}
|
||||
}
|
||||
|
||||
bool needVFX = !self.GetSkill(SkillType.HideState, out _);
|
||||
self.AddOrOverrideSkill(SkillType.HideState, mapData, self.Id);
|
||||
if (needVFX && self.InMainSight())
|
||||
// 走到敌方城市中心不能隐身(与军营同语义)
|
||||
if (grid.Resource == ResourceType.CityCenter)
|
||||
{
|
||||
//播放雾气特效
|
||||
self.Grid(mapData)?.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Fog));
|
||||
//刷新origin的显示
|
||||
self.Renderer(mapData)?.InstantUpdateUnit(true);
|
||||
if (mapData.GetCityDataByGid(grid.Id, out var city)
|
||||
&& city.Player(mapData, out var cityPlayer)
|
||||
&& self.Player(mapData, out var selfPlayer)
|
||||
&& !mapData.SameUnion(cityPlayer.Id, selfPlayer.Id))
|
||||
return;
|
||||
}
|
||||
|
||||
// 添加 HideState。视觉刷新在 HideStateSkill.OnSkillAdd 中处理,
|
||||
// Fog 特效由本类 OnAnyUnitMove 中的状态变化检测统一播放
|
||||
self.AddOrOverrideSkill(SkillType.HideState, mapData, self.Id);
|
||||
}
|
||||
|
||||
// OnAnyUnitMove 在 MoveToLogic 中位于所有 OnMove 派发之后,HideState 最终状态此时已稳定
|
||||
public override void OnAnyUnitMove(MapData map, IdentifierBase identifier, UnitData moveUnit, GridData target, MoveType moveType)
|
||||
{
|
||||
if (identifier is not UnitData self) return;
|
||||
if (moveUnit == null || moveUnit.Id != self.Id) return;
|
||||
|
||||
bool hideStateAfterMove = self.GetSkill(SkillType.HideState, out _);
|
||||
if (_hideStateBeforeMove == hideStateAfterMove)
|
||||
{
|
||||
_startGridIdBeforeMove = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 状态变化 → 在出发格播 Fog
|
||||
if (_startGridIdBeforeMove != 0
|
||||
&& map.GridMap.GetGridDataByGid(_startGridIdBeforeMove, out var startGrid)
|
||||
&& self.InMainSight())
|
||||
{
|
||||
startGrid.Renderer(map)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Fog));
|
||||
}
|
||||
_startGridIdBeforeMove = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
/*
|
||||
* @Author: 白哉
|
||||
* @Description: 隐匿状态技能
|
||||
* Fog 特效播放策略:
|
||||
* - 不再在 HideState/CanHide 添加、解除时直接播放 Fog
|
||||
* - 由本技能的 BeforeMove + OnMove 比对"移动前后是否处于 HideState",
|
||||
* 只有发生状态变化时才在"出发格"播一次 Fog
|
||||
* 进入敌方城市中心 / 敌方军营 → 立刻破除 HideState
|
||||
* @Date: 2026年03月06日
|
||||
* @Modify:
|
||||
*/
|
||||
@ -37,66 +42,65 @@ namespace Logic.Skill
|
||||
public override void OnClearActionPoint(MapData mapData, UnitData self)
|
||||
{
|
||||
// 单位 AP 被清光(移动/攻击/占领等)即解除 HideState
|
||||
bool removed = self.GetSkill(SkillType.HideState, out _);
|
||||
if (!removed) return;
|
||||
// 不再播放 Fog —— Fog 仅由 BeforeMove/OnMove 的状态变化对比触发
|
||||
if (!self.GetSkill(SkillType.HideState, out _)) return;
|
||||
self.RemoveSkill(SkillType.HideState, mapData);
|
||||
if (self.InMainSight())
|
||||
{
|
||||
self.Grid(mapData)?.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Fog));
|
||||
self.Renderer(mapData)?.InstantUpdateUnit(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnBeInteractTarget(UnitData origin, UnitData self, GridData grid, MapData mapData)
|
||||
{
|
||||
// 被交互即解除 HideState(不播 Fog)
|
||||
bool removed = self.GetSkill(SkillType.HideState, out _);
|
||||
self.RemoveSkill(SkillType.HideState, mapData);
|
||||
//处理视觉
|
||||
if (removed && self.InMainSight())
|
||||
{
|
||||
//播放雾气特效
|
||||
self.Grid(mapData)?.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Fog));
|
||||
//刷新self的显示
|
||||
self.Renderer(mapData)?.InstantUpdateUnit(true);
|
||||
}
|
||||
}
|
||||
|
||||
// 移动前快照逻辑全部由 CanHideSkill 维护:那边的 BeforeMove 记录"移动前 HideState 状态 + 出发格",
|
||||
// OnAnyUnitMove 完成后再比对、必要时在出发格播 Fog(CanHideSkill 必然存在于会改变 HideState 的单位身上,HideStateSkill 不必维护这段状态)
|
||||
|
||||
public override void OnMove(UnitData self, GridData grid, MapData mapData, MoveType moveType, List<Vector2Int> path = null)
|
||||
{
|
||||
// 移动到敌方军营格子上时自动破除Hide状态
|
||||
if (grid.Resource is ResourceType.Military or ResourceType.RemiliaMilitary or ResourceType.MoriyaMilitary)
|
||||
// 进入敌方军营或敌方城市中心 → 立刻破除 HideState
|
||||
bool isEnemyMilitary = grid.Resource is ResourceType.Military or ResourceType.RemiliaMilitary or ResourceType.MoriyaMilitary;
|
||||
bool isEnemyCityCenter = grid.Resource == ResourceType.CityCenter;
|
||||
if (isEnemyMilitary || isEnemyCityCenter)
|
||||
{
|
||||
if (grid.Player(mapData, out var gridPlayer) && self.Player(mapData, out var selfPlayer))
|
||||
bool isEnemyOwnedGrid = false;
|
||||
if (isEnemyMilitary)
|
||||
{
|
||||
if (!mapData.SameUnion(gridPlayer.Id, selfPlayer.Id))
|
||||
if (grid.Player(mapData, out var gridPlayer) && self.Player(mapData, out var selfPlayer))
|
||||
isEnemyOwnedGrid = !mapData.SameUnion(gridPlayer.Id, selfPlayer.Id);
|
||||
}
|
||||
else // isEnemyCityCenter
|
||||
{
|
||||
// 城心格:用城主而非"格子归属玩家"判定
|
||||
if (mapData.GetCityDataByGid(grid.Id, out var city)
|
||||
&& city.Player(mapData, out var cityPlayer)
|
||||
&& self.Player(mapData, out var selfPlayer))
|
||||
{
|
||||
bool removed = self.GetSkill(SkillType.HideState, out _);
|
||||
self.RemoveSkill(SkillType.HideState, mapData);
|
||||
// 处理视觉
|
||||
if (removed && self.InMainSight())
|
||||
{
|
||||
// 播放雾气特效
|
||||
self.Grid(mapData)?.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Fog));
|
||||
// 刷新self的显示
|
||||
self.Renderer(mapData)?.InstantUpdateUnit(true);
|
||||
}
|
||||
isEnemyOwnedGrid = !mapData.SameUnion(cityPlayer.Id, selfPlayer.Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnemyOwnedGrid && self.GetSkill(SkillType.HideState, out _))
|
||||
{
|
||||
self.RemoveSkill(SkillType.HideState, mapData);
|
||||
if (self.InMainSight())
|
||||
self.Renderer(mapData)?.InstantUpdateUnit(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSkillAdd(MapData mapData, uint originId)
|
||||
{
|
||||
base.OnSkillAdd(mapData, originId);
|
||||
// 触发渲染更新,使HideState立即生效
|
||||
// 添加 HideState 时刷新单位渲染(让其立刻进入"半透明/隐身"视觉),但不播 Fog
|
||||
// Fog 现在仅由"移动前后 HideState 变化"统一在出发格播放
|
||||
if (mapData.GetIdentifierBase(originId) is UnitData unitData)
|
||||
{
|
||||
if (unitData.InMainSight())
|
||||
{
|
||||
unitData.Grid(mapData)?.Renderer(mapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.Fog));
|
||||
}
|
||||
unitData.Renderer(mapData)?.InstantUpdateUnit(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsHideState()
|
||||
@ -121,4 +125,3 @@ namespace Logic.Skill
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -4012,9 +4012,9 @@ V1.5版本放出 | | | | | | | | | False | False | | False | False | Fa
|
||||
| 2144 | True | 移动时,对周围1格范围造成溅射伤害。 | 移動時,對周圍1格範圍造成濺射傷害。 | Deals Splash damage to surrounding tiles within 1 range when moving. | 移動時、周囲1マスにスプラッシュダメージを与える | 이동 시, 주변 1칸 범위에 범위 공격 피해를 입힌다. | | | | | False | False | | False | False | False | | | SkillInfoShowPack : SkillDesc |
|
||||
| 2145 | True | 移动提升 | 移動提升 | Movement Boost | 移動力アップ | 이동력 증가 | | | | | False | False | | False | False | False | | | SkillInfo : SkillName |
|
||||
| 2146 | True | 提升1点移动力 | 提升1點移動力 | Increases Movement by 1. | 移動力を1上昇させる | 이동력 1 증가 | | | | | False | False | | False | False | False | | | SkillInfo : SkillDesc |
|
||||
| 2147 | True | 偷袭 | 偷襲 | Ambush | 奇襲 | 기습 | | | | | False | True | | False | False | True | | | |
|
||||
| 2148 | True | 被动技能。攻击时,不会受到对方反击。 | 被動技能。攻擊時,不會受到對方反擊。 | Passive Skill. When attacking, does not receive counterattack from the opponent. | パッシブスキル。攻撃時、相手の反撃を受けない | 패시브 스킬. 공격 시, 상대의 반격을 받지 않는다. | | | | | False | False | | False | False | False | | | SkillInfoShowPack : SkillDesc |
|
||||
| 2149 | True | 掌中破坏者 | 掌中破壞者 | Palm Destroyer | 掌中の破壊者 | 장중의 파괴자 | | | | | False | False | | False | False | False | | | SkillInfoShowPack : SkillName |
|
||||
| 2147 | True | 偷袭 | 偷襲 | Ambush | 奇襲 | 기습 | | | | | False | False | | False | False | True | | | SkillInfo : SkillName |
|
||||
| 2148 | True | 被动技能。攻击时,不会受到对方反击。 | 被動技能。攻擊時,不會受到對方反擊。 | Passive Skill. When attacking, does not receive counterattack from the opponent. | パッシブスキル。攻撃時、相手の反撃を受けない | 패시브 스킬. 공격 시, 상대의 반격을 받지 않는다. | | | | | False | False | | False | False | False | | | SkillInfo : SkillDesc |
|
||||
| 2149 | False | 掌中破坏者 | 掌中破壞者 | Palm Destroyer | 掌中の破壊者 | 장중의 파괴자 | | | | | False | False | | False | False | False | | | |
|
||||
| 2150 | True | 城市传送 | 城市傳送 | City Teleport | 都市転送 | 도시 텔레포트 | | | | | False | False | | False | False | False | | | SkillInfo : SkillName |
|
||||
| 2151 | True | 主动技能。可在与首通联通的城市之间传送。 | 主動技能。可在與首通聯通的城市之間傳送。 | Active Skill. Can teleport between cities connected to the capital. | アクティブスキル。首都と接続されている都市間をテレポートできる | 액티브 스킬. 수도와 연결된 도시 간을 텔레포트할 수 있다. | | | | | False | False | | False | False | False | | | SkillInfo : SkillDesc |
|
||||
| 2152 | True | 主动技能。蕾米化作蝙蝠群,可在与首通联通的城市之间传送。 | 主動技能。蕾米化作蝙蝠群,可在與首通聯通的城市之間傳送。 | Active Skill. Remilia transforms into a swarm of bats and can teleport between cities connected to the capital. | アクティブスキル。レミリアが蝙蝠の群れに変身し、首都と繋がっている都市間をテレポートできる | 액티브 스킬. 레미리아가 박쥐 떼로 변신하여 수도와 연결된 도시 간을 텔레포트할 수 있다. | | | | | False | False | | False | False | False | | | SkillInfoShowPack : SkillDesc |
|
||||
@ -36806,7 +36806,8 @@ Release Date: 04/26/26
|
||||
| 19571 | True | 间谍艇 | | | | | | | | | False | False | | False | False | False | | | UnitTypeInfo : Name |
|
||||
| 19572 | True | 叛乱者小艇 | | | | | | | | | False | False | | False | False | False | | | UnitTypeInfo : Name |
|
||||
| 19576 | True | 只能攻击敌方城市中心。根据城市等级产生不同数量的**<叛乱者>**,并窃取该城市本回合的金币产出。自身消失。 | | | | | | | | | False | False | | False | False | False | | | SkillInfo : SkillDesc |
|
||||
| 19577 | True | English | | | | | | | | | False | False | | False | False | True | | | |
|
||||
| 19578 | True | Chinese | | | | | | | | | False | False | | False | False | True | | | |
|
||||
| 19579 | True | Heads-up! The current version of the game is in **<Chinese >**only.**< English >**and more languages are on the way. Thank you for your patience and support! | | | | | | | | | False | False | | False | False | False | | | UIOutsideMenu : UIOutsideMenu/LanguageHint/text |
|
||||
| 19580 | True | 可以移动至任意**<己方英雄>**1格范围内,并使**<1格范围内>**的**<己方英雄>**获得**<女仆长护佑>**。同回合内多次使用会累计层数。每次**<银之跳跃>**都会叠加与当前层数相同的**<疲劳>** | | | | | | | | | False | False | | False | False | False | | | SkillInfo : SkillDesc |
|
||||
| 19580 | True | 可以移动至任意**<己方英雄>**1格范围内,并使**<1格范围内>**的**<己方英雄>**获得**<女仆长护佑>**。同回合内多次使用会累计层数。每次**<银之跳跃>**都会叠加与当前层数相同的**<疲劳>** | | | | | | | | | False | False | | False | False | False | | | SkillInfo : SkillDesc |
|
||||
| 19584 | True | 成功窃取{param}金币! | | | | | | | | | False | False | | False | False | False | | | TextDataAssets : NotifyUIInfiltrateStealCoin |
|
||||
| 19585 | True | English | | | | | | | | | False | False | | False | False | True | | | |
|
||||
| 19586 | True | Chinese | | | | | | | | | False | False | | False | False | True | | | |
|
||||
| 19587 | True | Heads-up! The current version of the game is in **<Chinese >**only.**< English >**and more languages are on the way. Thank you for your patience and support! | | | | | | | | | False | False | | False | False | False | | | UIOutsideMenu : UIOutsideMenu/LanguageHint/text |
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user