finished building *Infos
This commit is contained in:
@@ -647,7 +647,7 @@ namespace OpenRa.Game
|
||||
DrawRightAligned( "${0}".F(info.Cost), pos + new int2(-5,5),
|
||||
Game.LocalPlayer.Cash + Game.LocalPlayer.Ore >= info.Cost ? Color.White : Color.Red);
|
||||
|
||||
var bi = info as BuildingInfo;
|
||||
var bi = info as LegacyBuildingInfo;
|
||||
if (bi != null)
|
||||
DrawRightAligned("ϟ{0}".F(bi.Power), pos + new int2(-5, 20),
|
||||
Game.LocalPlayer.PowerProvided - Game.LocalPlayer.PowerDrained + bi.Power >= 0
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace OpenRa.Game
|
||||
public static Random SharedRandom = new Random(0); /* for things that require sync */
|
||||
public static Random CosmeticRandom = new Random(); /* for things that are just fluff */
|
||||
|
||||
public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
||||
public static bool CanPlaceBuilding(LegacyBuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
||||
{
|
||||
return !Footprint.Tiles(building, xy, adjust).Any(
|
||||
t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t,
|
||||
@@ -329,7 +329,7 @@ namespace OpenRa.Game
|
||||
toIgnore));
|
||||
}
|
||||
|
||||
public static bool IsCloseEnoughToBase(Player p, BuildingInfo bi, int2 position)
|
||||
public static bool IsCloseEnoughToBase(Player p, LegacyBuildingInfo bi, int2 position)
|
||||
{
|
||||
var maxDistance = bi.Adjacent + 1;
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace OpenRa.Game
|
||||
heuristic = loc =>
|
||||
{
|
||||
var b = Game.BuildingInfluence.GetBuildingAt(loc);
|
||||
if (b != null && b.Owner == p && (b.Info as BuildingInfo).BaseNormal) return 0;
|
||||
if (b != null && b.Owner == p && (b.Info as LegacyBuildingInfo).BaseNormal) return 0;
|
||||
if ((loc - position).Length > maxDistance)
|
||||
return float.PositiveInfinity; /* not quite right */
|
||||
return 1;
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace OpenRa.Game.GameRules
|
||||
{
|
||||
static class Footprint
|
||||
{
|
||||
public static IEnumerable<int2> Tiles( BuildingInfo buildingInfo, int2 position )
|
||||
public static IEnumerable<int2> Tiles( LegacyBuildingInfo buildingInfo, int2 position )
|
||||
{
|
||||
return Tiles(buildingInfo, position, true);
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> Tiles( BuildingInfo buildingInfo, int2 position, bool adjustForPlacement )
|
||||
public static IEnumerable<int2> Tiles( LegacyBuildingInfo buildingInfo, int2 position, bool adjustForPlacement )
|
||||
{
|
||||
var dim = buildingInfo.Dimensions;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRa.Game.GameRules
|
||||
return Tiles( building.unitInfo, a.Location, false );
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> UnpathableTiles( BuildingInfo buildingInfo, int2 position )
|
||||
public static IEnumerable<int2> UnpathableTiles( LegacyBuildingInfo buildingInfo, int2 position )
|
||||
{
|
||||
var footprint = buildingInfo.Footprint.Where( x => !char.IsWhiteSpace( x ) ).ToArray();
|
||||
foreach( var tile in TilesWhere( buildingInfo.Name, buildingInfo.Dimensions, footprint, a => a == 'x' ) )
|
||||
@@ -52,7 +52,7 @@ namespace OpenRa.Game.GameRules
|
||||
yield return new int2( x, y );
|
||||
}
|
||||
|
||||
public static int2 AdjustForBuildingSize( BuildingInfo unitInfo )
|
||||
public static int2 AdjustForBuildingSize( LegacyBuildingInfo unitInfo )
|
||||
{
|
||||
var dim = unitInfo.Dimensions;
|
||||
return new int2( dim.X / 2, dim.Y > 1 ? ( dim.Y + 1 ) / 2 : 0 );
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace OpenRa.Game
|
||||
UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair<string, string>(y, x.Key))).ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
UnitInfo = new InfoLoader<LegacyUnitInfo>(
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Building", s => new BuildingInfo(s)),
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Defense", s => new BuildingInfo(s)),
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Building", s => new LegacyBuildingInfo(s)),
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Defense", s => new LegacyBuildingInfo(s)),
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Infantry", s => new InfantryInfo(s)),
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Vehicle", s => new VehicleInfo(s)),
|
||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Ship", s => new VehicleInfo(s)),
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace OpenRa.Game.GameRules
|
||||
{
|
||||
foreach( var b in Rules.Categories[ "Building" ] )
|
||||
{
|
||||
var info = (BuildingInfo)Rules.UnitInfo[ b ];
|
||||
var info = (LegacyBuildingInfo)Rules.UnitInfo[ b ];
|
||||
foreach( var p in info.Produces )
|
||||
producesIndex[ p ].Add( info );
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace OpenRa.Game.GameRules
|
||||
public Cache<string, List<Actor>> GatherBuildings( Player player )
|
||||
{
|
||||
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
|
||||
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is BuildingInfo ) )
|
||||
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is LegacyBuildingInfo ) )
|
||||
ret[ b.Info.Name ].Add( b );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRa.Game.GameRules
|
||||
public VehicleInfo(string name) : base(name) { }
|
||||
}
|
||||
|
||||
public class BuildingInfo : LegacyUnitInfo
|
||||
public class LegacyBuildingInfo : LegacyUnitInfo
|
||||
{
|
||||
public readonly int2 Dimensions = new int2(1, 1);
|
||||
public readonly string Footprint = "x";
|
||||
@@ -112,6 +112,6 @@ namespace OpenRa.Game.GameRules
|
||||
public readonly int[] RallyPoint = { 1, 3 };
|
||||
public readonly float[] SpawnOffset = null;
|
||||
|
||||
public BuildingInfo(string name) : base(name) { }
|
||||
public LegacyBuildingInfo(string name) : base(name) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace OpenRa.Game.Orders
|
||||
class PlaceBuildingOrderGenerator : IOrderGenerator
|
||||
{
|
||||
readonly Actor Producer;
|
||||
readonly BuildingInfo Building;
|
||||
readonly LegacyBuildingInfo Building;
|
||||
|
||||
public PlaceBuildingOrderGenerator(Actor producer, string name)
|
||||
{
|
||||
Producer = producer;
|
||||
Building = (BuildingInfo)Rules.UnitInfo[ name ];
|
||||
Building = (LegacyBuildingInfo)Rules.UnitInfo[ name ];
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRa.Game.Orders
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.Info.Selectable).FirstOrDefault();
|
||||
|
||||
var building = underCursor != null ? underCursor.Info as BuildingInfo : null;
|
||||
var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null;
|
||||
|
||||
if (building != null)
|
||||
yield return new Order("PowerDown", underCursor, null, int2.Zero, null);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRa.Game.Orders
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.Info.Selectable).FirstOrDefault();
|
||||
|
||||
var building = underCursor != null ? underCursor.Info as BuildingInfo : null;
|
||||
var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null;
|
||||
|
||||
if (building != null && building.Repairable && underCursor.Health < building.Strength)
|
||||
yield return new Order("Repair", underCursor, null, int2.Zero, null);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRa.Game.Orders
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.Info.Selectable).FirstOrDefault();
|
||||
|
||||
var building = underCursor != null ? underCursor.Info as BuildingInfo : null;
|
||||
var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null;
|
||||
|
||||
if (building != null && !building.Unsellable)
|
||||
yield return new Order("Sell", underCursor, null, int2.Zero, null);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRa.Game.Orders
|
||||
else
|
||||
return Cursor.MoveBlocked;
|
||||
case "DeployMcv":
|
||||
var factBuildingInfo = (BuildingInfo)Rules.UnitInfo["fact"];
|
||||
var factBuildingInfo = (LegacyBuildingInfo)Rules.UnitInfo["fact"];
|
||||
if (Game.CanPlaceBuilding(factBuildingInfo, a.Location - new int2(1, 1), a, false))
|
||||
return Cursor.Deploy;
|
||||
else
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenRa.Game.Orders
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
var queue = order.Player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||
var building = (BuildingInfo)Rules.UnitInfo[ order.TargetString ];
|
||||
var building = (LegacyBuildingInfo)Rules.UnitInfo[ order.TargetString ];
|
||||
var producing = queue.CurrentItem(Rules.UnitCategory[order.TargetString]);
|
||||
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
||||
return;
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
OreCapacity = Game.world.Actors
|
||||
.Where(a => a.Owner == this && a.traits.Contains<StoresOre>())
|
||||
.Select(a => a.Info as BuildingInfo)
|
||||
.Select(a => a.Info as LegacyBuildingInfo)
|
||||
.Where(b => b != null)
|
||||
.Sum(b => b.Storage);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class APMineInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new APMine(self); }
|
||||
}
|
||||
|
||||
class APMine : ICrushable, IOccupySpace
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.GameRules;
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Effects;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ATMineInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new ATMine(self); }
|
||||
}
|
||||
|
||||
class ATMine : ICrushable, IOccupySpace
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AcceptsOreInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new AcceptsOre(self); }
|
||||
}
|
||||
|
||||
class AcceptsOre
|
||||
{
|
||||
public AcceptsOre(Actor self)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
if (res != null)
|
||||
self.traits.Get<Helicopter>().reservation = res.Reserve(self);
|
||||
|
||||
var offset = (dest.Info as BuildingInfo).SpawnOffset;
|
||||
var offset = (dest.Info as LegacyBuildingInfo).SpawnOffset;
|
||||
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
|
||||
@@ -8,9 +8,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AttackBaseInfo : ITraitInfo
|
||||
{
|
||||
|
||||
|
||||
public object Create(Actor self) { return new AttackBase(self); }
|
||||
public virtual object Create(Actor self) { return new AttackBase(self); }
|
||||
}
|
||||
|
||||
class AttackBase : IIssueOrder, IResolveOrder, ITick
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AttackHeliInfo : AttackBaseInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new AttackHeli(self); }
|
||||
}
|
||||
|
||||
class AttackHeli : AttackFrontal
|
||||
{
|
||||
public AttackHeli(Actor self) : base(self, 20) { }
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AttackPlaneInfo : AttackBaseInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new AttackPlane(self); }
|
||||
}
|
||||
|
||||
class AttackPlane : AttackFrontal
|
||||
{
|
||||
public AttackPlane(Actor self) : base(self, 20) { }
|
||||
|
||||
@@ -3,11 +3,14 @@ using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AttackTurretedInfo : AttackBaseInfo { }
|
||||
class AttackTurretedInfo : AttackBaseInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new AttackTurreted( self ); }
|
||||
}
|
||||
|
||||
class AttackTurreted : AttackBase, INotifyBuildComplete
|
||||
{
|
||||
public AttackTurreted( Actor self ) : base(self) { self.traits.Get<Turreted>(); }
|
||||
public AttackTurreted(Actor self) : base(self) { }
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
|
||||
@@ -3,10 +3,10 @@ using OpenRa.Game.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AutoHealInfo : StatelessTraitInfo<AutoHeal> { }
|
||||
|
||||
class AutoHeal : ITick
|
||||
{
|
||||
public AutoHeal(Actor self) { }
|
||||
|
||||
void AttackTarget(Actor self, Actor target)
|
||||
{
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AutoTargetInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new AutoTarget(self); }
|
||||
}
|
||||
class AutoTargetInfo : StatelessTraitInfo<AutoTarget> { }
|
||||
|
||||
class AutoTarget : ITick, INotifyDamage
|
||||
{
|
||||
public AutoTarget(Actor self) {}
|
||||
|
||||
void AttackTarget(Actor self, Actor target)
|
||||
{
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
|
||||
@@ -3,10 +3,10 @@ using System.Linq;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class BelowUnitsInfo : StatelessTraitInfo<BelowUnits> { }
|
||||
|
||||
class BelowUnits : IRenderModifier
|
||||
{
|
||||
public BelowUnits(Actor self) { }
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
return r.Select(a => a.WithZOffset(-1));
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class BuildableInfo : ITraitInfo
|
||||
class BuildableInfo : StatelessTraitInfo<Buildable>
|
||||
{
|
||||
public readonly int TechLevel = -1;
|
||||
public readonly string Tab = null;
|
||||
@@ -15,12 +15,7 @@ namespace OpenRa.Game.Traits
|
||||
public readonly string Description = "";
|
||||
public readonly string LongDesc = "";
|
||||
public readonly string Icon = null;
|
||||
|
||||
public object Create(Actor self) { return new Buildable(self); }
|
||||
}
|
||||
|
||||
class Buildable
|
||||
{
|
||||
public Buildable( Actor self ) { }
|
||||
}
|
||||
class Buildable { }
|
||||
}
|
||||
|
||||
@@ -9,10 +9,15 @@ using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class BuildingInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Building(self); }
|
||||
}
|
||||
|
||||
class Building : INotifyDamage, IResolveOrder, ITick
|
||||
{
|
||||
readonly Actor self;
|
||||
public readonly BuildingInfo unitInfo;
|
||||
public readonly LegacyBuildingInfo unitInfo;
|
||||
[Sync]
|
||||
bool isRepairing = false;
|
||||
[Sync]
|
||||
@@ -24,7 +29,7 @@ namespace OpenRa.Game.Traits
|
||||
public Building(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
unitInfo = (BuildingInfo)self.Info;
|
||||
unitInfo = (LegacyBuildingInfo)self.Info;
|
||||
self.CenterLocation = Game.CellSize
|
||||
* ((float2)self.Location + .5f * (float2)unitInfo.Dimensions);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class C4DemolitionInfo : StatelessTraitInfo<C4Demolition> { }
|
||||
|
||||
class C4Demolition : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public C4Demolition(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
|
||||
@@ -4,6 +4,11 @@ using OpenRa.Game.Orders;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ChronoshiftDeployInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new ChronoshiftDeploy(self); }
|
||||
}
|
||||
|
||||
class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ISpeedModifier, ITick, IPips
|
||||
{
|
||||
// Recharge logic
|
||||
|
||||
@@ -3,6 +3,9 @@ using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
// this is NOT bound through rules (it belongs on the world actor!)
|
||||
// so no *Info required
|
||||
|
||||
class ChronoshiftPaletteEffect : IPaletteModifier, ITick
|
||||
{
|
||||
const int chronoEffectLength = 20;
|
||||
|
||||
@@ -5,8 +5,6 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class Chronosphere
|
||||
{
|
||||
public Chronosphere(Actor self) { }
|
||||
}
|
||||
class ChronosphereInfo : StatelessTraitInfo<Chronosphere> { }
|
||||
class Chronosphere { }
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@ using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class CloakInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Cloak(self); }
|
||||
}
|
||||
|
||||
class Cloak : IRenderModifier, INotifyAttack, ITick
|
||||
{
|
||||
[Sync]
|
||||
|
||||
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class EngineerCaptureInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new EngineerCapture(self); }
|
||||
}
|
||||
class EngineerCaptureInfo : StatelessTraitInfo<EngineerCapture> { }
|
||||
|
||||
class EngineerCapture : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public const int EngineerDamage = 300; // todo: push into rules, as a weapon
|
||||
|
||||
public EngineerCapture(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class ExplodesInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Explodes(self); }
|
||||
}
|
||||
class ExplodesInfo : StatelessTraitInfo<Explodes> { }
|
||||
|
||||
class Explodes : INotifyDamage
|
||||
{
|
||||
public Explodes(Actor self) {}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (self.IsDead)
|
||||
|
||||
@@ -2,18 +2,10 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class FakeInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Fake(self); }
|
||||
}
|
||||
class FakeInfo : StatelessTraitInfo<Fake> { }
|
||||
|
||||
class Fake : ITags
|
||||
{
|
||||
public Fake(Actor self){}
|
||||
|
||||
public IEnumerable<TagType> GetTags()
|
||||
{
|
||||
yield return TagType.Fake;
|
||||
}
|
||||
public IEnumerable<TagType> GetTags() { yield return TagType.Fake; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class GpsLaunchSiteInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new GpsLaunchSite(self); }
|
||||
}
|
||||
|
||||
class GpsLaunchSite { public GpsLaunchSite(Actor self) { } }
|
||||
class GpsLaunchSiteInfo : StatelessTraitInfo<GpsLaunchSite> { }
|
||||
class GpsLaunchSite { }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class HarvesterInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Harvester(self); }
|
||||
public object Create(Actor self) { return new Harvester(); }
|
||||
}
|
||||
|
||||
class Harvester : IIssueOrder, IResolveOrder, IPips
|
||||
@@ -18,8 +18,6 @@ namespace OpenRa.Game.Traits
|
||||
public bool IsFull { get { return oreCarried + gemsCarried == Rules.General.BailCount; } }
|
||||
public bool IsEmpty { get { return oreCarried == 0 && gemsCarried == 0; } }
|
||||
|
||||
public Harvester(Actor self) { }
|
||||
|
||||
public void AcceptResource(bool isGem)
|
||||
{
|
||||
if (isGem) gemsCarried++;
|
||||
|
||||
@@ -6,6 +6,9 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class HelicopterInfo : ITraitInfo
|
||||
{
|
||||
public readonly int ROT = 0;
|
||||
public readonly int Speed = 0;
|
||||
|
||||
public object Create(Actor self) { return new Helicopter(self); }
|
||||
}
|
||||
|
||||
@@ -60,7 +63,7 @@ namespace OpenRa.Game.Traits
|
||||
if (res != null)
|
||||
reservation = res.Reserve(self);
|
||||
|
||||
var offset = (order.TargetActor.Info as BuildingInfo).SpawnOffset;
|
||||
var offset = (order.TargetActor.Info as LegacyBuildingInfo).SpawnOffset;
|
||||
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
|
||||
|
||||
self.CancelActivity();
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class InvisibleToOthersInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new InvisibleToOthers(self); }
|
||||
}
|
||||
class InvisibleToOthersInfo : StatelessTraitInfo<InvisibleToOthers> { }
|
||||
|
||||
class InvisibleToOthers : IRenderModifier
|
||||
{
|
||||
public InvisibleToOthers(Actor self) { }
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
return Game.LocalPlayer == self.Owner
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class IronCurtainInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new IronCurtain(self); }
|
||||
}
|
||||
|
||||
class IronCurtain
|
||||
{
|
||||
public IronCurtain(Actor self) {}
|
||||
}
|
||||
class IronCurtainInfo : StatelessTraitInfo<IronCurtain> { }
|
||||
class IronCurtain { }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class IronCurtainableInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new IronCurtain(self); }
|
||||
public object Create(Actor self) { return new IronCurtainable(); }
|
||||
}
|
||||
|
||||
class IronCurtainable : IResolveOrder, IDamageModifier, ITick
|
||||
@@ -13,8 +13,6 @@ namespace OpenRa.Game.Traits
|
||||
[Sync]
|
||||
int RemainingTicks = 0;
|
||||
|
||||
public IronCurtainable(Actor self) { }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (RemainingTicks > 0)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
if( order.OrderString == "DeployMcv" )
|
||||
{
|
||||
var factBuildingInfo = (BuildingInfo)Rules.UnitInfo[ "fact" ];
|
||||
var factBuildingInfo = (LegacyBuildingInfo)Rules.UnitInfo[ "fact" ];
|
||||
if( Game.CanPlaceBuilding( factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) )
|
||||
{
|
||||
self.CancelActivity();
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class MineImmuneInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new MineImmune(self); }
|
||||
}
|
||||
|
||||
class MineImmune
|
||||
{
|
||||
public MineImmune(Actor self) { }
|
||||
}
|
||||
class MineImmuneInfo : StatelessTraitInfo<MineImmune> { }
|
||||
class MineImmune { }
|
||||
}
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class MinelayerInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new Minelayer(self); }
|
||||
}
|
||||
class MinelayerInfo : StatelessTraitInfo<Minelayer> { }
|
||||
|
||||
class Minelayer : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public Minelayer(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
|
||||
@@ -21,7 +13,7 @@ namespace OpenRa.Game.Traits
|
||||
return null;
|
||||
|
||||
// Ensure that the cell is empty except for the minelayer
|
||||
if (Game.UnitInfluence.GetUnitsAt( xy ).Any(a => a != self))
|
||||
if (Game.UnitInfluence.GetUnitsAt(xy).Any(a => a != self))
|
||||
return null;
|
||||
|
||||
if (mi.Button == MouseButton.Right && underCursor == self)
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class PlaneInfo : ITraitInfo
|
||||
{
|
||||
public readonly int ROT = 0;
|
||||
public readonly int Speed = 0;
|
||||
|
||||
public object Create(Actor self) { return new Plane(self); }
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRa.Game.Traits
|
||||
newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) );
|
||||
}
|
||||
|
||||
var bi = self.Info as BuildingInfo;
|
||||
var bi = self.Info as LegacyBuildingInfo;
|
||||
if (bi != null && bi.SpawnOffset != null)
|
||||
newUnit.CenterLocation = self.CenterLocation
|
||||
+ new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]);
|
||||
@@ -83,12 +83,12 @@ namespace OpenRa.Game.Traits
|
||||
}
|
||||
|
||||
// Cancel existing primaries
|
||||
foreach (var p in (self.Info as BuildingInfo).Produces)
|
||||
foreach (var p in (self.Info as LegacyBuildingInfo).Produces)
|
||||
{
|
||||
foreach (var b in Game.world.Actors.Where(x => x.traits.Contains<Production>()
|
||||
&& x.Owner == self.Owner
|
||||
&& x.traits.Get<Production>().IsPrimary == true
|
||||
&& (x.Info as BuildingInfo).Produces.Contains(p)))
|
||||
&& (x.Info as LegacyBuildingInfo).Produces.Contains(p)))
|
||||
{
|
||||
b.traits.Get<Production>().SetPrimaryProducer(b, false);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits
|
||||
public void OnSteal(Actor self, Actor thief)
|
||||
{
|
||||
// Steal half the ore the building holds
|
||||
var toSteal = (self.Info as BuildingInfo).Storage/2;
|
||||
var toSteal = (self.Info as LegacyBuildingInfo).Storage/2;
|
||||
self.Owner.TakeCash(toSteal);
|
||||
thief.Owner.GiveCash(toSteal);
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class WaterPaletteRotationInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new WaterPaletteRotation(self); }
|
||||
}
|
||||
// this is NOT bound through rules (it belongs on the world actor!)
|
||||
// so no *Info required
|
||||
|
||||
class WaterPaletteRotation : ITick, IPaletteModifier
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRa.Game
|
||||
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
|
||||
}
|
||||
|
||||
public void DrawBuildingGrid( BuildingInfo bi )
|
||||
public void DrawBuildingGrid( LegacyBuildingInfo bi )
|
||||
{
|
||||
var position = Game.controller.MousePosition.ToInt2();
|
||||
var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, bi, position);
|
||||
|
||||
Reference in New Issue
Block a user