git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1358 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
<Compile Include="IOrderGenerator.cs" />
|
<Compile Include="IOrderGenerator.cs" />
|
||||||
<Compile Include="Network\Packet.cs" />
|
<Compile Include="Network\Packet.cs" />
|
||||||
<Compile Include="Player.cs" />
|
<Compile Include="Player.cs" />
|
||||||
|
<Compile Include="Rules.cs" />
|
||||||
<Compile Include="Sheet.cs" />
|
<Compile Include="Sheet.cs" />
|
||||||
<Compile Include="Harvester.cs" />
|
<Compile Include="Harvester.cs" />
|
||||||
<Compile Include="Log.cs" />
|
<Compile Include="Log.cs" />
|
||||||
|
|||||||
79
OpenRa.Game/Rules.cs
Normal file
79
OpenRa.Game/Rules.cs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using OpenRa.FileFormats;
|
||||||
|
|
||||||
|
namespace OpenRa.Game
|
||||||
|
{
|
||||||
|
static class Rules
|
||||||
|
{
|
||||||
|
static readonly Dictionary<string, UnitInfo> unitInfos = new Dictionary<string, UnitInfo>();
|
||||||
|
|
||||||
|
static Rules()
|
||||||
|
{
|
||||||
|
IniFile rulesIni = new IniFile( FileSystem.Open( "rules.ini" ) );
|
||||||
|
using( Stream s = FileSystem.Open( "units.txt" ) )
|
||||||
|
{
|
||||||
|
StreamReader reader = new StreamReader( s );
|
||||||
|
|
||||||
|
while( true )
|
||||||
|
{
|
||||||
|
string unit = reader.ReadLine();
|
||||||
|
if( unit == null )
|
||||||
|
break;
|
||||||
|
unit = unit.Substring( 0, unit.IndexOf( ',' ) );
|
||||||
|
IniSection section = rulesIni.GetSection( unit.ToUpperInvariant() );
|
||||||
|
if( section == null )
|
||||||
|
{
|
||||||
|
Log.Write( "rules.ini doesnt contain entry for unit \"{0}\"", unit );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
unitInfos.Add( unit, new UnitInfo( section ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UnitInfo UnitInfo( string name )
|
||||||
|
{
|
||||||
|
return unitInfos[ name.ToUpperInvariant() ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnitInfo
|
||||||
|
{
|
||||||
|
public readonly int Speed;
|
||||||
|
|
||||||
|
public UnitInfo( IniSection ini )
|
||||||
|
{
|
||||||
|
Speed = int.Parse( ini.GetValue( "Speed", "0" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unit Missions:
|
||||||
|
//{
|
||||||
|
// Sleep - no-op
|
||||||
|
// Harmless - no-op, and also not considered a threat
|
||||||
|
// Sticky
|
||||||
|
// Attack
|
||||||
|
// Move
|
||||||
|
// QMove
|
||||||
|
// Retreat
|
||||||
|
// Guard
|
||||||
|
// Enter
|
||||||
|
// Capture
|
||||||
|
// Harvest
|
||||||
|
// Area Guard
|
||||||
|
// [Return]
|
||||||
|
// Stop
|
||||||
|
// [Ambush]
|
||||||
|
// Hunt
|
||||||
|
// Unload
|
||||||
|
// Sabotage
|
||||||
|
// Construction
|
||||||
|
// Selling
|
||||||
|
// Repair
|
||||||
|
// Rescue
|
||||||
|
// Missile
|
||||||
|
//}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ namespace OpenRa.Game
|
|||||||
protected TickFunc nextOrder = null;
|
protected TickFunc nextOrder = null;
|
||||||
|
|
||||||
protected readonly float2 renderOffset;
|
protected readonly float2 renderOffset;
|
||||||
|
protected readonly UnitInfo unitInfo;
|
||||||
|
|
||||||
public Unit( string name, int2 cell, Player owner, float2 renderOffset, Game game )
|
public Unit( string name, int2 cell, Player owner, float2 renderOffset, Game game )
|
||||||
: base( game )
|
: base( game )
|
||||||
@@ -24,6 +25,7 @@ namespace OpenRa.Game
|
|||||||
fromCell = toCell = cell;
|
fromCell = toCell = cell;
|
||||||
this.renderOffset = renderOffset;
|
this.renderOffset = renderOffset;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
this.unitInfo = Rules.UnitInfo( name );
|
||||||
|
|
||||||
animation = new Animation( name );
|
animation = new Animation( name );
|
||||||
animation.PlayFetchIndex( "idle", delegate { return facing; } );
|
animation.PlayFetchIndex( "idle", delegate { return facing; } );
|
||||||
@@ -53,8 +55,6 @@ namespace OpenRa.Game
|
|||||||
return highest;
|
return highest;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int Speed = 6;
|
|
||||||
|
|
||||||
public override void Tick( Game game, int t )
|
public override void Tick( Game game, int t )
|
||||||
{
|
{
|
||||||
animation.Tick( t );
|
animation.Tick( t );
|
||||||
@@ -78,7 +78,7 @@ namespace OpenRa.Game
|
|||||||
if( Turn( GetFacing( toCell - fromCell ) ) )
|
if( Turn( GetFacing( toCell - fromCell ) ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
moveFraction += t * Speed;
|
moveFraction += t * unitInfo.Speed;
|
||||||
if( moveFraction < moveFractionTotal )
|
if( moveFraction < moveFractionTotal )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ OpenRA
|
|||||||
|
|
||||||
[ ] Rules.ini
|
[ ] Rules.ini
|
||||||
[ ] Unit turn rate as specified in rules.ini
|
[ ] Unit turn rate as specified in rules.ini
|
||||||
|
[ ] Load unit/building infos
|
||||||
|
|
||||||
[ ] Ore
|
[ ] Ore
|
||||||
[ ] Better harvester logic - seek out more ore when harvesting, until full
|
[ ] Better harvester logic - seek out more ore when harvesting, until full
|
||||||
|
[ ] Render it :D
|
||||||
|
|
||||||
[ ] Weapons
|
[ ] Weapons
|
||||||
|
|
||||||
@@ -52,9 +54,9 @@ OpenRA
|
|||||||
Use FileSystem.Create() to automatically place output files on sensible mounts.
|
Use FileSystem.Create() to automatically place output files on sensible mounts.
|
||||||
|
|
||||||
[ ] Ditch special unit classes, use templates extracted from rules.ini instead.
|
[ ] Ditch special unit classes, use templates extracted from rules.ini instead.
|
||||||
Push the special-case logic into code that can be named.
|
[ ] Push the special-case logic into code that can be named.
|
||||||
|
|
||||||
[ ] Remove all remaining `../../../` bullshit from the code. We should be able to set our datapaths
|
[x] Remove all remaining `../../../` bullshit from the code. We should be able to set our datapaths
|
||||||
externally, then `just go`. The FileSystem class is there to facilitate this.
|
externally, then `just go`. The FileSystem class is there to facilitate this.
|
||||||
|
|
||||||
[ ] Get rid of all the damned static classes! Makes it REALLY HARD to reuse code,
|
[ ] Get rid of all the damned static classes! Makes it REALLY HARD to reuse code,
|
||||||
|
|||||||
Reference in New Issue
Block a user