code cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -11,14 +11,17 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class ChronoshiftPowerInfo : SupportPowerInfo
|
class ChronoshiftPowerInfo : SupportPowerInfo
|
||||||
{
|
{
|
||||||
public readonly int Range = 1; // Range in cells
|
[Desc("Cells")]
|
||||||
public readonly int Duration = 30; // Seconds
|
public readonly int Range = 1;
|
||||||
|
[Desc("Seconds")]
|
||||||
|
public readonly int Duration = 30;
|
||||||
public readonly bool KillCargo = true;
|
public readonly bool KillCargo = true;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); }
|
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); }
|
||||||
@@ -51,7 +54,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
public IEnumerable<Actor> UnitsInRange(CPos xy)
|
||||||
{
|
{
|
||||||
int range = (Info as ChronoshiftPowerInfo).Range;
|
var range = (Info as ChronoshiftPowerInfo).Range;
|
||||||
var tiles = self.World.FindTilesInCircle(xy, range);
|
var tiles = self.World.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
@@ -60,31 +63,33 @@ namespace OpenRA.Mods.RA
|
|||||||
return units.Distinct().Where(a => a.HasTrait<Chronoshiftable>());
|
return units.Distinct().Where(a => a.HasTrait<Chronoshiftable>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SimilarTerrain(CPos xy, CPos sourceLocation)
|
||||||
public bool SimilarTerrain(CPos xy, CPos sourceLocation) {
|
{
|
||||||
|
|
||||||
if (!self.Owner.Shroud.IsExplored(xy))
|
if (!self.Owner.Shroud.IsExplored(xy))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int range = (Info as ChronoshiftPowerInfo).Range;
|
var range = (Info as ChronoshiftPowerInfo).Range;
|
||||||
var sourceTiles = self.World.FindTilesInCircle(xy, range);
|
var sourceTiles = self.World.FindTilesInCircle(xy, range);
|
||||||
var destTiles = self.World.FindTilesInCircle(sourceLocation, range);
|
var destTiles = self.World.FindTilesInCircle(sourceLocation, range);
|
||||||
List<string> sourceTerrain = new List<string>();
|
var sourceTerrain = new List<string>();
|
||||||
List<string> destTerrain = new List<string>();
|
var destTerrain = new List<string>();
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
foreach (var t in sourceTiles) {
|
foreach (var t in sourceTiles)
|
||||||
|
{
|
||||||
j = j + 1;
|
j = j + 1;
|
||||||
if (!self.Owner.Shroud.IsExplored(t))
|
if (!self.Owner.Shroud.IsExplored(t))
|
||||||
return false;
|
return false;
|
||||||
sourceTerrain.Add(self.World.GetTerrainType(t));
|
sourceTerrain.Add(self.World.GetTerrainType(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
foreach (var t in destTiles) {
|
foreach (var t in destTiles)
|
||||||
|
{
|
||||||
j = j + 1;
|
j = j + 1;
|
||||||
if (!self.Owner.Shroud.IsExplored(t)) {
|
if (!self.Owner.Shroud.IsExplored(t))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
self.World.GetTerrainType(t);
|
self.World.GetTerrainType(t);
|
||||||
destTerrain.Add(self.World.GetTerrainType(t));
|
destTerrain.Add(self.World.GetTerrainType(t));
|
||||||
}
|
}
|
||||||
@@ -93,7 +98,8 @@ namespace OpenRA.Mods.RA
|
|||||||
if (sourceTerrain.Count != destTerrain.Count)
|
if (sourceTerrain.Count != destTerrain.Count)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < sourceTerrain.Count; i++) {
|
for (int i = 0; i < sourceTerrain.Count; i++)
|
||||||
|
{
|
||||||
if (!sourceTerrain[i].Equals(destTerrain[i]))
|
if (!sourceTerrain[i].Equals(destTerrain[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -101,7 +107,6 @@ namespace OpenRA.Mods.RA
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SelectTarget : IOrderGenerator
|
class SelectTarget : IOrderGenerator
|
||||||
{
|
{
|
||||||
readonly ChronoshiftPower power;
|
readonly ChronoshiftPower power;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -19,15 +20,24 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class IronCurtainPowerInfo : SupportPowerInfo
|
class IronCurtainPowerInfo : SupportPowerInfo
|
||||||
{
|
{
|
||||||
public readonly int Duration = 10; // Seconds
|
[Desc("Seconds")]
|
||||||
public readonly int Range = 1; // Range in cells
|
public readonly int Duration = 10;
|
||||||
|
[Desc("Cells")]
|
||||||
|
public readonly int Range = 1;
|
||||||
|
public readonly string IronCurtainSound = "ironcur9.aud";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new IronCurtainPower(init.self, this); }
|
public override object Create(ActorInitializer init) { return new IronCurtainPower(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class IronCurtainPower : SupportPower
|
class IronCurtainPower : SupportPower
|
||||||
{
|
{
|
||||||
public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info) { }
|
IronCurtainPowerInfo info;
|
||||||
|
|
||||||
|
public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
||||||
@@ -40,7 +50,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
|
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
|
|
||||||
Sound.Play("ironcur9.aud", order.TargetLocation.CenterPosition);
|
Sound.Play(info.IronCurtainSound, order.TargetLocation.CenterPosition);
|
||||||
|
|
||||||
foreach (var target in UnitsInRange(order.TargetLocation)
|
foreach (var target in UnitsInRange(order.TargetLocation)
|
||||||
.Where(a => a.Owner.Stances[self.Owner] == Stance.Ally))
|
.Where(a => a.Owner.Stances[self.Owner] == Stance.Ally))
|
||||||
|
|||||||
Reference in New Issue
Block a user