chronotank in aftermath mod dll

This commit is contained in:
Chris Forbes
2010-01-17 10:31:48 +13:00
parent 9c78406f08
commit b290d46ddc
12 changed files with 35 additions and 61 deletions

View File

@@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Net.Sockets; using System.Net.Sockets;
using IjwFramework.Types;
using OpenRa.FileFormats; using OpenRa.FileFormats;
using OpenRa.GameRules; using OpenRa.GameRules;
using OpenRa.Graphics; using OpenRa.Graphics;
using OpenRa.Orders; using OpenRa.Orders;
using OpenRa.Support; using OpenRa.Support;
using OpenRa.Traits; using OpenRa.Traits;
using IjwFramework.Types;
namespace OpenRa namespace OpenRa
{ {
@@ -20,7 +20,7 @@ namespace OpenRa
public static World world; public static World world;
internal static Viewport viewport; internal static Viewport viewport;
public static PathFinder PathFinder; public static PathFinder PathFinder;
internal static WorldRenderer worldRenderer; public static WorldRenderer worldRenderer;
public static Controller controller; public static Controller controller;
internal static Chrome chrome; internal static Chrome chrome;
public static UserSettings Settings; public static UserSettings Settings;

View File

@@ -1,26 +1,21 @@
using System.Drawing;
using System;
using System.Linq;
using System.Windows.Forms;
using IjwFramework.Types;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRa.Traits; using OpenRa.Traits;
using OpenRa.Support;
using OpenRa.Effects;
namespace OpenRa.Graphics namespace OpenRa.Graphics
{ {
class WorldRenderer public class WorldRenderer
{ {
public readonly TerrainRenderer terrainRenderer; internal readonly TerrainRenderer terrainRenderer;
public readonly SpriteRenderer spriteRenderer; internal readonly SpriteRenderer spriteRenderer;
public readonly LineRenderer lineRenderer; internal readonly LineRenderer lineRenderer;
public readonly UiOverlay uiOverlay; internal readonly UiOverlay uiOverlay;
public readonly Renderer renderer; internal readonly Renderer renderer;
public static bool ShowUnitPaths = false; public static bool ShowUnitPaths = false;
public WorldRenderer(Renderer renderer) internal WorldRenderer(Renderer renderer)
{ {
terrainRenderer = new TerrainRenderer(renderer, Rules.Map); terrainRenderer = new TerrainRenderer(renderer, Rules.Map);

View File

@@ -103,7 +103,6 @@
<Compile Include="Effects\IEffect.cs" /> <Compile Include="Effects\IEffect.cs" />
<Compile Include="Graphics\MappedImage.cs" /> <Compile Include="Graphics\MappedImage.cs" />
<Compile Include="Graphics\Minimap.cs" /> <Compile Include="Graphics\Minimap.cs" />
<Compile Include="Orders\ChronoshiftSelfDestinationOrderGenerator.cs" />
<Compile Include="Orders\ChronosphereSelectOrderGenerator.cs" /> <Compile Include="Orders\ChronosphereSelectOrderGenerator.cs" />
<Compile Include="Orders\IOrderSource.cs" /> <Compile Include="Orders\IOrderSource.cs" />
<Compile Include="Orders\IronCurtainOrderGenerator.cs" /> <Compile Include="Orders\IronCurtainOrderGenerator.cs" />
@@ -224,7 +223,6 @@
<Compile Include="Traits\Chronosphere.cs" /> <Compile Include="Traits\Chronosphere.cs" />
<Compile Include="Traits\EngineerCapture.cs" /> <Compile Include="Traits\EngineerCapture.cs" />
<Compile Include="Traits\Explodes.cs" /> <Compile Include="Traits\Explodes.cs" />
<Compile Include="Traits\ChronoshiftDeploy.cs" />
<Compile Include="Traits\Fake.cs" /> <Compile Include="Traits\Fake.cs" />
<Compile Include="Traits\GeneratesGap.cs" /> <Compile Include="Traits\GeneratesGap.cs" />
<Compile Include="Traits\GpsLaunchSite.cs" /> <Compile Include="Traits\GpsLaunchSite.cs" />

View File

@@ -1,12 +1,11 @@
using IjwFramework.Collections; using IjwFramework.Collections;
using IrrKlang; using IrrKlang;
using OpenRa.FileFormats; using OpenRa.FileFormats;
using OpenRa.GameRules;
using OpenRa.Traits; using OpenRa.Traits;
namespace OpenRa namespace OpenRa
{ {
static class Sound public static class Sound
{ {
static ISoundEngine soundEngine; static ISoundEngine soundEngine;
static Cache<string, ISoundSource> sounds; static Cache<string, ISoundSource> sounds;

View File

@@ -7,7 +7,7 @@ using OpenRa.FileFormats;
namespace OpenRa namespace OpenRa
{ {
class SyncAttribute : Attribute { } public class SyncAttribute : Attribute { }
static class Sync static class Sync
{ {

View File

@@ -1,12 +1,7 @@
using System; 
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using OpenRa.GameRules;
namespace OpenRa.Traits.Activities namespace OpenRa.Traits.Activities
{ {
class Teleport : IActivity public class Teleport : IActivity
{ {
public IActivity NextActivity { get; set; } public IActivity NextActivity { get; set; }

View File

@@ -5,7 +5,7 @@ namespace OpenRa.Traits
{ {
class ChronoshiftPaletteEffectInfo : StatelessTraitInfo<ChronoshiftPaletteEffect> { } class ChronoshiftPaletteEffectInfo : StatelessTraitInfo<ChronoshiftPaletteEffect> { }
class ChronoshiftPaletteEffect : IPaletteModifier, ITick public class ChronoshiftPaletteEffect : IPaletteModifier, ITick
{ {
const int chronoEffectLength = 20; const int chronoEffectLength = 20;
int remainingFrames; int remainingFrames;

View File

@@ -1,10 +0,0 @@
using OpenRa.Effects;
using OpenRa.Traits;
using System.Collections.Generic;
using System.Linq;
using OpenRa.Orders;
namespace OpenRa.Traits
{
}

View File

@@ -1,15 +1,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRa.Orders; using OpenRa.Mods.Aftermath.Orders;
using OpenRa.Traits;
using OpenRa.Traits.Activities;
namespace OpenRa.Traits namespace OpenRa.Mods.Aftermath
{ {
class ChronoshiftDeployInfo : ITraitInfo class ChronoshiftDeployInfo : ITraitInfo
{ {
public object Create(Actor self) { return new ChronoshiftDeploy(self); } public object Create(Actor self) { return new ChronoshiftDeploy(self); }
} }
class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ISpeedModifier, ITick, IPips class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ITick, IPips
{ {
// Recharge logic // Recharge logic
[Sync] [Sync]
@@ -17,7 +19,7 @@ namespace OpenRa.Traits
readonly int chargeLength = (int)(Rules.Aftermath.ChronoTankDuration * 60 * 25); // How long between shifts? readonly int chargeLength = (int)(Rules.Aftermath.ChronoTankDuration * 60 * 25); // How long between shifts?
public ChronoshiftDeploy(Actor self) { } public ChronoshiftDeploy(Actor self) { }
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (chargeTick > 0) if (chargeTick > 0)
@@ -36,7 +38,7 @@ namespace OpenRa.Traits
{ {
if (order.OrderString == "Deploy") if (order.OrderString == "Deploy")
{ {
Game.controller.orderGenerator = new ChronoshiftSelfDestinationOrderGenerator(self); Game.controller.orderGenerator = new SetChronoTankDestination(self);
return; return;
} }
@@ -46,10 +48,10 @@ namespace OpenRa.Traits
// Cannot chronoshift into unexplored location // Cannot chronoshift into unexplored location
if (!self.Owner.Shroud.IsExplored(order.TargetLocation)) if (!self.Owner.Shroud.IsExplored(order.TargetLocation))
return; return;
Game.controller.CancelInputMode(); Game.controller.CancelInputMode();
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new Activities.Teleport(order.TargetLocation)); self.QueueActivity(new Teleport(order.TargetLocation));
Sound.Play("chrotnk1.aud"); Sound.Play("chrotnk1.aud");
chargeTick = chargeLength; chargeTick = chargeLength;
@@ -57,13 +59,7 @@ namespace OpenRa.Traits
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift(); a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift();
} }
} }
public float GetSpeedModifier()
{
// ARGH! You must not do this, it will desync!
return (Game.controller.orderGenerator is ChronoshiftDestinationOrderGenerator) ? 0f : 1f;
}
// Display 5 pips indicating the current charge status // Display 5 pips indicating the current charge status
public IEnumerable<PipType> GetPips(Actor self) public IEnumerable<PipType> GetPips(Actor self)
{ {
@@ -75,7 +71,7 @@ namespace OpenRa.Traits
yield return PipType.Transparent; yield return PipType.Transparent;
continue; continue;
} }
switch (i) switch (i)
{ {
case 0: case 0:

View File

@@ -35,6 +35,7 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
@@ -45,6 +46,8 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ChronoshiftDeploy.cs" />
<Compile Include="Orders\SetChronoTankDestination.cs" />
<Compile Include="DemoTruck.cs" /> <Compile Include="DemoTruck.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>

View File

@@ -1,17 +1,14 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing; using System.Drawing;
using OpenRa.Traits; using OpenRa.Traits;
namespace OpenRa.Orders namespace OpenRa.Mods.Aftermath.Orders
{ {
class ChronoshiftSelfDestinationOrderGenerator : IOrderGenerator class SetChronoTankDestination : IOrderGenerator
{ {
public readonly Actor self; public readonly Actor self;
public ChronoshiftSelfDestinationOrderGenerator(Actor self) public SetChronoTankDestination(Actor self)
{ {
this.self = self; this.self = self;
} }

View File

@@ -35,6 +35,7 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>