unitinfo.InitialFacing etc
This commit is contained in:
@@ -53,6 +53,7 @@ namespace OpenRa.Game.GameRules
|
|||||||
public readonly string SecondaryAnim = null;
|
public readonly string SecondaryAnim = null;
|
||||||
public readonly bool MuzzleFlash = false;
|
public readonly bool MuzzleFlash = false;
|
||||||
public readonly int SelectionPriority = 10;
|
public readonly int SelectionPriority = 10;
|
||||||
|
public readonly int InitialFacing = 128;
|
||||||
|
|
||||||
public UnitInfo(string name) { Name = name; }
|
public UnitInfo(string name) { Name = name; }
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
|
|
||||||
Size tileSize = new Size( Game.CellSize, Game.CellSize );
|
Size tileSize = new Size( Game.CellSize, Game.CellSize );
|
||||||
|
|
||||||
SheetBuilder.ForceNewSheet();
|
// SheetBuilder.ForceNewSheet();
|
||||||
|
|
||||||
var tileMapping = new Cache<TileReference, Sprite>(
|
var tileMapping = new Cache<TileReference, Sprite>(
|
||||||
x => SheetBuilder.Add(Rules.TileSet.GetBytes(x), tileSize));
|
x => SheetBuilder.Add(Rules.TileSet.GetBytes(x), tileSize));
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
<Compile Include="OrderManager.cs" />
|
<Compile Include="OrderManager.cs" />
|
||||||
<Compile Include="Ore.cs" />
|
<Compile Include="Ore.cs" />
|
||||||
<Compile Include="PathSearch.cs" />
|
<Compile Include="PathSearch.cs" />
|
||||||
|
<Compile Include="ProductionItem.cs" />
|
||||||
<Compile Include="Support\Stopwatch.cs" />
|
<Compile Include="Support\Stopwatch.cs" />
|
||||||
<Compile Include="Support\PerfHistory.cs" />
|
<Compile Include="Support\PerfHistory.cs" />
|
||||||
<Compile Include="Traits\AcceptsOre.cs" />
|
<Compile Include="Traits\AcceptsOre.cs" />
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
@@ -47,8 +46,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public void GiveCash( int num )
|
public void GiveCash( int num )
|
||||||
{
|
{
|
||||||
// TODO: increase cash
|
Cash += num;
|
||||||
Cash += num; // TODO: slowly
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeCash( int num )
|
public bool TakeCash( int num )
|
||||||
@@ -97,45 +95,4 @@ namespace OpenRa.Game
|
|||||||
production[ group ] = item;
|
production[ group ] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProductionItem
|
|
||||||
{
|
|
||||||
public readonly string Item;
|
|
||||||
|
|
||||||
public readonly int TotalTime;
|
|
||||||
public readonly int TotalCost;
|
|
||||||
public int RemainingTime { get; private set; }
|
|
||||||
public int RemainingCost { get; private set; }
|
|
||||||
|
|
||||||
public bool Paused = false, Done = false;
|
|
||||||
public Action OnComplete;
|
|
||||||
|
|
||||||
public ProductionItem( string item, int time, int cost, Action onComplete )
|
|
||||||
{
|
|
||||||
Item = item;
|
|
||||||
RemainingTime = TotalTime = time;
|
|
||||||
RemainingCost = TotalCost = cost;
|
|
||||||
OnComplete = onComplete;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Tick( Player player )
|
|
||||||
{
|
|
||||||
if (Done)
|
|
||||||
{
|
|
||||||
if (OnComplete != null) OnComplete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( Paused ) return;
|
|
||||||
|
|
||||||
var costThisFrame = RemainingCost / RemainingTime;
|
|
||||||
if( costThisFrame != 0 && !player.TakeCash( costThisFrame ) ) return;
|
|
||||||
|
|
||||||
RemainingCost -= costThisFrame;
|
|
||||||
RemainingTime -= 1;
|
|
||||||
if( RemainingTime > 0 ) return;
|
|
||||||
|
|
||||||
Done = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
48
OpenRa.Game/ProductionItem.cs
Normal file
48
OpenRa.Game/ProductionItem.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRa.Game
|
||||||
|
{
|
||||||
|
class ProductionItem
|
||||||
|
{
|
||||||
|
public readonly string Item;
|
||||||
|
|
||||||
|
public readonly int TotalTime;
|
||||||
|
public readonly int TotalCost;
|
||||||
|
public int RemainingTime { get; private set; }
|
||||||
|
public int RemainingCost { get; private set; }
|
||||||
|
|
||||||
|
public bool Paused = false, Done = false;
|
||||||
|
public Action OnComplete;
|
||||||
|
|
||||||
|
public ProductionItem(string item, int time, int cost, Action onComplete)
|
||||||
|
{
|
||||||
|
Item = item;
|
||||||
|
RemainingTime = TotalTime = time;
|
||||||
|
RemainingCost = TotalCost = cost;
|
||||||
|
OnComplete = onComplete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick(Player player)
|
||||||
|
{
|
||||||
|
if (Done)
|
||||||
|
{
|
||||||
|
if (OnComplete != null) OnComplete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Paused) return;
|
||||||
|
|
||||||
|
var costThisFrame = RemainingCost / RemainingTime;
|
||||||
|
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
|
||||||
|
|
||||||
|
RemainingCost -= costThisFrame;
|
||||||
|
RemainingTime -= 1;
|
||||||
|
if (RemainingTime > 0) return;
|
||||||
|
|
||||||
|
Done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,9 +17,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public virtual int CreationFacing( Actor self, Actor newUnit )
|
public virtual int CreationFacing( Actor self, Actor newUnit )
|
||||||
{
|
{
|
||||||
if( newUnit.traits.Contains<Helicopter>() )
|
return newUnit.unitInfo.InitialFacing;
|
||||||
return 20;
|
|
||||||
return 128;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Produce( Actor self, UnitInfo producee )
|
public bool Produce( Actor self, UnitInfo producee )
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public Turreted(Actor self)
|
public Turreted(Actor self)
|
||||||
{
|
{
|
||||||
|
turretFacing = self.unitInfo.InitialFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Actor self )
|
public void Tick( Actor self )
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace OpenRa.Game
|
|||||||
Log.Write( "Player \"{0}\" builds {1}", order.Player.PlayerName, building.Name );
|
Log.Write( "Player \"{0}\" builds {1}", order.Player.PlayerName, building.Name );
|
||||||
|
|
||||||
Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) );
|
Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) );
|
||||||
|
if (order.Player == Game.LocalPlayer)
|
||||||
|
Game.PlaySound("build5.aud", false);
|
||||||
|
|
||||||
order.Player.FinishProduction(Rules.UnitCategory[building.Name]);
|
order.Player.FinishProduction(Rules.UnitCategory[building.Name]);
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -123,10 +123,12 @@ HIND
|
|||||||
Description=Mig Attack Plane
|
Description=Mig Attack Plane
|
||||||
BuiltAt=afld
|
BuiltAt=afld
|
||||||
Traits=Unit, Mobile, RenderUnit
|
Traits=Unit, Mobile, RenderUnit
|
||||||
|
InitialFacing=192
|
||||||
[YAK]
|
[YAK]
|
||||||
Description=Yak Attack Plane
|
Description=Yak Attack Plane
|
||||||
BuiltAt=afld
|
BuiltAt=afld
|
||||||
Traits=Unit, Mobile, RenderUnit
|
Traits=Unit, Mobile, RenderUnit
|
||||||
|
InitialFacing=192
|
||||||
[TRAN]
|
[TRAN]
|
||||||
Description=Transport Helicopter
|
Description=Transport Helicopter
|
||||||
PrimaryOffset=0,14,0,-4
|
PrimaryOffset=0,14,0,-4
|
||||||
@@ -134,15 +136,18 @@ SecondaryOffset=0,-14,0,-2
|
|||||||
BuiltAt=hpad
|
BuiltAt=hpad
|
||||||
Traits=Unit, Helicopter, RenderUnitRotor
|
Traits=Unit, Helicopter, RenderUnitRotor
|
||||||
SecondaryAnim=rotor2
|
SecondaryAnim=rotor2
|
||||||
|
InitialFacing=20
|
||||||
[HELI]
|
[HELI]
|
||||||
Description=Longbow
|
Description=Longbow
|
||||||
BuiltAt=hpad
|
BuiltAt=hpad
|
||||||
Traits=Unit, Helicopter, RenderUnitRotor
|
Traits=Unit, Helicopter, RenderUnitRotor
|
||||||
PrimaryOffset=0,0,0,-2
|
PrimaryOffset=0,0,0,-2
|
||||||
|
InitialFacing=20
|
||||||
[HIND]
|
[HIND]
|
||||||
Description=Hind
|
Description=Hind
|
||||||
BuiltAt=hpad
|
BuiltAt=hpad
|
||||||
Traits=Unit, Helicopter, RenderUnitRotor
|
Traits=Unit, Helicopter, RenderUnitRotor
|
||||||
|
InitialFacing=20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -262,12 +267,14 @@ Traits=Building, Turreted, RenderBuildingTurreted
|
|||||||
Dimensions=1,1
|
Dimensions=1,1
|
||||||
Footprint=x
|
Footprint=x
|
||||||
SelectionPriority=3
|
SelectionPriority=3
|
||||||
|
InitialFacing=50
|
||||||
[AGUN]
|
[AGUN]
|
||||||
Description=AA Gun
|
Description=AA Gun
|
||||||
Traits=Building, Turreted, RenderBuildingTurreted
|
Traits=Building, Turreted, RenderBuildingTurreted
|
||||||
Dimensions=1,2
|
Dimensions=1,2
|
||||||
Footprint=_ x
|
Footprint=_ x
|
||||||
SelectionPriority=3
|
SelectionPriority=3
|
||||||
|
InitialFacing=224
|
||||||
[FTUR]
|
[FTUR]
|
||||||
Description=Flame Turret
|
Description=Flame Turret
|
||||||
Traits=Building, RenderBuilding
|
Traits=Building, RenderBuilding
|
||||||
|
|||||||
Reference in New Issue
Block a user