Aftermath support, and spinners (on MGG, MRJ, TTNK) work (again?).

This commit is contained in:
Bob
2009-11-25 22:55:40 +13:00
parent 7c1c0835e1
commit ea096361bb
14 changed files with 732 additions and 55 deletions

View File

@@ -46,9 +46,9 @@ namespace OpenRa.Game
public static bool skipMakeAnims = true;
public static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer)
public static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, bool useAftermath)
{
Rules.LoadRules(mapName);
Rules.LoadRules(mapName, useAftermath);
for (int i = 0; i < 8; i++)
players.Add(i,

View File

@@ -21,14 +21,24 @@ namespace OpenRa.Game
public static Map Map;
public static TileSet TileSet;
public static void LoadRules(string mapFileName)
public static void LoadRules(string mapFileName, bool useAftermath)
{
AllRules = new IniFile(
FileSystem.Open("session.ini"),
FileSystem.Open(mapFileName),
FileSystem.Open("rules.ini"),
FileSystem.Open("units.ini"),
FileSystem.Open("campaignUnits.ini"));
if( useAftermath )
AllRules = new IniFile(
FileSystem.Open( "session.ini" ),
FileSystem.Open( mapFileName ),
FileSystem.Open( "aftrmath.ini" ),
FileSystem.Open( "rules.ini" ),
FileSystem.Open( "aftermathUnits.ini" ),
FileSystem.Open( "units.ini" ),
FileSystem.Open( "campaignUnits.ini" ) );
else
AllRules = new IniFile(
FileSystem.Open("session.ini"),
FileSystem.Open(mapFileName),
FileSystem.Open("rules.ini"),
FileSystem.Open("units.ini"),
FileSystem.Open("campaignUnits.ini"));
General = new GeneralInfo();
FieldLoader.Load(General, AllRules.GetSection("General"));

View File

@@ -59,12 +59,14 @@ namespace OpenRa.Game.GameRules
{
public readonly int Passengers = 0;
public readonly int Speed = 0;
public readonly bool NoMovingFire = false;
public MobileInfo(string name) : base(name) { }
}
public class InfantryInfo : MobileInfo
{
public readonly bool Crushable = true; // also on VehicleInfo, but with a different default
public readonly bool C4 = false;
public readonly bool FraidyCat = false;
public readonly bool Infiltrate = false;
@@ -78,7 +80,6 @@ namespace OpenRa.Game.GameRules
{
public readonly bool Crushable = false;
public readonly bool Tracked = false;
public readonly bool NoMovingFire = false;
public VehicleInfo(string name) : base(name) { }
}

View File

@@ -5,6 +5,7 @@ using OpenRa.Game.Graphics;
using System.Runtime.InteropServices;
using OpenRa.Game.Traits;
using System.IO;
using System;
namespace OpenRa.Game
{
@@ -26,29 +27,12 @@ namespace OpenRa.Game
public MainWindow(Settings settings)
{
FileSystem.Mount( new Folder( "../../../../" ) );
if( File.Exists( "../../../../main.mix" ) )
FileSystem.Mount(new Package("main.mix"));
FileSystem.Mount(new Package("redalert.mix"));
FileSystem.Mount(new Package("conquer.mix"));
FileSystem.Mount(new Package("hires.mix"));
FileSystem.Mount(new Package("general.mix"));
FileSystem.Mount(new Package("local.mix"));
FileSystem.Mount(new Package("sounds.mix"));
FileSystem.Mount(new Package("speech.mix"));
FileSystem.Mount(new Package("allies.mix"));
FileSystem.Mount(new Package("russian.mix"));
FormBorderStyle = FormBorderStyle.None;
BackColor = Color.Black;
StartPosition = FormStartPosition.Manual;
Location = Point.Empty;
Visible = true;
bool windowed = !settings.GetValue("fullscreen", false);
renderer = new Renderer(this, GetResolution(settings), windowed);
SheetBuilder.Initialize(renderer);
UiOverlay.ShowUnitDebug = settings.GetValue("udebug", false);
UiOverlay.ShowBuildDebug = settings.GetValue("bdebug", false);
WorldRenderer.ShowUnitPaths = settings.GetValue("pathdebug", false);
@@ -57,10 +41,26 @@ namespace OpenRa.Game
Game.NetworkHost = settings.GetValue( "host", "" );
Game.NetworkPort = int.Parse( settings.GetValue( "port", "0" ) );
var useAftermath = bool.Parse( settings.GetValue( "aftermath", "false" ) );
Renderer.SheetSize = int.Parse( settings.GetValue( "sheetsize", "512" ) );
while( !File.Exists( "redalert.mix" ) )
{
var current = Directory.GetCurrentDirectory();
if( Directory.GetDirectoryRoot( current ) == current )
throw new InvalidOperationException( "Unable to load MIX files." );
Directory.SetCurrentDirectory( ".." );
}
FileSystem.MountDefault( useAftermath );
bool windowed = !settings.GetValue( "fullscreen", false );
renderer = new Renderer( this, GetResolution( settings ), windowed );
SheetBuilder.Initialize( renderer );
Game.Initialize(settings.GetValue("map", "scm12ea.ini"), renderer, new int2(ClientSize),
settings.GetValue("player", 1));
settings.GetValue("player", 1), useAftermath);
SequenceProvider.ForcePrecache();

View File

@@ -155,6 +155,7 @@
<Compile Include="Traits\RenderUnit.cs" />
<Compile Include="Traits\RenderUnitMuzzleFlash.cs" />
<Compile Include="Traits\RenderUnitRotor.cs" />
<Compile Include="Traits\RenderUnitSpinner.cs" />
<Compile Include="Traits\RenderUnitTurreted.cs" />
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Tree.cs" />

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Graphics;
namespace OpenRa.Game.Traits
{
class RenderUnitSpinner : RenderUnit
{
public Animation spinnerAnim;
public RenderUnitSpinner( Actor self )
: base(self)
{
spinnerAnim = new Animation( self.unitInfo.Name );
spinnerAnim.PlayRepeating( "spinner" );
}
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
{
var unit = self.traits.Get<Unit>();
yield return Util.Centered(self, anim.Image, self.CenterLocation);
yield return Util.Centered( self, spinnerAnim.Image, self.CenterLocation
+ Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, 0));
}
public override void Tick(Actor self)
{
base.Tick(self);
spinnerAnim.Tick();
}
}
}

View File

@@ -15,23 +15,20 @@ namespace OpenRa.Game.Traits
public RenderUnitTurreted(Actor self)
: base(self)
{
self.traits.Get<Turreted>();
turretAnim = new Animation(self.unitInfo.Name);
if (self.traits.Contains<Turreted>())
{
if (self.unitInfo.MuzzleFlash)
{
var attack = self.traits.WithInterface<AttackBase>().First();
muzzleFlash = new Animation(self.unitInfo.Name);
muzzleFlash.PlayFetchIndex("muzzle",
() => (Util.QuantizeFacing(self.traits.Get<Turreted>().turretFacing,8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
/* hack: recoil can be 1.0f, but don't overflow into next anim */
}
turretAnim.PlayFetchIndex("turret",
() => self.traits.Get<Turreted>().turretFacing / 8);
if (self.unitInfo.MuzzleFlash)
{
var attack = self.traits.WithInterface<AttackBase>().First();
muzzleFlash = new Animation(self.unitInfo.Name);
muzzleFlash.PlayFetchIndex("muzzle",
() => (Util.QuantizeFacing(self.traits.Get<Turreted>().turretFacing,8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
/* hack: recoil can be 1.0f, but don't overflow into next anim */
}
else
turretAnim.PlayRepeating("turret"); /* not really a turret; it's a spinner */
turretAnim.PlayFetchIndex("turret",
() => self.traits.Get<Turreted>().turretFacing / 8);
}
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)