move CanPowerDown, PowerDownButton, and 3 IOGs
This commit is contained in:
@@ -121,12 +121,9 @@
|
||||
<Compile Include="Graphics\Minimap.cs" />
|
||||
<Compile Include="Graphics\SpriteFont.cs" />
|
||||
<Compile Include="Network\Connection.cs" />
|
||||
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
||||
<Compile Include="Effects\Missile.cs" />
|
||||
<Compile Include="Network\OrderIO.cs" />
|
||||
<Compile Include="Network\OrderManager.cs" />
|
||||
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
||||
<Compile Include="Orders\SellOrderGenerator.cs" />
|
||||
<Compile Include="PathSearch.cs" />
|
||||
<Compile Include="Selection.cs" />
|
||||
<Compile Include="Server\Connection.cs" />
|
||||
@@ -138,7 +135,6 @@
|
||||
<Compile Include="Sound.cs" />
|
||||
<Compile Include="Support\PerfHistory.cs" />
|
||||
<Compile Include="Sync.cs" />
|
||||
<Compile Include="Traits\Chrome\PowerDownButton.cs" />
|
||||
<Compile Include="Traits\CustomSellValue.cs" />
|
||||
<Compile Include="Traits\World\SpatialBins.cs" />
|
||||
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
|
||||
|
||||
@@ -1,61 +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;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Orders
|
||||
{
|
||||
class PowerDownOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.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.traits.Contains<CanPowerDown>())
|
||||
.FirstOrDefault();
|
||||
|
||||
if (underCursor != null)
|
||||
yield return new Order("PowerDown", underCursor);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick( World world ) { }
|
||||
public void Render( World world ) { }
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? "powerdown" : "powerdown-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +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;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Orders
|
||||
{
|
||||
class RepairOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.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.traits.Contains<Building>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;
|
||||
|
||||
if (building != null && building.Repairable && underCursor.Health < building.HP)
|
||||
yield return new Order("Repair", underCursor);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
var hasFact = world.Queries.OwnedBy[world.LocalPlayer]
|
||||
.WithTrait<ConstructionYard>()
|
||||
.Any();
|
||||
|
||||
if (!hasFact)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render( World world ) {}
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? "repair" : "repair-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +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;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Orders
|
||||
{
|
||||
class SellOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.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.traits.Contains<Building>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;
|
||||
|
||||
if (building != null && !building.Unsellable)
|
||||
yield return new Order("Sell", underCursor);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick( World world ) {}
|
||||
public void Render( World world ) {}
|
||||
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? "sell" : "sell-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class CanPowerDownInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new CanPowerDown(); }
|
||||
}
|
||||
|
||||
public class CanPowerDown : IDisable, IPowerModifier, IResolveOrder
|
||||
{
|
||||
[Sync]
|
||||
bool disabled = false;
|
||||
|
||||
public bool Disabled { get { return disabled; } }
|
||||
|
||||
public float GetPowerModifier() { return (disabled) ? 0.0f : 1.0f; }
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "PowerDown")
|
||||
{
|
||||
disabled = !disabled;
|
||||
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
|
||||
Sound.PlayToPlayer(self.Owner, disabled ? eva.EnablePower : eva.DisablePower);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Orders;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class PowerDownButtonInfo : TraitInfo<PowerDownButton> { }
|
||||
|
||||
class PowerDownButton : IChromeButton
|
||||
{
|
||||
public string Image { get { return "power"; } }
|
||||
public bool Enabled { get { return true; } }
|
||||
public bool Pressed { get { return Game.controller.orderGenerator is PowerDownOrderGenerator; } }
|
||||
public void OnClick() { Game.controller.ToggleInputMode<PowerDownOrderGenerator>(); }
|
||||
|
||||
public string Description { get { return "Powerdown"; } }
|
||||
public string LongDesc { get { return "Disable unneeded structures so their \npower can be used elsewhere"; } }
|
||||
}
|
||||
|
||||
class SellButtonInfo : TraitInfo<SellButton> { }
|
||||
|
||||
class SellButton : IChromeButton
|
||||
{
|
||||
public string Image { get { return "sell"; } }
|
||||
public bool Enabled { get { return true; } }
|
||||
public bool Pressed { get { return Game.controller.orderGenerator is SellOrderGenerator; } }
|
||||
public void OnClick() { Game.controller.ToggleInputMode<SellOrderGenerator>(); }
|
||||
|
||||
public string Description { get { return "Sell"; } }
|
||||
public string LongDesc { get { return "Sell buildings, reclaiming a \nproportion of their build cost"; } }
|
||||
}
|
||||
|
||||
class RepairButtonInfo : ITraitInfo
|
||||
{
|
||||
public readonly bool RequiresConstructionYard = true;
|
||||
public object Create(Actor self) { return new RepairButton(this); }
|
||||
}
|
||||
|
||||
class RepairButton : IChromeButton
|
||||
{
|
||||
RepairButtonInfo info;
|
||||
public RepairButton( RepairButtonInfo info ) { this.info = info; }
|
||||
|
||||
public string Image { get { return "repair"; } }
|
||||
public bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return !info.RequiresConstructionYard ||
|
||||
Game.world.Queries.OwnedBy[Game.world.LocalPlayer]
|
||||
.WithTrait<ConstructionYard>().Any();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Pressed { get { return Game.controller.orderGenerator is RepairOrderGenerator; } }
|
||||
public void OnClick() { Game.controller.ToggleInputMode<RepairOrderGenerator>(); }
|
||||
|
||||
public string Description { get { return "Repair"; } }
|
||||
public string LongDesc
|
||||
{
|
||||
get
|
||||
{
|
||||
var s = "Repair damaged buildings";
|
||||
return Enabled ? s : s + "\n\nRequires: Construction Yard";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Traits
|
||||
public object Create(Actor self) { return new ConstructionYard(self); }
|
||||
}
|
||||
|
||||
class ConstructionYard : IIssueOrder, IResolveOrder, IMovement
|
||||
public class ConstructionYard : IIssueOrder, IResolveOrder, IMovement
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class EvaAlertsInfo : TraitInfo<EvaAlerts>
|
||||
public class EvaAlertsInfo : TraitInfo<EvaAlerts>
|
||||
{
|
||||
// Sound effects
|
||||
public readonly string TabClick = "ramenu1.aud";
|
||||
@@ -59,5 +59,5 @@ namespace OpenRA.Traits
|
||||
public readonly string CreditsStolen = "credit1.aud";
|
||||
}
|
||||
|
||||
class EvaAlerts {}
|
||||
public class EvaAlerts {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user