non-high weapons impact walls - not perfect yet, but it will do

This commit is contained in:
Chris Forbes
2010-05-13 13:00:58 +12:00
parent 25d135f6bc
commit 5d3397ba83
2 changed files with 27 additions and 4 deletions

View File

@@ -19,6 +19,7 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
@@ -83,8 +84,7 @@ namespace OpenRA.Effects
{
var at = (float)t / TotalTime();
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp(Args.src, Args.dest, at)
- 0.5f * anim.Image.size - new float2(0, altitude);
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
var highPos = (Info.High || Info.Arcing)
? (pos - new float2(0, (Args.dest - Args.src).Length * height * 4 * at * (1 - at)))
@@ -93,6 +93,20 @@ namespace OpenRA.Effects
world.AddFrameEndTask(w => w.Add(
new Smoke(w, highPos.ToInt2(), Info.Trail)));
}
if (!Info.High) // check for hitting a wall
{
var at = (float)t / TotalTime();
var pos = float2.Lerp(Args.src, Args.dest, at);
var cell = ((1f/Game.CellSize) * pos).ToInt2();
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(cell).Any(
a => a.traits.Contains<Wall>()))
{
Args.dest = pos.ToInt2();
Explode(world);
}
}
}
const float height = .1f;
@@ -104,8 +118,7 @@ namespace OpenRA.Effects
var at = (float)t / TotalTime();
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
var pos = float2.Lerp( Args.src, Args.dest, at)
- 0.5f * anim.Image.size - new float2( 0, altitude );
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
if (Info.High || Info.Arcing)
{

View File

@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
@@ -109,6 +110,15 @@ namespace OpenRA.Effects
if (Info.RangeLimit != 0 && t > Info.RangeLimit * 40)
Explode(world);
if (!Info.High) // check for hitting a wall
{
var cell = ((1f / Game.CellSize) * Pos).ToInt2();
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(cell).Any(
a => a.traits.Contains<Wall>()))
Explode(world);
}
}
void Explode(World world)