Implement Teleport ability and update ability/effects TODO docs

- Add Teleport handling in DungeonSimulation ability switch and implemented-type list

- Teleport mob toward target using displacement distance with walkable-position fallback search

- Add Teleport success/failure diagnostics

- Update AbilitySystemWalkthrough status and add effect animation builder TODOs
This commit is contained in:
dingo
2026-02-11 09:15:39 -05:00
parent 5aebc9afe2
commit 7e8d195aec
2 changed files with 88 additions and 4 deletions
+78
View File
@@ -525,6 +525,10 @@ public partial class DungeonSimulation
case MobAbilityType.HealSelf:
ProcessHealSelfAbility(mob, ability.Definition);
break;
case MobAbilityType.Teleport:
ApplyTeleport(mob, ability.Definition, target);
break;
}
}
@@ -572,6 +576,7 @@ public partial class DungeonSimulation
MobAbilityType.Pull => true,
MobAbilityType.HazardZone => true,
MobAbilityType.HealSelf => true,
MobAbilityType.Teleport => true,
_ => false
};
}
@@ -1159,6 +1164,79 @@ public partial class DungeonSimulation
}
}
}
private void ApplyTeleport(MobInstance mob, MobAbilityDefinition ability, PlayerInstance target)
{
float maxTeleport = ability.DisplacementDistance > 0
? ability.DisplacementDistance
: Math.Max(ability.Range, 100f);
maxTeleport = Math.Max(32f, maxTeleport);
// Prefer blinking near the target instead of directly on top.
const float stopShort = 30f;
float toTargetX = target.X - mob.X;
float toTargetY = target.Y - mob.Y;
float toTargetDist = MathF.Sqrt(toTargetX * toTargetX + toTargetY * toTargetY);
if (toTargetDist <= 0.001f)
{
Console.WriteLine($"[Teleport] Mob {mob.Id} ({mob.Name}) skipped: target overlap.");
return;
}
float desiredTravel = Math.Min(maxTeleport, Math.Max(0f, toTargetDist - stopShort));
if (desiredTravel < 8f)
{
desiredTravel = Math.Min(maxTeleport, toTargetDist);
}
float rawX = mob.X + (toTargetX / toTargetDist) * desiredTravel;
float rawY = mob.Y + (toTargetY / toTargetDist) * desiredTravel;
if (TryFindWalkableNear(rawX, rawY, out float finalX, out float finalY))
{
mob.X = finalX;
mob.Y = finalY;
mob.UpdateFacingDirection(target.X, target.Y);
Console.WriteLine(
$"[Teleport] Mob {mob.Id} ({mob.Name}) -> ({finalX:F1},{finalY:F1}) target=({target.X:F1},{target.Y:F1}) max={maxTeleport:F1}");
return;
}
Console.WriteLine(
$"[Teleport] Mob {mob.Id} ({mob.Name}) failed: no walkable destination near ({rawX:F1},{rawY:F1})");
}
private bool TryFindWalkableNear(float x, float y, out float walkableX, out float walkableY)
{
if (CanMoveTo(x, y))
{
walkableX = x;
walkableY = y;
return true;
}
const int maxRadius = 96;
const int step = 12;
for (int radius = step; radius <= maxRadius; radius += step)
{
for (int i = 0; i < 8; i++)
{
float angle = (MathF.PI * 2f * i) / 8f;
float testX = x + MathF.Cos(angle) * radius;
float testY = y + MathF.Sin(angle) * radius;
if (CanMoveTo(testX, testY))
{
walkableX = testX;
walkableY = testY;
return true;
}
}
}
walkableX = x;
walkableY = y;
return false;
}
private void SpawnHazardZone(MobInstance mob, MobAbilityDefinition ability, float x, float y)
{