remove some duplication in global order OGs
This commit is contained in:
@@ -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>
|
||||||
@@ -39,20 +39,15 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Xml.Linq">
|
<Reference Include="System.Xml.Linq">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Data.DataSetExtensions">
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="ICSharpCode.SharpZipLib">
|
<Reference Include="ICSharpCode.SharpZipLib">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>..\ICSharpCode.SharpZipLib.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -235,7 +230,6 @@
|
|||||||
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
||||||
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
||||||
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
||||||
<Compile Include="Orders\SellOrderGenerator.cs" />
|
|
||||||
<Compile Include="Orders\SetChronoTankDestination.cs" />
|
<Compile Include="Orders\SetChronoTankDestination.cs" />
|
||||||
<Compile Include="Orders\UnitOrderTargeter.cs" />
|
<Compile Include="Orders\UnitOrderTargeter.cs" />
|
||||||
<Compile Include="OreRefinery.cs" />
|
<Compile Include="OreRefinery.cs" />
|
||||||
|
|||||||
@@ -12,11 +12,21 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Orders
|
namespace OpenRA.Mods.RA.Orders
|
||||||
{
|
{
|
||||||
class PowerDownOrderGenerator : IOrderGenerator
|
public class GlobalButtonOrderGenerator<T> : IOrderGenerator
|
||||||
{
|
{
|
||||||
|
string cursor;
|
||||||
|
string order;
|
||||||
|
|
||||||
|
public GlobalButtonOrderGenerator(string cursor, string order)
|
||||||
|
{
|
||||||
|
this.cursor = cursor;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
@@ -31,11 +41,10 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
{
|
{
|
||||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||||
.Where(a => a.Owner == world.LocalPlayer
|
.Where(a => a.Owner == world.LocalPlayer
|
||||||
&& a.HasTrait<CanPowerDown>())
|
&& a.HasTrait<T>()).FirstOrDefault();
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
if (underCursor != null)
|
if (underCursor != null)
|
||||||
yield return new Order("PowerDown", underCursor, false);
|
yield return new Order(order, underCursor, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +55,17 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
mi.Button = MouseButton.Left;
|
mi.Button = MouseButton.Left;
|
||||||
return OrderInner(world, xy, mi).Any()
|
return cursor + (OrderInner(world, xy, mi).Any() ? "" : "-blocked");
|
||||||
? "powerdown" : "powerdown-blocked";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PowerDownOrderGenerator : GlobalButtonOrderGenerator<CanPowerDown>
|
||||||
|
{
|
||||||
|
public PowerDownOrderGenerator() : base( "powerdown", "PowerDown" ) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SellOrderGenerator : GlobalButtonOrderGenerator<Sellable>
|
||||||
|
{
|
||||||
|
public SellOrderGenerator() : base( "sell", "Sell" ) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Mods.RA.Buildings;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Orders
|
|
||||||
{
|
|
||||||
public class SellOrderGenerator : IOrderGenerator
|
|
||||||
{
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
|
||||||
{
|
|
||||||
if (mi.Button == MouseButton.Right)
|
|
||||||
world.CancelInputMode();
|
|
||||||
|
|
||||||
return OrderInner(world, xy, mi);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
|
||||||
{
|
|
||||||
if (mi.Button == MouseButton.Left)
|
|
||||||
{
|
|
||||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
|
||||||
.Where(a => a.Owner == world.LocalPlayer
|
|
||||||
&& a.HasTrait<Sellable>()).FirstOrDefault();
|
|
||||||
|
|
||||||
if (underCursor != null)
|
|
||||||
yield return new Order("Sell", underCursor, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Tick( World world ) {}
|
|
||||||
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
|
|
||||||
public void RenderBeforeWorld( WorldRenderer wr, World world ) { }
|
|
||||||
|
|
||||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
|
||||||
{
|
|
||||||
mi.Button = MouseButton.Left;
|
|
||||||
return OrderInner(world, xy, mi).Any()
|
|
||||||
? "sell" : "sell-blocked";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,12 +14,12 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class SellableInfo : TraitInfo<Sellable>
|
public class SellableInfo : TraitInfo<Sellable>
|
||||||
{
|
{
|
||||||
public readonly int RefundPercent = 50;
|
public readonly int RefundPercent = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Sellable : IResolveOrder
|
public class Sellable : IResolveOrder
|
||||||
{
|
{
|
||||||
bool selling = false;
|
bool selling = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user