moving Actor.Location onto the appropriate traits (bob)
This commit is contained in:
@@ -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<IOccupySpace>().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<IOccupySpace>() )
|
||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||
|
||||
Size = Lazy.New(() =>
|
||||
{
|
||||
var si = Info.Traits.GetOrDefault<SelectableInfo>();
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
||||
@@ -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<IDisable>().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<BuildingInfo>();
|
||||
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<int2> OccupiedCells()
|
||||
{
|
||||
return Footprint.UnpathableTiles( self.Info.Name, Info, TopLeft );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ using OpenRA.GameRules;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class MobileInfo : ITraitInfo, ITraitPrerequisite<Unit>
|
||||
public class MobileInfo : ITraitInfo, ITraitPrerequisite<UnitInfo>
|
||||
{
|
||||
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<UnitInfluence>().Remove(self, this); __fromCell = value; self.World.WorldActor.traits.Get<UnitInfluence>().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<UnitInfluence>().Remove(self, this);
|
||||
self.Location = value;
|
||||
}
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().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<UnitInfluence>().Remove(self, this);
|
||||
__fromCell = from;
|
||||
__toCell = to;
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().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<UnitInfluence>().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<int2> OccupiedCells()
|
||||
{
|
||||
return (fromCell == toCell)
|
||||
|
||||
@@ -61,8 +61,32 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
public interface IDisable { bool Disabled { get; } }
|
||||
|
||||
public interface IOccupySpace { IEnumerable<int2> OccupiedCells(); }
|
||||
|
||||
public interface IOccupySpace
|
||||
{
|
||||
int2 TopLeft { get; }
|
||||
IEnumerable<int2> 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<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r); }
|
||||
public interface IDamageModifier { float GetDamageModifier( WarheadInfo warhead ); }
|
||||
@@ -112,7 +136,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public class TraitInfo<T> : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } }
|
||||
|
||||
public interface ITraitPrerequisite<T> { }
|
||||
public interface ITraitPrerequisite<T> where T : ITraitInfo { }
|
||||
|
||||
public interface INotifySelection { void SelectionChanged(); }
|
||||
public interface ILoadWorldHook { void WorldLoaded(World w); }
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class TiberiumRefineryDockActionInfo : TraitInfo<TiberiumRefineryDockAction> {}
|
||||
|
||||
class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture, ITraitPrerequisite<IAcceptOre>
|
||||
class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture
|
||||
{
|
||||
Actor dockedHarv = null;
|
||||
bool preventDock = false;
|
||||
|
||||
@@ -68,9 +68,10 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var speed = .2f * Util.GetEffectiveSpeed(self, UnitMovementType.Fly);
|
||||
var angle = unit.Facing / 128f * Math.PI;
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
}
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var info = self.Info.Traits.Get<HelicopterInfo>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var aircraft = self.traits.Get<Aircraft>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
68
OpenRA.Mods.RA/Aircraft.cs
Executable file
68
OpenRA.Mods.RA/Aircraft.cs
Executable file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#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<int2> 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<AircraftInfo>();
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -42,16 +42,21 @@ namespace OpenRA.Mods.RA
|
||||
class CrateInfo : ITraitInfo, ITraitPrerequisite<RenderSimpleInfo>
|
||||
{
|
||||
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<UnitInfluence>().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<int2> OccupiedCells() { yield return self.Location; }
|
||||
public int2 TopLeft { get { return location; } }
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
|
||||
@@ -71,7 +71,6 @@ namespace OpenRA.Mods.RA.Effects
|
||||
cargo.traits.Get<Mobile>().TeleportTo(cargo, loc);
|
||||
else
|
||||
{
|
||||
cargo.Location = loc;
|
||||
cargo.CenterLocation = Traits.Util.CenterOfCell(loc);
|
||||
|
||||
if (cargo.traits.Contains<IOccupySpace>())
|
||||
|
||||
@@ -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<HelicopterInfo>().RearmBuildings.Contains(a.Info.Name)) return true;
|
||||
if (self.Info.Traits.Get<HelicopterInfo>().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<HelicopterInfo>().IdealSeparation)
|
||||
.Where(a => a.traits.Contains<Helicopter>());
|
||||
|
||||
|
||||
var f = otherHelis
|
||||
.Select(h => self.traits.Get<Helicopter>().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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UnitInfluence>().Add(self, this);
|
||||
}
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||
public int2 TopLeft { get { return location; } }
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UnitInfluence>().Add(self, this);
|
||||
}
|
||||
|
||||
@@ -64,7 +68,9 @@ namespace OpenRA.Mods.RA
|
||||
return self.Info.Traits.Get<MineInfo>().TriggeredBy.Contains(umt);
|
||||
}
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||
public int2 TopLeft { get { return location; } }
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
|
||||
}
|
||||
|
||||
/* tag trait for stuff that shouldnt trigger mines */
|
||||
|
||||
@@ -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">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -69,6 +69,7 @@
|
||||
<Compile Include="Activities\Teleport.cs" />
|
||||
<Compile Include="Activities\UnloadCargo.cs" />
|
||||
<Compile Include="Activities\Wait.cs" />
|
||||
<Compile Include="Aircraft.cs" />
|
||||
<Compile Include="AirstrikePower.cs" />
|
||||
<Compile Include="AttackFrontal.cs" />
|
||||
<Compile Include="AttackHeli.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<IAcceptOreDockAction>
|
||||
class OreRefinery : ITick, IAcceptOre, INotifyDamage, INotifySold, INotifyCapture, IPips
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly OreRefineryInfo Info;
|
||||
|
||||
@@ -27,23 +27,16 @@ using OpenRA.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class PlaneInfo : TraitInfo<Plane>
|
||||
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<PlaneInfo>();
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,19 +110,19 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
foreach (var w in adjWalls)
|
||||
{
|
||||
w.traits.Get<RenderBuildingWall>().AddAdjacentWall(w, self);
|
||||
AddAdjacentWall(self, w);
|
||||
w.traits.Get<RenderBuildingWall>().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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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<UnitInfluence>().Add(self, this);
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, self.traits.Get<Building>());
|
||||
}
|
||||
|
||||
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
|
||||
|
||||
public void OnCrush(Actor crusher) { self.InflictDamage(crusher, self.Health, null); }
|
||||
public bool IsCrushableBy(UnitMovementType umt, Player player)
|
||||
{
|
||||
|
||||
@@ -110,4 +110,4 @@
|
||||
Priority: -1
|
||||
HiddenUnderFog:
|
||||
RevealsShroud:
|
||||
Burns:
|
||||
Burns:
|
||||
|
||||
@@ -345,6 +345,7 @@ CRATE:
|
||||
BelowUnits:
|
||||
|
||||
CAMERA:
|
||||
Aircraft:
|
||||
Unit:
|
||||
HP:1000
|
||||
Sight: 10
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user