add CarpetBomb trait for 1-pass airstrikes etc
This commit is contained in:
58
OpenRA.Mods.Cnc/CarpetBomb.cs
Normal file
58
OpenRA.Mods.Cnc/CarpetBomb.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.GameRules;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Cnc
|
||||||
|
{
|
||||||
|
class CarpetBombInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly string Weapon = null;
|
||||||
|
public readonly int Interval = 0;
|
||||||
|
public readonly int Range = 0;
|
||||||
|
|
||||||
|
public object Create(Actor self) { return new CarpetBomb(self); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class CarpetBomb : ITick
|
||||||
|
{
|
||||||
|
int2 Target;
|
||||||
|
int dropDelay;
|
||||||
|
|
||||||
|
public CarpetBomb(Actor self) { }
|
||||||
|
|
||||||
|
public void SetTarget(int2 targetCell) { Target = targetCell; }
|
||||||
|
|
||||||
|
public void Tick(Actor self)
|
||||||
|
{
|
||||||
|
var info = self.Info.Traits.Get<CarpetBombInfo>();
|
||||||
|
|
||||||
|
if ((self.Location - Target).LengthSquared > info.Range * info.Range)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||||
|
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (--dropDelay <= 0)
|
||||||
|
{
|
||||||
|
dropDelay = info.Interval;
|
||||||
|
|
||||||
|
var args = new ProjectileArgs
|
||||||
|
{
|
||||||
|
srcAltitude = self.traits.Get<Unit>().Altitude,
|
||||||
|
destAltitude = 0,
|
||||||
|
src = self.CenterLocation.ToInt2(),
|
||||||
|
dest = self.CenterLocation.ToInt2(),
|
||||||
|
facing = self.traits.Get<Unit>().Facing,
|
||||||
|
firedBy = self,
|
||||||
|
weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()]
|
||||||
|
};
|
||||||
|
|
||||||
|
self.World.Add(args.weapon.Projectile.Create(args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AirstrikePower.cs" />
|
<Compile Include="AirstrikePower.cs" />
|
||||||
|
<Compile Include="CarpetBomb.cs" />
|
||||||
<Compile Include="CriticalBuildingState.cs" />
|
<Compile Include="CriticalBuildingState.cs" />
|
||||||
<Compile Include="Effects\IonCannon.cs" />
|
<Compile Include="Effects\IonCannon.cs" />
|
||||||
<Compile Include="IonCannonPower.cs" />
|
<Compile Include="IonCannonPower.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user