moved paradrop crap into mod dll
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Graphics;
|
||||
|
||||
namespace OpenRa.Effects
|
||||
{
|
||||
class Parachute : IEffect
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly Animation paraAnim;
|
||||
readonly float2 location;
|
||||
|
||||
readonly Actor cargo;
|
||||
readonly Player owner;
|
||||
|
||||
float altitude;
|
||||
const float fallRate = .3f;
|
||||
|
||||
public Parachute(Player owner, string image, float2 location, int altitude, Actor cargo)
|
||||
{
|
||||
this.location = location;
|
||||
this.altitude = altitude;
|
||||
this.cargo = cargo;
|
||||
this.owner = owner;
|
||||
|
||||
anim = new Animation(image);
|
||||
if (anim.HasSequence("idle"))
|
||||
anim.PlayFetchIndex("idle", () => 0);
|
||||
else
|
||||
anim.PlayFetchIndex("stand", () => 0);
|
||||
anim.Tick();
|
||||
|
||||
paraAnim = new Animation("parach");
|
||||
paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
paraAnim.Tick();
|
||||
|
||||
altitude -= fallRate;
|
||||
|
||||
if (altitude <= 0)
|
||||
world.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(this);
|
||||
w.Add(cargo);
|
||||
cargo.CancelActivity();
|
||||
cargo.traits.Get<Mobile>().TeleportTo(cargo, ((1 / 24f) * location).ToInt2());
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
var pos = location - new float2(0, altitude);
|
||||
yield return new Renderable(anim.Image, location - .5f * anim.Image.size, PaletteType.Shadow, 0);
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, owner.Palette, 2);
|
||||
yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size, owner.Palette, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,6 @@
|
||||
<Compile Include="Effects\GpsSatellite.cs" />
|
||||
<Compile Include="Effects\InvulnEffect.cs" />
|
||||
<Compile Include="Effects\MoveFlash.cs" />
|
||||
<Compile Include="Effects\Parachute.cs" />
|
||||
<Compile Include="Effects\RepairIndicator.cs" />
|
||||
<Compile Include="Effects\SatelliteLaunch.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
@@ -225,8 +224,6 @@
|
||||
<Compile Include="Traits\LightPaletteRotator.cs" />
|
||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||
<Compile Include="Traits\NukePower.cs" />
|
||||
<Compile Include="Traits\ParaDrop.cs" />
|
||||
<Compile Include="Traits\ParatroopersPower.cs" />
|
||||
<Compile Include="Traits\Passenger.cs" />
|
||||
<Compile Include="Traits\PlaceBuilding.cs" />
|
||||
<Compile Include="Traits\SonarPulsePower.cs" />
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Traits.Activities
|
||||
{
|
||||
class Fly : IActivity
|
||||
public class Fly : IActivity
|
||||
{
|
||||
readonly float2 Pos;
|
||||
bool isCanceled;
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Traits.Activities
|
||||
{
|
||||
class FlyAttack : IActivity
|
||||
public class FlyAttack : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
Actor Target;
|
||||
@@ -30,7 +30,7 @@ namespace OpenRa.Traits.Activities
|
||||
public void Cancel(Actor self) { Target = null; NextActivity = null; }
|
||||
}
|
||||
|
||||
class FlyCircle : IActivity
|
||||
public class FlyCircle : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
int2 Target;
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace OpenRa.Traits.Activities
|
||||
{
|
||||
class RemoveSelf : IActivity
|
||||
public class RemoveSelf : IActivity
|
||||
{
|
||||
bool isCanceled;
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
@@ -3,7 +3,7 @@ using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class CargoInfo : ITraitInfo
|
||||
public class CargoInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Passengers = 0;
|
||||
public readonly UnitMovementType[] PassengerTypes = { };
|
||||
@@ -12,7 +12,7 @@ namespace OpenRa.Traits
|
||||
public object Create(Actor self) { return new Cargo(self); }
|
||||
}
|
||||
|
||||
class Cargo : IPips, IIssueOrder, IResolveOrder
|
||||
public class Cargo : IPips, IIssueOrder, IResolveOrder
|
||||
{
|
||||
List<Actor> cargo = new List<Actor>();
|
||||
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.GameRules;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class MobileInfo : ITraitInfo
|
||||
public class MobileInfo : ITraitInfo
|
||||
{
|
||||
public readonly UnitMovementType MovementType = UnitMovementType.Wheel;
|
||||
|
||||
public object Create(Actor self) { return new Mobile(self); }
|
||||
}
|
||||
|
||||
class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits.Activities;
|
||||
using OpenRa.Effects;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class ParaDropInfo : ITraitInfo
|
||||
{
|
||||
public readonly int LZRange = 4;
|
||||
public object Create(Actor self) { return new ParaDrop(); }
|
||||
}
|
||||
|
||||
class ParaDrop : ITick
|
||||
{
|
||||
readonly List<int2> droppedAt = new List<int2>();
|
||||
int2 lz;
|
||||
|
||||
public void SetLZ( int2 lz )
|
||||
{
|
||||
this.lz = lz;
|
||||
droppedAt.Clear();
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var r = self.Info.Traits.Get<ParaDropInfo>().LZRange;
|
||||
|
||||
if ((self.Location - lz).LengthSquared <= r * r && !droppedAt.Contains(self.Location))
|
||||
{
|
||||
// todo: check is this is a good drop cell.
|
||||
|
||||
// unload a dude here
|
||||
droppedAt.Add(self.Location);
|
||||
|
||||
var cargo = self.traits.Get<Cargo>();
|
||||
if (cargo.IsEmpty(self))
|
||||
FinishedDropping(self);
|
||||
else
|
||||
{
|
||||
var a = cargo.Unload(self);
|
||||
var rs = a.traits.Get<RenderSimple>();
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(
|
||||
new Parachute(self.Owner, rs.anim.Name,
|
||||
self.CenterLocation,
|
||||
self.traits.Get<Unit>().Altitude, a)));
|
||||
|
||||
Sound.Play("chute1.aud");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FinishedDropping(Actor self)
|
||||
{
|
||||
// this kindof sucks, actually.
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Fly(Util.CenterOfCell(self.World.ChooseRandomEdgeCell())));
|
||||
self.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class ParatroopersPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public string[] DropItems = { };
|
||||
public override object Create(Actor self) { return new ParatroopersPower(self,this); }
|
||||
}
|
||||
|
||||
class ParatroopersPower : SupportPower, IResolveOrder
|
||||
{
|
||||
public ParatroopersPower(Actor self, ParatroopersPowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.controller.orderGenerator = new SelectTarget();
|
||||
Sound.Play("slcttgt1.aud");
|
||||
}
|
||||
|
||||
class SelectTarget : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
yield return new Order("ParatroopersActivate", world.LocalPlayer.PlayerActor, xy);
|
||||
}
|
||||
|
||||
public void Tick(World world) {}
|
||||
public void Render(World world) {}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
return Cursor.Ability;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "ParatroopersActivate")
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
DoParadrop(Owner, order.TargetLocation,
|
||||
self.Info.Traits.Get<ParatroopersPowerInfo>().DropItems);
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
static void DoParadrop(Player owner, int2 p, string[] items)
|
||||
{
|
||||
var startPos = owner.World.ChooseRandomEdgeCell();
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var a = w.CreateActor("BADR", startPos, owner);
|
||||
|
||||
a.CancelActivity();
|
||||
a.QueueActivity(new FlyCircle(p));
|
||||
a.traits.Get<ParaDrop>().SetLZ(p);
|
||||
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
foreach (var i in items)
|
||||
cargo.Load(a, new Actor(owner.World, i.ToLowerInvariant(),
|
||||
new int2(0,0), a.Owner));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRa.GameRules;
|
||||
using OpenRa.Graphics;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
static class Util
|
||||
public static class Util
|
||||
{
|
||||
public static void TickFacing( ref int facing, int desiredFacing, int rot )
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa
|
||||
{
|
||||
static class WorldUtils
|
||||
public static class WorldUtils
|
||||
{
|
||||
public static bool IsCellBuildable(this World world, int2 a, UnitMovementType umt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user