using GAS.Runtime; using Sog; using UnityEngine; using xFrame; namespace CoreGame.Render { public static class ForceMoveSrv { //位移失败 或 被障碍物阻挡移动到障碍物旁边 时返回 False,没有被阻挡并位移成功返回 True public static bool ForceMoveEntity(CombatEntity ent, Fixed64Vector2 offset, bool changeFaceDir) { if (ent.TagCountContainer.HasTag(GTagLib.State_Death) || !ent.TagCountContainer.HasTag(GTagLib.State_ForceMove) || !ent.hasNavAgentProxy) return false; var navAgentProxy = ent.navAgentProxy; var res = navAgentProxy.ForceMove(offset); var logicPos = navAgentProxy.GetLogicPos(); var transformProxy = ent.transformProxy; if (changeFaceDir) transformProxy.SetDirection((logicPos - transformProxy.position).normalized); transformProxy.SetPosition(logicPos); return res; } } }