New extendable mechanism for disabling units

This commit is contained in:
Paul Chote
2010-01-25 20:18:12 +13:00
parent 3aa40c36cf
commit f0ae162fb0
11 changed files with 254 additions and 211 deletions

View File

@@ -53,6 +53,7 @@
<Compile Include="C4Demolition.cs" />
<Compile Include="EngineerCapture.cs" />
<Compile Include="InfiltrateForSonarPulse.cs" />
<Compile Include="RequiresPower.cs" />
<Compile Include="Mine.cs" />
<Compile Include="MineImmune.cs" />
<Compile Include="Minelayer.cs" />
@@ -72,6 +73,9 @@
<Name>OpenRa.Game</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Orders\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRa.Traits;
namespace OpenRa.Mods.RA
{
class RequiresPowerInfo : ITraitInfo
{
public object Create(Actor self) { return new RequiresPower(self); }
}
class RequiresPower : IDisable
{
readonly Actor self;
public RequiresPower( Actor self )
{
this.self = self;
}
public bool Disabled
{
get { return (self.Owner.GetPowerState() != PowerState.Normal); }
set {} // Cannot explicity set
}
}
}