Move StoresOre into Mods.RA

This commit is contained in:
Paul Chote
2010-07-08 19:32:07 +12:00
parent d9ba7ff90c
commit 476d40b317
5 changed files with 15 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -187,7 +187,6 @@
<Compile Include="Traits\Production.cs" /> <Compile Include="Traits\Production.cs" />
<Compile Include="Traits\RallyPoint.cs" /> <Compile Include="Traits\RallyPoint.cs" />
<Compile Include="Traits\Render\RenderSimple.cs" /> <Compile Include="Traits\Render\RenderSimple.cs" />
<Compile Include="Traits\StoresOre.cs" />
<Compile Include="Traits\Cloak.cs" /> <Compile Include="Traits\Cloak.cs" />
<Compile Include="Traits\TraitsInterfaces.cs" /> <Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Turreted.cs" /> <Compile Include="Traits\Turreted.cs" />
@@ -263,4 +262,7 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
<ItemGroup>
<Folder Include="Traits\" />
</ItemGroup>
</Project> </Project>

View File

@@ -48,8 +48,8 @@ namespace OpenRA.Traits
int nextSiloAdviceTime = 0; int nextSiloAdviceTime = 0;
void TickOre(Actor self) void TickOre(Actor self)
{ {
OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait<StoresOre>() OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait<IStoreOre>()
.Sum(a => a.Actor.Info.Traits.Get<StoresOreInfo>().Capacity); .Sum(a => a.Actor.traits.WithInterface<IStoreOre>().Sum(b => b.Capacity));
if (Ore > OreCapacity) if (Ore > OreCapacity)
Ore = OreCapacity; Ore = OreCapacity;

View File

@@ -56,6 +56,7 @@ namespace OpenRA.Traits
public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); } public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); }
public interface IProvideHazard { IEnumerable<HazardLayer.Hazard> HazardCells(Actor self); } public interface IProvideHazard { IEnumerable<HazardLayer.Hazard> HazardCells(Actor self); }
public interface IAvoidHazard { string Type { get; } } public interface IAvoidHazard { string Type { get; } }
public interface IStoreOre { int Capacity { get; }}
public interface ITerrainTypeModifier { string GetTerrainType(int2 cell); } public interface ITerrainTypeModifier { string GetTerrainType(int2 cell); }
public interface ITerrainCost { float GetTerrainCost(int2 cell, Actor forActor); } public interface ITerrainCost { float GetTerrainCost(int2 cell, Actor forActor); }

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -201,6 +201,7 @@
<Compile Include="OreRefineryDockAction.cs" /> <Compile Include="OreRefineryDockAction.cs" />
<Compile Include="Activities\Drag.cs" /> <Compile Include="Activities\Drag.cs" />
<Compile Include="ProducesHelicopters.cs" /> <Compile Include="ProducesHelicopters.cs" />
<Compile Include="StoresOre.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -19,8 +19,9 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Traits
namespace OpenRA.Mods.RA
{ {
class StoresOreInfo : ITraitInfo class StoresOreInfo : ITraitInfo
{ {
@@ -30,7 +31,7 @@ namespace OpenRA.Traits
public object Create(ActorInitializer init) { return new StoresOre(init.self, this); } public object Create(ActorInitializer init) { return new StoresOre(init.self, this); }
} }
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier, IStoreOre
{ {
readonly PlayerResources Player; readonly PlayerResources Player;
readonly StoresOreInfo Info; readonly StoresOreInfo Info;
@@ -41,6 +42,8 @@ namespace OpenRA.Traits
Info = info; Info = info;
} }
public int Capacity { get { return Info.Capacity; } }
public void OnCapture(Actor self, Actor captor) public void OnCapture(Actor self, Actor captor)
{ {
var ore = Stored(self); var ore = Stored(self);