diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 1308ba32ef..717221cb3b 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -38,8 +38,7 @@ namespace OpenRA public readonly World World; public readonly uint ActorID; - [Sync] - public int2 Location; + public int2 Location { get { return traits.Get().TopLeft; } } [Sync] public Player Owner; [Sync] @@ -52,11 +51,9 @@ namespace OpenRA { World = world; ActorID = world.NextAID(); - Location = location; - CenterLocation = Traits.Util.CenterOfCell(Location); Owner = owner; - var init = new ActorInitializer( this ); + var init = new ActorInitializer( this, location ); if (name != null) { @@ -70,6 +67,9 @@ namespace OpenRA traits.Add(trait.Create(init)); } + if( CenterLocation == float2.Zero && traits.Contains() ) + CenterLocation = Traits.Util.CenterOfCell(Location); + Size = Lazy.New(() => { var si = Info.Traits.GetOrDefault(); @@ -262,10 +262,12 @@ namespace OpenRA { public readonly Actor self; public World world { get { return self.World; } } + public readonly int2 location; - public ActorInitializer( Actor actor ) + public ActorInitializer( Actor actor, int2 location ) { this.self = actor; + this.location = location; } } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 5f95edb4db..67a316fd7d 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -1,4 +1,4 @@ - + Debug diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Game/Traits/Building.cs index 31ac388e9c..d402dc0e84 100644 --- a/OpenRA.Game/Traits/Building.cs +++ b/OpenRA.Game/Traits/Building.cs @@ -54,14 +54,16 @@ namespace OpenRA.Traits public readonly string DamagedSound = "kaboom1.aud"; public readonly string DestroyedSound = "kaboom22.aud"; - public object Create(ActorInitializer init) { return new Building(init.self); } + public object Create(ActorInitializer init) { return new Building(init); } } - public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier + public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace { readonly Actor self; public readonly BuildingInfo Info; [Sync] + readonly int2 topLeft; + [Sync] bool isRepairing = false; public bool Disabled @@ -69,12 +71,13 @@ namespace OpenRA.Traits get { return self.traits.WithInterface().Any(t => t.Disabled); } } - public Building(Actor self) + public Building(ActorInitializer init) { - this.self = self; + this.self = init.self; + this.topLeft = init.location; Info = self.Info.Traits.Get(); self.CenterLocation = Game.CellSize - * ((float2)self.Location + .5f * (float2)Info.Dimensions); + * ((float2)topLeft + .5f * (float2)Info.Dimensions); } public int GetPowerUsage() @@ -157,5 +160,15 @@ namespace OpenRA.Traits yield return a.WithPalette("disabled"); } } + + public int2 TopLeft + { + get { return topLeft; } + } + + public IEnumerable OccupiedCells() + { + return Footprint.UnpathableTiles( self.Info.Name, Info, TopLeft ); + } } } diff --git a/OpenRA.Game/Traits/Mobile.cs b/OpenRA.Game/Traits/Mobile.cs index c70b5187d2..dc81a695b1 100644 --- a/OpenRA.Game/Traits/Mobile.cs +++ b/OpenRA.Game/Traits/Mobile.cs @@ -24,13 +24,13 @@ using OpenRA.GameRules; namespace OpenRA.Traits { - public class MobileInfo : ITraitInfo, ITraitPrerequisite + public class MobileInfo : ITraitInfo, ITraitPrerequisite { public readonly UnitMovementType MovementType = UnitMovementType.Wheel; public readonly int WaitAverage = 60; public readonly int WaitSpread = 20; - public object Create(ActorInitializer init) { return new Mobile(init.self); } + public object Create(ActorInitializer init) { return new Mobile(init); } } public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement @@ -38,36 +38,37 @@ namespace OpenRA.Traits readonly Actor self; [Sync] - int2 __fromCell; + int2 __fromCell, __toCell; public int2 fromCell { get { return __fromCell; } - set { self.World.WorldActor.traits.Get().Remove(self, this); __fromCell = value; self.World.WorldActor.traits.Get().Add(self, this); } + set { SetLocation( value, __toCell ); } } + [Sync] public int2 toCell { - get { return self.Location; } - set - { - if (self.Location != value) - { - self.World.WorldActor.traits.Get().Remove(self, this); - self.Location = value; - } - self.World.WorldActor.traits.Get().Add(self, this); - } + get { return __toCell; } + set { SetLocation( __fromCell, value ); } + } + void SetLocation( int2 from, int2 to ) + { + if( fromCell == from && toCell == to ) return; + self.World.WorldActor.traits.Get().Remove(self, this); + __fromCell = from; + __toCell = to; + self.World.WorldActor.traits.Get().Add(self, this); } - public Mobile(Actor self) + public Mobile(ActorInitializer init) { - this.self = self; - __fromCell = toCell; + this.self = init.self; + this.__fromCell = this.__toCell = init.location; self.World.WorldActor.traits.Get().Add(self, this); } public void TeleportTo(Actor self, int2 xy) { - fromCell = toCell = xy; + SetLocation( xy, xy ); self.CenterLocation = Util.CenterOfCell(fromCell); } @@ -102,6 +103,8 @@ namespace OpenRA.Traits } } + public int2 TopLeft { get { return toCell; } } + public IEnumerable OccupiedCells() { return (fromCell == toCell) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index ea32ed9d32..7391301c9e 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -61,8 +61,32 @@ namespace OpenRA.Traits } public interface IDisable { bool Disabled { get; } } - - public interface IOccupySpace { IEnumerable OccupiedCells(); } + + public interface IOccupySpace + { + int2 TopLeft { get; } + IEnumerable OccupiedCells(); + } + + public static class IOccupySpaceExts + { + public static int2 NearestCellTo( this IOccupySpace ios, int2 other ) + { + var nearest = ios.TopLeft; + var nearestDistance = int.MaxValue; + foreach( var cell in ios.OccupiedCells() ) + { + var dist = ( other - cell ).LengthSquared; + if( dist < nearestDistance ) + { + nearest = cell; + nearestDistance = dist; + } + } + return nearest; + } + } + public interface INotifyAttack { void Attacking(Actor self); } public interface IRenderModifier { IEnumerable ModifyRender(Actor self, IEnumerable r); } public interface IDamageModifier { float GetDamageModifier( WarheadInfo warhead ); } @@ -112,7 +136,7 @@ namespace OpenRA.Traits public class TraitInfo : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } } - public interface ITraitPrerequisite { } + public interface ITraitPrerequisite where T : ITraitInfo { } public interface INotifySelection { void SelectionChanged(); } public interface ILoadWorldHook { void WorldLoaded(World w); } diff --git a/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs b/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs index e5f25f0787..4af4dfcc47 100644 --- a/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs +++ b/OpenRA.Mods.Cnc/TiberiumRefineryDockAction.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc { class TiberiumRefineryDockActionInfo : TraitInfo {} - class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture, ITraitPrerequisite + class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture { Actor dockedHarv = null; bool preventDock = false; diff --git a/OpenRA.Mods.RA/Activities/Fly.cs b/OpenRA.Mods.RA/Activities/Fly.cs index e5aa0ee84d..3359a1db49 100644 --- a/OpenRA.Mods.RA/Activities/Fly.cs +++ b/OpenRA.Mods.RA/Activities/Fly.cs @@ -68,9 +68,10 @@ namespace OpenRA.Mods.RA.Activities var unit = self.traits.Get(); var speed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly); var angle = unit.Facing / 128f * Math.PI; + var aircraft = self.traits.Get(); self.CenterLocation += speed * -float2.FromAngle((float)angle); - self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); + aircraft.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); unit.Altitude += Math.Sign(desiredAltitude - unit.Altitude); } diff --git a/OpenRA.Mods.RA/Activities/HeliAttack.cs b/OpenRA.Mods.RA/Activities/HeliAttack.cs index fae9b230ed..1d4edcfec3 100644 --- a/OpenRA.Mods.RA/Activities/HeliAttack.cs +++ b/OpenRA.Mods.RA/Activities/HeliAttack.cs @@ -44,6 +44,7 @@ namespace OpenRA.Mods.RA.Activities return NextActivity; } var unit = self.traits.Get(); + var aircraft = self.traits.Get(); var info = self.Info.Traits.Get(); if (unit.Altitude != info.CruiseAltitude) @@ -62,7 +63,7 @@ namespace OpenRA.Mods.RA.Activities if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize)) self.CenterLocation += (rawSpeed / dist.Length) * dist; - + return this; } diff --git a/OpenRA.Mods.RA/Activities/HeliFly.cs b/OpenRA.Mods.RA/Activities/HeliFly.cs index 533cb24b96..ceede06670 100644 --- a/OpenRA.Mods.RA/Activities/HeliFly.cs +++ b/OpenRA.Mods.RA/Activities/HeliFly.cs @@ -43,6 +43,7 @@ namespace OpenRA.Mods.RA.Activities var unit = self.traits.Get(); var info = self.Info.Traits.Get(); + var aircraft = self.traits.Get(); if (unit.Altitude != info.CruiseAltitude) { @@ -54,7 +55,7 @@ namespace OpenRA.Mods.RA.Activities if (float2.WithinEpsilon(float2.Zero, dist, 2)) { self.CenterLocation = Dest; - self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); + aircraft.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); return NextActivity; } @@ -64,7 +65,7 @@ namespace OpenRA.Mods.RA.Activities var rawSpeed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly); self.CenterLocation += (rawSpeed / dist.Length) * dist; - self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); + aircraft.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); return this; } diff --git a/OpenRA.Mods.RA/Activities/Land.cs b/OpenRA.Mods.RA/Activities/Land.cs index 49f9e117cb..4e64474f01 100644 --- a/OpenRA.Mods.RA/Activities/Land.cs +++ b/OpenRA.Mods.RA/Activities/Land.cs @@ -50,6 +50,7 @@ namespace OpenRA.Mods.RA.Activities return NextActivity; var unit = self.traits.Get(); + var aircraft = self.traits.Get(); if (unit.Altitude > 0) --unit.Altitude; @@ -60,7 +61,7 @@ namespace OpenRA.Mods.RA.Activities var angle = unit.Facing / 128f * Math.PI; self.CenterLocation += speed * -float2.FromAngle((float)angle); - self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); + aircraft.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); return this; } diff --git a/OpenRA.Mods.RA/Aircraft.cs b/OpenRA.Mods.RA/Aircraft.cs new file mode 100755 index 0000000000..6d06c5f45a --- /dev/null +++ b/OpenRA.Mods.RA/Aircraft.cs @@ -0,0 +1,68 @@ +#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 . + */ +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRA.GameRules; + +namespace OpenRA.Traits +{ + public class AircraftInfo : ITraitInfo + { + public readonly int CruiseAltitude = 20; + public readonly string[] RepairBuildings = { "fix" }; + public readonly string[] RearmBuildings = { "hpad", "afld" }; + + public virtual object Create( ActorInitializer init ) { return new Aircraft( init ); } + } + + public class Aircraft : IOccupySpace, IMovement + { + [Sync] + public int2 Location; + + public Aircraft( ActorInitializer init ) + { + this.Location = init.location; + } + + public int2 TopLeft + { + get { return Location; } + } + + public IEnumerable OccupiedCells() + { + // TODO: make helis on the ground occupy a space. + yield break; + } + + public bool AircraftCanEnter(Actor self, Actor a) + { + var aircraft = self.Info.Traits.Get(); + return aircraft.RearmBuildings.Contains( a.Info.Name ) + || aircraft.RepairBuildings.Contains( a.Info.Name ); + } + + public UnitMovementType GetMovementType() { return UnitMovementType.Fly; } + public bool CanEnterCell(int2 location) { return true; } + } +} diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index de39f8eb03..99e24922a6 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -42,16 +42,21 @@ namespace OpenRA.Mods.RA class CrateInfo : ITraitInfo, ITraitPrerequisite { public readonly int Lifetime = 5; // Seconds - public object Create(ActorInitializer init) { return new Crate(init.self); } + public object Create(ActorInitializer init) { return new Crate(init); } } class Crate : ICrushable, IOccupySpace, ITick { readonly Actor self; + [Sync] + readonly int2 location; + [Sync] int ticks; - public Crate(Actor self) + + public Crate(ActorInitializer init) { - this.self = self; + this.self = init.self; + this.location = init.location; self.World.WorldActor.traits.Get().Add(self, this); } @@ -75,7 +80,9 @@ namespace OpenRA.Mods.RA public bool IsPathableCrush(UnitMovementType umt, Player player) { return true; } public bool IsCrushableBy(UnitMovementType umt, Player player) { return true; } - public IEnumerable OccupiedCells() { yield return self.Location; } + public int2 TopLeft { get { return location; } } + + public IEnumerable OccupiedCells() { yield return TopLeft; } public void Tick(Actor self) { diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index 85de93c4b6..d27905f41e 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -71,7 +71,6 @@ namespace OpenRA.Mods.RA.Effects cargo.traits.Get().TeleportTo(cargo, loc); else { - cargo.Location = loc; cargo.CenterLocation = Traits.Util.CenterOfCell(loc); if (cargo.traits.Contains()) diff --git a/OpenRA.Mods.RA/Helicopter.cs b/OpenRA.Mods.RA/Helicopter.cs index d44b3c3092..2f4883c821 100644 --- a/OpenRA.Mods.RA/Helicopter.cs +++ b/OpenRA.Mods.RA/Helicopter.cs @@ -27,28 +27,19 @@ using OpenRA.Mods.RA.Activities; namespace OpenRA.Mods.RA { - class HelicopterInfo : ITraitInfo + class HelicopterInfo : AircraftInfo { - public readonly string[] RepairBuildings = { "fix" }; - public readonly string[] RearmBuildings = { "hpad" }; - public readonly int CruiseAltitude = 20; public readonly int IdealSeparation = 40; public readonly bool LandWhenIdle = true; - public object Create(ActorInitializer init) { return new Helicopter(init.self); } + public override object Create( ActorInitializer init ) { return new Helicopter( init ); } } - - class Helicopter : ITick, IIssueOrder, IResolveOrder, IMovement + + class Helicopter : Aircraft, IIssueOrder, IResolveOrder { public IDisposable reservation; - public Helicopter(Actor self) {} - static bool HeliCanEnter(Actor self, Actor a) - { - if (self.Info.Traits.Get().RearmBuildings.Contains(a.Info.Name)) return true; - if (self.Info.Traits.Get().RepairBuildings.Contains(a.Info.Name)) return true; - return false; - } + public Helicopter( ActorInitializer init ) : base( init ) { } public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { @@ -60,7 +51,7 @@ namespace OpenRA.Mods.RA return new Order("Move", self, xy); } - if (HeliCanEnter(self, underCursor) + if (AircraftCanEnter(self, underCursor) && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor); @@ -113,13 +104,13 @@ namespace OpenRA.Mods.RA var rawSpeed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly); var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, self.Info.Traits.Get().IdealSeparation) .Where(a => a.traits.Contains()); - + var f = otherHelis .Select(h => self.traits.Get().GetRepulseForce(self, h)) .Aggregate(float2.Zero, (a, b) => a + b); self.CenterLocation += rawSpeed * f; - self.Location = ((1 / 24f) * self.CenterLocation).ToInt2(); + Location = ((1 / 24f) * self.CenterLocation).ToInt2(); } const float Epsilon = .5f; @@ -135,9 +126,6 @@ namespace OpenRA.Mods.RA if (d.LengthSquared < Epsilon) return float2.FromAngle((float)self.World.SharedRandom.NextDouble() * 3.14f); return (5 / d.LengthSquared) * d; - } - - public UnitMovementType GetMovementType() { return UnitMovementType.Fly; } - public bool CanEnterCell(int2 location) { return true; } + } } } diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index d3ab58c686..a867399b97 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -8,18 +8,24 @@ namespace OpenRA.Mods.RA { class HuskInfo : ITraitInfo { - public object Create( ActorInitializer init ) { return new Husk( init.self ); } + public object Create( ActorInitializer init ) { return new Husk( init ); } } class Husk : IOccupySpace { Actor self; - public Husk(Actor self) + [Sync] + int2 location; + + public Husk(ActorInitializer init) { - this.self = self; + this.self = init.self; + this.location = init.location; self.World.WorldActor.traits.Get().Add(self, this); } - public IEnumerable OccupiedCells() { yield return self.Location; } + public int2 TopLeft { get { return location; } } + + public IEnumerable OccupiedCells() { yield return TopLeft; } } } diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index bd3b43b11c..6e3951cdb3 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -32,15 +32,19 @@ namespace OpenRA.Mods.RA public readonly string Weapon = "ATMine"; public readonly bool AvoidFriendly = true; - public object Create(ActorInitializer init) { return new Mine(init.self); } + public object Create(ActorInitializer init) { return new Mine(init); } } class Mine : ICrushable, IOccupySpace { readonly Actor self; - public Mine(Actor self) + [Sync] + readonly int2 location; + + public Mine(ActorInitializer init) { - this.self = self; + this.self = init.self; + this.location = init.location; self.World.WorldActor.traits.Get().Add(self, this); } @@ -64,7 +68,9 @@ namespace OpenRA.Mods.RA return self.Info.Traits.Get().TriggeredBy.Contains(umt); } - public IEnumerable OccupiedCells() { yield return self.Location; } + public int2 TopLeft { get { return location; } } + + public IEnumerable OccupiedCells() { yield return TopLeft; } } /* tag trait for stuff that shouldnt trigger mines */ diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 936581e439..6d73bc7a2c 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -69,6 +69,7 @@ + diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 509d8e7ab7..781cf34796 100755 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new OreRefinery(init.self, this); } } - class OreRefinery : ITick, IAcceptOre, INotifyDamage, INotifySold, INotifyCapture, IPips, ITraitPrerequisite + class OreRefinery : ITick, IAcceptOre, INotifyDamage, INotifySold, INotifyCapture, IPips { readonly Actor self; readonly OreRefineryInfo Info; diff --git a/OpenRA.Mods.RA/Plane.cs b/OpenRA.Mods.RA/Plane.cs index 2c5d3030df..7dbcd08996 100644 --- a/OpenRA.Mods.RA/Plane.cs +++ b/OpenRA.Mods.RA/Plane.cs @@ -27,23 +27,16 @@ using OpenRA.Mods.RA.Activities; namespace OpenRA.Mods.RA { - public class PlaneInfo : TraitInfo + public class PlaneInfo : AircraftInfo { - public readonly int CruiseAltitude = 20; - public readonly string[] RearmBuildings = { "afld" }; - public readonly string[] RepairBuildings = { "fix" }; + public override object Create( ActorInitializer init ) { return new Plane( init ); } } - public class Plane : IIssueOrder, IResolveOrder, IMovement + public class Plane : Aircraft, IIssueOrder, IResolveOrder { public IDisposable reservation; - static bool PlaneCanEnter(Actor self, Actor a) - { - var plane = self.Info.Traits.Get(); - return plane.RearmBuildings.Contains(a.Info.Name) - || plane.RepairBuildings.Contains(a.Info.Name); - } + public Plane( ActorInitializer init ) : base( init ) { } public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { @@ -52,7 +45,7 @@ namespace OpenRA.Mods.RA if (underCursor == null) return new Order("Move", self, xy); - if (PlaneCanEnter(self, underCursor) + if (AircraftCanEnter(self, underCursor) && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor); @@ -90,8 +83,5 @@ namespace OpenRA.Mods.RA ? (IActivity)new Rearm() : new Repair(order.TargetActor)); } } - - public UnitMovementType GetMovementType() { return UnitMovementType.Fly; } - public bool CanEnterCell(int2 location) { return true; } } } diff --git a/OpenRA.Mods.RA/RenderBuildingWall.cs b/OpenRA.Mods.RA/RenderBuildingWall.cs index 295bce182a..ae4c59ab87 100644 --- a/OpenRA.Mods.RA/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/RenderBuildingWall.cs @@ -110,19 +110,19 @@ namespace OpenRA.Mods.RA foreach (var w in adjWalls) { - w.traits.Get().AddAdjacentWall(w, self); - AddAdjacentWall(self, w); + w.traits.Get().AddAdjacentWall(w.Location, self.Location); + AddAdjacentWall(self.Location, w.Location); } hasTicked = true; } } - void AddAdjacentWall(Actor self, Actor other) + void AddAdjacentWall(int2 location, int2 otherLocation) { - if (other.Location == self.Location + new int2(0, -1)) adjacentWalls |= 1; - if (other.Location == self.Location + new int2(+1, 0)) adjacentWalls |= 2; - if (other.Location == self.Location + new int2(0, +1)) adjacentWalls |= 4; - if (other.Location == self.Location + new int2(-1, 0)) adjacentWalls |= 8; + if (otherLocation == location + new int2(0, -1)) adjacentWalls |= 1; + if (otherLocation == location + new int2(+1, 0)) adjacentWalls |= 2; + if (otherLocation == location + new int2(0, +1)) adjacentWalls |= 4; + if (otherLocation == location + new int2(-1, 0)) adjacentWalls |= 8; } } } diff --git a/OpenRA.Mods.RA/SpyPlanePower.cs b/OpenRA.Mods.RA/SpyPlanePower.cs index 732edf68a7..9d7e5e04a8 100644 --- a/OpenRA.Mods.RA/SpyPlanePower.cs +++ b/OpenRA.Mods.RA/SpyPlanePower.cs @@ -64,7 +64,6 @@ namespace OpenRA.Mods.RA plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation))); plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w => { - var camera = w.CreateActor("camera", order.TargetLocation, Owner); camera.QueueActivity(new Wait((int)(25 * 60 * (Info as SpyPlanePowerInfo).RevealTime))); camera.QueueActivity(new RemoveSelf()); diff --git a/OpenRA.Mods.RA/Wall.cs b/OpenRA.Mods.RA/Wall.cs index d59c07cbef..a85a08b7b3 100644 --- a/OpenRA.Mods.RA/Wall.cs +++ b/OpenRA.Mods.RA/Wall.cs @@ -32,17 +32,16 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new Wall(init.self); } } - public class Wall : ICrushable, IOccupySpace, IBlocksBullets + public class Wall : ICrushable, IBlocksBullets { readonly Actor self; + public Wall(Actor self) { this.self = self; - self.World.WorldActor.traits.Get().Add(self, this); + self.World.WorldActor.traits.Get().Add(self, self.traits.Get()); } - public IEnumerable OccupiedCells() { yield return self.Location; } - public void OnCrush(Actor crusher) { self.InflictDamage(crusher, self.Health, null); } public bool IsCrushableBy(UnitMovementType umt, Player player) { diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml index 620090a772..310595fc12 100644 --- a/mods/ra/defaults.yaml +++ b/mods/ra/defaults.yaml @@ -110,4 +110,4 @@ Priority: -1 HiddenUnderFog: RevealsShroud: - Burns: \ No newline at end of file + Burns: diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index 0be779e6aa..b075758125 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -345,6 +345,7 @@ CRATE: BelowUnits: CAMERA: + Aircraft: Unit: HP:1000 Sight: 10 diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml index 3c1eaed7e5..ebb5102caf 100644 --- a/mods/ra/vehicles.yaml +++ b/mods/ra/vehicles.yaml @@ -543,6 +543,7 @@ MIG: PrimaryWeapon: Maverick SecondaryWeapon: Maverick Plane: + RearmBuildings: afld RenderUnit: WithShadow: LimitedAmmo: @@ -572,6 +573,7 @@ YAK: PrimaryWeapon: ChainGun SecondaryWeapon: ChainGun Plane: + RearmBuildings: afld RenderUnit: WithShadow: LimitedAmmo: @@ -597,6 +599,7 @@ TRAN: Sight: 12 Speed: 12 Helicopter: + RearmBuildings: hpad RenderUnitRotor: PrimaryOffset: 0,14,0,-4 SecondaryOffset: 0,-14,0,-2 @@ -630,6 +633,7 @@ HELI: PrimaryOffset: -5,0,0,2 SecondaryOffset: 5,0,0,2 Helicopter: + RearmBuildings: hpad RenderUnitRotor: PrimaryOffset: 0,0,0,-2 WithShadow: @@ -660,6 +664,7 @@ HIND: PrimaryOffset: -5,0,0,2 SecondaryOffset: 5,0,0,2 Helicopter: + RearmBuildings: hpad RenderUnitRotor: WithShadow: LimitedAmmo: