Merge branch 'minelayer'

This commit is contained in:
Chris Forbes
2009-12-28 18:06:17 +13:00
10 changed files with 138 additions and 19 deletions

View File

@@ -181,6 +181,9 @@
<Compile Include="Traits\Fake.cs" />
<Compile Include="Traits\Harvester.cs" />
<Compile Include="Traits\Helicopter.cs" />
<Compile Include="Traits\InvisibleToOthers.cs" />
<Compile Include="Traits\MineImmune.cs" />
<Compile Include="Traits\Minelayer.cs" />
<Compile Include="Traits\SquishByTank.cs" />
<Compile Include="Traits\Plane.cs" />
<Compile Include="Traits\ProductionQueue.cs" />
@@ -256,11 +259,11 @@
<None Include="Graphics\Graphics.cd" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -5,16 +5,20 @@ using OpenRa.Game.GameRules;
using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits
{
class APMine : ICrushable
class APMine : ICrushable, IOccupySpace
{
readonly Actor self;
public APMine(Actor self)
{
this.self = self;
Game.UnitInfluence.Add(self, this);
}
public void OnCrush(Actor crusher)
{
if (crusher.traits.Contains<MineImmune>() && crusher.Owner == self.Owner)
return;
Game.world.AddFrameEndTask(_ =>
{
Game.world.Remove(self);
@@ -33,9 +37,15 @@ namespace OpenRa.Game.Traits
// Mines should explode indiscriminantly of player
switch (umt)
{
case UnitMovementType.Foot: return true;
case UnitMovementType.Foot:
case UnitMovementType.Wheel:
case UnitMovementType.Track:
return true;
default: return false;
}
}
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
}
}

View File

@@ -6,16 +6,20 @@ using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits
{
class ATMine : ICrushable
class ATMine : ICrushable, IOccupySpace
{
readonly Actor self;
public ATMine(Actor self)
{
this.self = self;
Game.UnitInfluence.Add(self, this);
}
public void OnCrush(Actor crusher)
{
if (crusher.traits.Contains<MineImmune>() && crusher.Owner == self.Owner)
return;
Game.world.AddFrameEndTask(_ =>
{
Game.world.Remove(self);
@@ -39,5 +43,7 @@ namespace OpenRa.Game.Traits
default: return false;
}
}
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game.Traits
{
class InvisibleToOthers : IRenderModifier
{
public InvisibleToOthers(Actor self) { }
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{
return Game.LocalPlayer == self.Owner
? r : new Renderable[] { };
}
}
}

View File

@@ -0,0 +1,8 @@

namespace OpenRa.Game.Traits
{
class MineImmune
{
public MineImmune(Actor self) { }
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game.Traits
{
class Minelayer : IOrder
{
public Minelayer(Actor self) { }
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
// todo: check for ammo
if (mi.Button == MouseButton.Right && underCursor == self)
return new Order("Deploy", self, null, int2.Zero, null);
return null;
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Deploy")
{
// todo: check for and adjust ammo
// todo: delay a bit?
Game.world.AddFrameEndTask(
w => w.Add(new Actor(Rules.UnitInfo[self.Info.Primary], self.Location, self.Owner)));
}
}
}
}

View File

@@ -83,7 +83,7 @@ namespace OpenRa.Game.Traits
case "Plane":
return UnitMovementType.Fly;
default:
throw new InvalidOperationException("GetMovementType on unit that shouldn't be aable to move.");
throw new InvalidOperationException("GetMovementType on unit that shouldn't be able to move.");
}
}

View File

@@ -369,14 +369,33 @@ Tracked=yes
Passengers=5
; mine layer
[MNLY]
[MNLY.AP]
Prerequisite=weap,fix
Strength=100
Armor=heavy
Image=MNLY
Icon=MNLYICON
TechLevel=3
Sight=5
Speed=9
Owner=allies,soviet
Owner=soviet
Cost=800
Points=50
ROT=5
Tracked=yes
Ammo=5 ; number of mines carried
Crewed=yes
[MNLY.AT]
Prerequisite=weap,fix
Strength=100
Armor=heavy
Image=MNLY
Icon=MNLYICON
TechLevel=3
Sight=5
Speed=9
Owner=allies
Cost=800
Points=50
ROT=5

View File

@@ -981,4 +981,10 @@
<sequence name="idle" start="0" length="1" />
<sequence name="damaged-idle" start="2" length="1" />
</unit>
<unit name="minp">
<sequence name="idle" start="0" length="1" />
</unit>
<unit name="minv">
<sequence name="idle" start="0" length="1" />
</unit>
</sequences>

View File

@@ -11,7 +11,8 @@ HARV
MCV
JEEP
APC
MNLY
MNLY.AP
MNLY.AT
[V2RL]
Description=V2 Rocket
@@ -88,12 +89,19 @@ Traits=Unit, Mobile, McvDeploy, RenderUnit
SelectionPriority=3
Voice=VehicleVoice
LongDesc=Deploys into another Construction Yard.\n Unarmed
[MNLY]
Description=Minelayer
Traits=Unit, Mobile, RenderUnit
[MNLY.AP]
Description=Minelayer (Anti-Personnel)
Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune
Voice=VehicleVoice
LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed
Primary=MINP ;; temporary hack
[MNLY.AT]
Description=Minelayer (Anti-Tank)
Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune
Voice=VehicleVoice
LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed
Primary=MINV ;; temporary hack
@@ -314,7 +322,10 @@ WEAF
SYRF
SPEF
DOMF
; TODO? : campaign-specific stuff - FCOM, civilian buildings, etc
; pseudo-buildings
MINP
MINV
; `Dimensions` is the size of a box that will include the whole building, excluding bib.
@@ -505,8 +516,13 @@ LongDesc=Looks like a Radar Dome
;SelectionPriority=3
[MINV]
Traits=Unit,RenderUnit,ATMine,BelowUnits,InvisibleToOthers
Selectable=no
[MINP]
Traits=Unit,RenderUnit,APMine,BelowUnits,InvisibleToOthers
Selectable=no
[InfantryTypes]
DOG