Beginnings of building power tracking

This commit is contained in:
Matthew Bowra-Dean
2009-11-09 21:57:42 +13:00
parent 14e2e3c2eb
commit a96a7523c8
8 changed files with 77 additions and 69 deletions

View File

@@ -100,13 +100,14 @@ namespace OpenRa.Game.Graphics
lineRenderer.Flush();
renderer.DrawText(string.Format("RenderFrame {0} ({2:F1} ms)\nTick {1} ({3:F1} ms)\nOre ({4:F1} ms)\n$ {5}\nTiles Expanded {6:F0}",
renderer.DrawText(string.Format("RenderFrame {0} ({2:F1} ms)\nTick {1} ({3:F1} ms)\nOre ({4:F1} ms)\n$ {5}\nPower {7}\nTiles Expanded {6:F0}",
Game.RenderFrame, Game.orderManager.FrameNumber,
Game.RenderTime * 1000,
Game.TickTime * 1000,
Game.OreTime * 1000,
Game.LocalPlayer.Cash,
PerfHistory.items[ "nodes_expanded" ].LastValue
PerfHistory.items[ "nodes_expanded" ].LastValue,
Game.LocalPlayer.Power
), new int2(5, 5), Color.White);
PerfHistory.Render(renderer, lineRenderer);

View File

@@ -11,6 +11,7 @@ namespace OpenRa.Game
public Race Race;
public readonly int Index;
public int Cash;
public int Power;
public Player( int index, int palette, string playerName, Race race )
{
@@ -19,6 +20,7 @@ namespace OpenRa.Game
this.PlayerName = playerName;
this.Race = race;
this.Cash = 10000;
this.Power = 0;
}
public float GetSiloFullness()

View File

@@ -2,10 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
class Building : ITick
class Building : ITick, INotifyBuildComplete
{
public Building(Actor self)
{
@@ -19,5 +20,13 @@ namespace OpenRa.Game.Traits
first = false;
}
public void BuildingComplete(Actor self)
{
UnitInfo.BuildingInfo bi = self.unitInfo as UnitInfo.BuildingInfo;
if (bi == null) return;
self.Owner.Power += bi.Power;
}
}
}

View File

@@ -18,7 +18,12 @@ namespace OpenRa.Game.Traits
public RenderBuilding(Actor self)
: base(self)
{
Make( () => anim.PlayRepeating("idle") );
Make(() =>
{
anim.PlayRepeating("idle");
foreach (var x in self.traits.WithInterface<INotifyBuildComplete>())
x.BuildingComplete(self);
});
DoBib(self, false);
}

View File

@@ -14,4 +14,5 @@ namespace OpenRa.Game.Traits
interface IOrder { Order Order(Actor self, int2 xy, bool lmb, Actor underCursor); }
interface INotifyDamage { void Damaged(Actor self, DamageState ds); }
interface INotifyDamageEx : INotifyDamage { void Damaged(Actor self, int damage); }
interface INotifyBuildComplete { void BuildingComplete (Actor self); }
}

View File

@@ -101,48 +101,40 @@ Global
{54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Mixed Platforms.ActiveCfg = Release|x86
{54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Mixed Platforms.Build.0 = Release|x86
{54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Win32.ActiveCfg = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.Build.0 = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Win32.ActiveCfg = Debug|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Any CPU.Build.0 = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Win32.ActiveCfg = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release|Any CPU.Build.0 = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Release|Win32.ActiveCfg = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Win32.Build.0 = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Win32.ActiveCfg = Debug|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Any CPU.Build.0 = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Win32.ActiveCfg = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Any CPU.Build.0 = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Win32.ActiveCfg = Release|Any CPU
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Any CPU.ActiveCfg = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.Build.0 = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.ActiveCfg = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.Build.0 = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.ActiveCfg = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.Build.0 = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Debug|Win32.ActiveCfg = Debug|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Any CPU.ActiveCfg = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Mixed Platforms.ActiveCfg = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Mixed Platforms.Build.0 = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Win32.ActiveCfg = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release|Any CPU.ActiveCfg = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.ActiveCfg = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.Build.0 = Release|x86
{31411761-224C-4C54-A5FE-280890A70259}.Release|Win32.ActiveCfg = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Any CPU.ActiveCfg = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Mixed Platforms.Build.0 = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Win32.ActiveCfg = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug (x86)|Win32.Build.0 = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.ActiveCfg = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.Build.0 = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Win32.ActiveCfg = Debug|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Any CPU.ActiveCfg = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Mixed Platforms.ActiveCfg = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Mixed Platforms.Build.0 = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release (x86)|Win32.ActiveCfg = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Any CPU.ActiveCfg = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.ActiveCfg = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Mixed Platforms.Build.0 = Release|x86
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Release|Win32.ActiveCfg = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -13,22 +13,21 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

View File

@@ -13,23 +13,22 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Ijw.DirectX, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">