Move StoresOre into Mods.RA
This commit is contained in:
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
*
|
||||
* OpenRA is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenRA is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class StoresOreInfo : ITraitInfo
|
||||
{
|
||||
public readonly int PipCount = 0;
|
||||
public readonly PipType PipColor = PipType.Yellow;
|
||||
public readonly int Capacity = 0;
|
||||
public object Create(ActorInitializer init) { return new StoresOre(init.self, this); }
|
||||
}
|
||||
|
||||
class StoresOre : IPips, INotifyCapture, INotifyDamage, IExplodeModifier
|
||||
{
|
||||
readonly PlayerResources Player;
|
||||
readonly StoresOreInfo Info;
|
||||
|
||||
public StoresOre(Actor self, StoresOreInfo info)
|
||||
{
|
||||
Player = self.Owner.PlayerActor.traits.Get<PlayerResources>();
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public void OnCapture(Actor self, Actor captor)
|
||||
{
|
||||
var ore = Stored(self);
|
||||
Player.TakeOre(ore);
|
||||
Player.GiveOre(ore);
|
||||
}
|
||||
|
||||
int Stored(Actor self)
|
||||
{
|
||||
return (int)(Player.GetSiloFullness() * Info.Capacity);
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead && Player.GetSiloFullness() > 0)
|
||||
Player.TakeOre(Stored(self)); // Lose the stored ore
|
||||
}
|
||||
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
return Graphics.Util.MakeArray( Info.PipCount,
|
||||
i => (Player.GetSiloFullness() > i * 1.0f / Info.PipCount)
|
||||
? Info.PipColor : PipType.Transparent );
|
||||
}
|
||||
|
||||
public bool ShouldExplode(Actor self) { return Player.GetSiloFullness() > 0; }
|
||||
}
|
||||
}
|
||||
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user