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">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -187,7 +187,6 @@
<Compile Include="Traits\Production.cs" />
<Compile Include="Traits\RallyPoint.cs" />
<Compile Include="Traits\Render\RenderSimple.cs" />
<Compile Include="Traits\StoresOre.cs" />
<Compile Include="Traits\Cloak.cs" />
<Compile Include="Traits\TraitsInterfaces.cs" />
<Compile Include="Traits\Turreted.cs" />
@@ -263,4 +262,7 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Folder Include="Traits\" />
</ItemGroup>
</Project>

View File

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

View File

@@ -56,6 +56,7 @@ namespace OpenRA.Traits
public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); }
public interface IProvideHazard { IEnumerable<HazardLayer.Hazard> HazardCells(Actor self); }
public interface IAvoidHazard { string Type { get; } }
public interface IStoreOre { int Capacity { get; }}
public interface ITerrainTypeModifier { string GetTerrainType(int2 cell); }
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">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -201,6 +201,7 @@
<Compile Include="OreRefineryDockAction.cs" />
<Compile Include="Activities\Drag.cs" />
<Compile Include="ProducesHelicopters.cs" />
<Compile Include="StoresOre.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -19,8 +19,9 @@
#endregion
using System.Collections.Generic;
namespace OpenRA.Traits
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class StoresOreInfo : ITraitInfo
{
@@ -30,7 +31,7 @@ namespace OpenRA.Traits
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 StoresOreInfo Info;
@@ -41,6 +42,8 @@ namespace OpenRA.Traits
Info = info;
}
public int Capacity { get { return Info.Capacity; } }
public void OnCapture(Actor self, Actor captor)
{
var ore = Stored(self);