private void CheckImpact(NpcInfo npc) { DashFireSpatial.ISpatialSystem spatialSys = npc.SpatialSystem; if (null != spatialSys) { bool existNpcInAttackRange = false; ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D(); spatialSys.VisitObjectInCircle(srcPos, npc.GetActualProperty().AttackRange, (float distSqr, ISpaceObject obj) => { if (obj.GetObjType() == SpatialObjType.kNPC && (int)obj.GetID() != npc.GetId()) { NpcInfo npcObj = obj.RealObject as NpcInfo; if (null != npcObj && npcObj.NpcType != (int)NpcTypeEnum.PvpTower) { existNpcInAttackRange = true; return(false); } } return(true); }); if (existNpcInAttackRange) { ImpactInfo impactInfo = npc.GetSkillStateInfo().GetImpactInfoById(c_ImpactForTower); if (null == impactInfo) { ServerNpcImpact(npc, c_ImpactForTower, npc); } } } }
public static CharacterInfo GetInterestestTargetHelper(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type) { CharacterInfo interestestTarget = null; DashFireSpatial.ISpatialSystem spatialSys = srcObj.SpatialSystem; if (null != spatialSys) { ScriptRuntime.Vector3 srcPos = srcObj.GetMovementStateInfo().GetPosition3D(); float minPowDist = 999999; spatialSys.VisitObjectInCircle(srcPos, srcObj.ViewRange, (float distSqr, ISpaceObject obj) => { GetInterestestTarget(srcObj, relation, type, distSqr, obj, ref minPowDist, ref interestestTarget); }); } return(interestestTarget); }