Ditto combat

This commit is contained in:
Bob
2010-01-21 13:22:39 +13:00
parent 7f5c59a967
commit 90b5df73b5

View File

@@ -13,13 +13,15 @@ namespace OpenRa
public static void DoImpact(int2 loc, int2 visualLoc, public static void DoImpact(int2 loc, int2 visualLoc,
WeaponInfo weapon, ProjectileInfo projectile, WarheadInfo warhead, Actor firedBy) WeaponInfo weapon, ProjectileInfo projectile, WarheadInfo warhead, Actor firedBy)
{ {
var world = firedBy.World;
var targetTile = ((1f / Game.CellSize) * loc.ToFloat2()).ToInt2(); var targetTile = ((1f / Game.CellSize) * loc.ToFloat2()).ToInt2();
var isWater = Game.world.IsWater(targetTile); var isWater = world.IsWater(targetTile);
var hitWater = Game.world.IsCellBuildable(targetTile, UnitMovementType.Float); var hitWater = world.IsCellBuildable(targetTile, UnitMovementType.Float);
if (warhead.Explosion != 0) if (warhead.Explosion != 0)
Game.world.AddFrameEndTask( world.AddFrameEndTask(
w => w.Add(new Explosion(visualLoc, warhead.Explosion, hitWater))); w => w.Add(new Explosion(visualLoc, warhead.Explosion, hitWater)));
var impactSound = warhead.ImpactSound; var impactSound = warhead.ImpactSound;
@@ -28,10 +30,10 @@ namespace OpenRa
if (impactSound != null) Sound.Play(impactSound + ".aud"); if (impactSound != null) Sound.Play(impactSound + ".aud");
if (!isWater) Smudge.AddSmudge(targetTile, warhead); if (!isWater) Smudge.AddSmudge(targetTile, warhead);
if (warhead.Ore) Game.world.Map.DestroyOre(targetTile.X, targetTile.Y); if (warhead.Ore) world.Map.DestroyOre(targetTile.X, targetTile.Y);
var maxSpread = GetMaximumSpread(weapon, warhead); var maxSpread = GetMaximumSpread(weapon, warhead);
var hitActors = Game.world.FindUnitsInCircle(loc, maxSpread); var hitActors = world.FindUnitsInCircle(loc, maxSpread);
foreach (var victim in hitActors) foreach (var victim in hitActors)
victim.InflictDamage(firedBy, (int)GetDamageToInflict(victim, loc, weapon, warhead), warhead); victim.InflictDamage(firedBy, (int)GetDamageToInflict(victim, loc, weapon, warhead), warhead);