tidy in OreRefinery, Harvester, CncLobbyLogic, ScaredyCat

This commit is contained in:
Chris Forbes
2011-10-29 17:39:58 +13:00
parent 268f06caf0
commit 9279161de6
29 changed files with 128 additions and 165 deletions

View File

@@ -221,7 +221,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var font = Game.Renderer.Fonts[nameLabel.Font]; var font = Game.Renderer.Fonts[nameLabel.Font];
var nameSize = font.Measure(from); var nameSize = font.Measure(from);
var time = System.DateTime.Now; var time = DateTime.Now;
timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute); timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);
nameLabel.GetColor = () => c; nameLabel.GetColor = () => c;
@@ -233,11 +233,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
// Hack around our hacky wordwrap behavior: need to resize the widget to fit the text // Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
text = WidgetUtils.WrapText(text, textLabel.Bounds.Width, font); text = WidgetUtils.WrapText(text, textLabel.Bounds.Width, font);
textLabel.GetText = () => text; textLabel.GetText = () => text;
var oldHeight = textLabel.Bounds.Height; var dh = font.Measure(text).Y - textLabel.Bounds.Height;
textLabel.Bounds.Height = font.Measure(text).Y;
var dh = textLabel.Bounds.Height - oldHeight;
if (dh > 0) if (dh > 0)
{
textLabel.Bounds.Height += dh;
template.Bounds.Height += dh; template.Bounds.Height += dh;
}
chatPanel.AddChild(template); chatPanel.AddChild(template);
chatPanel.ScrollToBottom(); chatPanel.ScrollToBottom();

View File

@@ -34,28 +34,19 @@ namespace OpenRA.Mods.RA
{ {
Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>(); Dictionary<ResourceTypeInfo, int> contents = new Dictionary<ResourceTypeInfo, int>();
[Sync] [Sync] public Actor LinkedProc = null;
public Actor LinkedProc = null; [Sync] int currentUnloadTicks;
public int2? LastHarvestedCell = null; public int2? LastHarvestedCell = null;
[Sync] public int ContentValue { get { return contents.Sum(c => c.Key.ValuePerUnit*c.Value); } }
[Sync]
public int ContentValue { get { return contents.Sum(c => c.Key.ValuePerUnit*c.Value); } }
[Sync]
int currentUnloadTicks;
readonly HarvesterInfo Info; readonly HarvesterInfo Info;
public Harvester(Actor self, HarvesterInfo info) public Harvester(Actor self, HarvesterInfo info)
{ {
Info = info; Info = info;
self.QueueActivity( new CallFunc( () => ChooseNewProc(self, null))); self.QueueActivity( new CallFunc( () => ChooseNewProc(self, null)));
} }
public void ChooseNewProc(Actor self, Actor ignore) public void ChooseNewProc(Actor self, Actor ignore) { LinkedProc = ClosestProc(self, ignore); }
{
LinkedProc = ClosestProc(self, ignore);
}
public void ContinueHarvesting(Actor self) public void ContinueHarvesting(Actor self)
{ {
@@ -78,7 +69,9 @@ namespace OpenRA.Mods.RA
PathSearch.FromPoints(self.World, mi, self.Owner, PathSearch.FromPoints(self.World, mi, self.Owner,
refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset), refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset),
self.Location, false)); self.Location, false));
path.Reverse(); path.Reverse();
if (path.Count != 0) if (path.Count != 0)
return refs.Where(x => x.Actor.Location + x.Trait.DeliverOffset == path[0]) return refs.Where(x => x.Actor.Location + x.Trait.DeliverOffset == path[0])
.Select(a => a.Actor).FirstOrDefault(); .Select(a => a.Actor).FirstOrDefault();
@@ -182,10 +175,8 @@ namespace OpenRA.Mods.RA
public void UnlinkProc(Actor self, Actor proc) public void UnlinkProc(Actor self, Actor proc)
{ {
if (LinkedProc != proc) if (LinkedProc == proc)
return; ChooseNewProc(self, proc);
ChooseNewProc(self, proc);
} }
PipType GetPipAt(int i) PipType GetPipAt(int i)
@@ -218,8 +209,9 @@ namespace OpenRA.Mods.RA
class HarvestOrderTargeter : IOrderTargeter class HarvestOrderTargeter : IOrderTargeter
{ {
public string OrderID { get { return "Harvest";}} public string OrderID { get { return "Harvest"; } }
public int OrderPriority { get { return 10; } } public int OrderPriority { get { return 10; } }
public bool IsQueued { get; protected set; }
public bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor) public bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
{ {
@@ -241,7 +233,6 @@ namespace OpenRA.Mods.RA
return true; return true;
} }
public bool IsQueued { get; protected set; }
} }
} }
} }

View File

@@ -363,6 +363,7 @@
<Compile Include="Widgets\Logic\DownloadPackagesLogic.cs" /> <Compile Include="Widgets\Logic\DownloadPackagesLogic.cs" />
<Compile Include="AI\BaseBuilder.cs" /> <Compile Include="AI\BaseBuilder.cs" />
<Compile Include="AI\HackyAI.cs" /> <Compile Include="AI\HackyAI.cs" />
<Compile Include="Render\RenderInfantryPanic.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -19,9 +19,7 @@ namespace OpenRA.Mods.RA
{ {
public class OreRefineryInfo : ITraitInfo public class OreRefineryInfo : ITraitInfo
{ {
public readonly int PipCount = 0; public readonly int2 DockOffset = new int2(1, 2);
public readonly PipType PipColor = PipType.Red;
public readonly int2 DockOffset = new int2 (1, 2);
public readonly bool ShowTicks = true; public readonly bool ShowTicks = true;
public readonly int TickLifetime = 30; public readonly int TickLifetime = 30;
@@ -40,20 +38,14 @@ namespace OpenRA.Mods.RA
int currentDisplayTick = 0; int currentDisplayTick = 0;
int currentDisplayValue = 0; int currentDisplayValue = 0;
[Sync] [Sync] public int Ore = 0;
public int Ore = 0; [Sync] Actor dockedHarv = null;
[Sync] bool preventDock = false;
[Sync]
Actor dockedHarv = null;
[Sync]
bool preventDock = false;
public bool AllowDocking { get { return !preventDock; } } public bool AllowDocking { get { return !preventDock; } }
public int2 DeliverOffset { get { return Info.DockOffset; } } public int2 DeliverOffset { get { return Info.DockOffset; } }
public virtual Activity DockSequence(Actor harv, Actor self)
{ public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self); }
return new RAHarvesterDockSequence(harv, self);
}
public OreRefinery(Actor self, OreRefineryInfo info) public OreRefinery(Actor self, OreRefineryInfo info)
{ {
@@ -69,10 +61,7 @@ namespace OpenRA.Mods.RA
.Where(a => a.Trait.LinkedProc == self); .Where(a => a.Trait.LinkedProc == self);
} }
public bool CanGiveOre(int amount) public bool CanGiveOre(int amount) { return PlayerResources.CanGiveOre(amount); }
{
return PlayerResources.CanGiveOre(amount);
}
public void GiveOre(int amount) public void GiveOre(int amount)
{ {

View File

@@ -8,10 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA

View File

@@ -10,8 +10,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Traits;
using OpenRA.Mods.RA.Orders; using OpenRA.Mods.RA.Orders;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Network; using OpenRA.Network;

View File

@@ -22,15 +22,13 @@ namespace OpenRA.Mods.RA
public class RadarColorFromTerrain : IRadarColorModifier public class RadarColorFromTerrain : IRadarColorModifier
{ {
Color c; Color c;
public RadarColorFromTerrain(Actor self, string terrain) public RadarColorFromTerrain(Actor self, string terrain)
{ {
c = self.World.TileSet.Terrain[terrain].Color; c = self.World.TileSet.Terrain[terrain].Color;
} }
public bool VisibleOnRadar(Actor self) { return true; } public bool VisibleOnRadar(Actor self) { return true; }
public Color RadarColorOverride(Actor self) public Color RadarColorOverride(Actor self) { return c; }
{
return c;
}
} }
} }

View File

@@ -9,10 +9,8 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -25,8 +23,7 @@ namespace OpenRA.Mods.RA
public class RallyPoint : IIssueOrder, IResolveOrder, ISync public class RallyPoint : IIssueOrder, IResolveOrder, ISync
{ {
[Sync] [Sync] public int2 rallyPoint;
public int2 rallyPoint;
public RallyPoint(Actor self) public RallyPoint(Actor self)
{ {

View File

@@ -22,8 +22,7 @@ namespace OpenRA.Mods.RA
public class Reloads : ITick public class Reloads : ITick
{ {
[Sync] [Sync] int remainingTicks;
int remainingTicks;
ReloadsInfo Info; ReloadsInfo Info;
LimitedAmmo la; LimitedAmmo la;

View File

@@ -0,0 +1,56 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
class RenderInfantryPanicInfo : RenderInfantryInfo, Requires<ScaredyCatInfo>
{
public override object Create(ActorInitializer init) { return new RenderInfantryPanic(init.self, this); }
}
class RenderInfantryPanic : RenderInfantry
{
readonly ScaredyCat sc;
bool wasPanic;
public RenderInfantryPanic(Actor self, RenderInfantryPanicInfo info)
: base(self, info)
{
sc = self.Trait<ScaredyCat>();
}
protected override string NormalizeInfantrySequence(Actor self, string baseSequence)
{
var prefix = sc != null && sc.Panicked ? "panic-" : "";
if (anim.HasSequence(prefix + baseSequence))
return prefix + baseSequence;
else
return baseSequence;
}
protected override bool AllowIdleAnimation(Actor self)
{
return base.AllowIdleAnimation(self) && !sc.Panicked;
}
public override void Tick (Actor self)
{
if (wasPanic != sc.Panicked)
dirty = true;
wasPanic = sc.Panicked;
base.Tick(self);
}
}
}

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Drawing; using System.Drawing;
using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;

View File

@@ -21,8 +21,7 @@ namespace OpenRA.Mods.RA
{ {
class RepairableNearInfo : ITraitInfo, Requires<HealthInfo> class RepairableNearInfo : ITraitInfo, Requires<HealthInfo>
{ {
[ActorReference] [ActorReference] public readonly string[] Buildings = { "spen", "syrd" };
public readonly string[] Buildings = { "spen", "syrd" };
public object Create( ActorInitializer init ) { return new RepairableNear( init.self ); } public object Create( ActorInitializer init ) { return new RepairableNear( init.self ); }
} }

View File

@@ -9,8 +9,8 @@
#endregion #endregion
using System; using System;
using OpenRA.Traits;
using OpenRA.Mods.RA.Air; using OpenRA.Mods.RA.Air;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
@@ -25,64 +24,17 @@ namespace OpenRA.Mods.RA
{ {
readonly ScaredyCatInfo Info; readonly ScaredyCatInfo Info;
public bool Panicked = false; public bool Panicked = false;
public ScaredyCat(Actor self, ScaredyCatInfo info)
{ public ScaredyCat(Actor self, ScaredyCatInfo info) { Info = info; }
Info = info;
}
public void TickIdle(Actor self) public void TickIdle(Actor self)
{ {
if (!Panicked) if (!Panicked) return;
return;
var target = Util.SubPxVector[self.World.SharedRandom.Next(255)]* Info.MoveRadius / 1024 + self.Location; var target = Util.SubPxVector[self.World.SharedRandom.Next(255)]* Info.MoveRadius / 1024 + self.Location;
self.Trait<Mobile>().ResolveOrder(self, new Order("Move", self, false) { TargetLocation = target }); self.Trait<Mobile>().ResolveOrder(self, new Order("Move", self, false) { TargetLocation = target });
} }
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e) { Panicked = true; }
{
Panicked = true;
}
}
class RenderInfantryPanicInfo : RenderInfantryInfo, Requires<ScaredyCatInfo>
{
public override object Create(ActorInitializer init) { return new RenderInfantryPanic(init.self, this); }
}
class RenderInfantryPanic : RenderInfantry
{
readonly ScaredyCat sc;
bool wasPanic;
public RenderInfantryPanic(Actor self, RenderInfantryPanicInfo info)
: base(self, info)
{
sc = self.Trait<ScaredyCat>();
}
protected override string NormalizeInfantrySequence(Actor self, string baseSequence)
{
var prefix = sc != null && sc.Panicked ? "panic-" : "";
if (anim.HasSequence(prefix + baseSequence))
return prefix + baseSequence;
else
return baseSequence;
}
protected override bool AllowIdleAnimation(Actor self)
{
return base.AllowIdleAnimation(self) && !sc.Panicked;
}
public override void Tick (Actor self)
{
if (wasPanic != sc.Panicked)
dirty = true;
wasPanic = sc.Panicked;
base.Tick(self);
}
} }
} }

View File

@@ -8,12 +8,9 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic;
using OpenRA.Orders;
using OpenRA.Traits;
using OpenRA.Mods.RA.Render;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -25,6 +22,7 @@ namespace OpenRA.Mods.RA
class Sellable : IResolveOrder class Sellable : IResolveOrder
{ {
bool selling = false; bool selling = false;
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Sell" && !selling) if (order.OrderString == "Sell" && !selling)

View File

@@ -10,8 +10,8 @@
using System.Drawing; using System.Drawing;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Traits;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -25,10 +25,8 @@ namespace OpenRA.Mods.RA
class ShroudPalette : IPalette class ShroudPalette : IPalette
{ {
readonly ShroudPaletteInfo info; readonly ShroudPaletteInfo info;
public ShroudPalette( ShroudPaletteInfo info )
{ public ShroudPalette( ShroudPaletteInfo info ) { this.info = info; }
this.info = info;
}
public void InitPalette( WorldRenderer wr ) public void InitPalette( WorldRenderer wr )
{ {

View File

@@ -9,8 +9,8 @@
#endregion #endregion
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits;
using OpenRA.Mods.RA.Render; using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -18,19 +18,19 @@ namespace OpenRA.Mods.RA
class TargetableBuildingInfo : ITraitInfo, Requires<BuildingInfo> class TargetableBuildingInfo : ITraitInfo, Requires<BuildingInfo>
{ {
public readonly string[] TargetTypes = { }; public readonly string[] TargetTypes = { };
public object Create( ActorInitializer init ) { return new TargetableBuilding( this ); } public object Create( ActorInitializer init ) { return new TargetableBuilding( this ); }
} }
class TargetableBuilding : ITargetable class TargetableBuilding : ITargetable
{ {
readonly TargetableBuildingInfo info; readonly TargetableBuildingInfo info;
public TargetableBuilding( TargetableBuildingInfo info )
{ public TargetableBuilding( TargetableBuildingInfo info ) { this.info = info; }
this.info = info;
}
public string[] TargetTypes { get { return info.TargetTypes; } } public string[] TargetTypes { get { return info.TargetTypes; } }
public bool TargetableBy(Actor self, Actor byActor) { return true; } public bool TargetableBy(Actor self, Actor byActor) { return true; }
public IEnumerable<int2> TargetableCells( Actor self ) public IEnumerable<int2> TargetableCells( Actor self )
{ {
return self.Trait<Building>().OccupiedCells().Select(c => c.First); return self.Trait<Building>().OccupiedCells().Select(c => c.First);

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.RA
public class TargetableSubmarineInfo : TargetableUnitInfo, Requires<CloakInfo> public class TargetableSubmarineInfo : TargetableUnitInfo, Requires<CloakInfo>
{ {
public readonly string[] CloakedTargetTypes = {}; public readonly string[] CloakedTargetTypes = {};
public override object Create( ActorInitializer init ) { return new TargetableSubmarine(init.self, this); } public override object Create( ActorInitializer init ) { return new TargetableSubmarine(init.self, this); }
} }
@@ -26,8 +27,8 @@ namespace OpenRA.Mods.RA
public override string[] TargetTypes public override string[] TargetTypes
{ {
get { return (Cloak.Cloaked) ? info.CloakedTargetTypes get { return Cloak.Cloaked ? info.CloakedTargetTypes
: info.TargetTypes;} : info.TargetTypes;}
} }
} }
} }

View File

@@ -8,10 +8,8 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA

View File

@@ -8,19 +8,16 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class TransformOnCaptureInfo : ITraitInfo class TransformOnCaptureInfo : ITraitInfo
{ {
[ActorReference] [ActorReference] public readonly string IntoActor = null;
public readonly string IntoActor = null;
public readonly int ForceHealthPercentage = 0; public readonly int ForceHealthPercentage = 0;
public virtual object Create(ActorInitializer init) { return new TransformOnCapture(this); } public virtual object Create(ActorInitializer init) { return new TransformOnCapture(this); }
} }
@@ -28,14 +25,14 @@ namespace OpenRA.Mods.RA
{ {
TransformOnCaptureInfo Info; TransformOnCaptureInfo Info;
public TransformOnCapture(TransformOnCaptureInfo info) public TransformOnCapture(TransformOnCaptureInfo info) { Info = info; }
{
Info = info;
}
public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner) public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
{ {
self.QueueActivity(new Transform(self, Info.IntoActor) {ForceHealthPercentage = Info.ForceHealthPercentage, Facing = self.Trait<IFacing>().Facing}); self.QueueActivity(new Transform(self, Info.IntoActor) {
ForceHealthPercentage = Info.ForceHealthPercentage,
Facing = self.Trait<IFacing>().Facing
});
} }
} }
} }

View File

@@ -10,8 +10,6 @@
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Render;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -12,15 +12,14 @@ using System.Collections.Generic;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders; using OpenRA.Mods.RA.Orders;
using OpenRA.Traits;
using OpenRA.Mods.RA.Render; using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class TransformsInfo : ITraitInfo class TransformsInfo : ITraitInfo
{ {
[ActorReference] [ActorReference] public readonly string IntoActor = null;
public readonly string IntoActor = null;
public readonly int2 Offset = int2.Zero; public readonly int2 Offset = int2.Zero;
public readonly int Facing = 96; public readonly int Facing = 96;
public readonly string[] TransformSounds = {}; public readonly string[] TransformSounds = {};

View File

@@ -45,13 +45,13 @@ namespace OpenRA.Mods.RA
facing = init.self.TraitOrDefault<IFacing>(); facing = init.self.TraitOrDefault<IFacing>();
} }
public void Tick( Actor self ) public void Tick(Actor self)
{ {
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing ); var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
turretFacing = Util.TickFacing(turretFacing, df, info.ROT); turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
} }
public bool FaceTarget( Actor self, Target target ) public bool FaceTarget(Actor self, Target target)
{ {
desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turretFacing ); desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turretFacing );
return turretFacing == desiredFacing; return turretFacing == desiredFacing;

View File

@@ -17,16 +17,16 @@ namespace OpenRA.Mods.RA
public readonly int Cost = 0; public readonly int Cost = 0;
} }
public class Valued { }
public class TooltipInfo : ITraitInfo public class TooltipInfo : ITraitInfo
{ {
public readonly string Description = ""; public readonly string Description = "";
public readonly string Name = ""; public readonly string Name = "";
public readonly string Icon = null; public readonly string Icon = null;
public virtual object Create (ActorInitializer init) { return new Tooltip(init.self, this); } public virtual object Create(ActorInitializer init) { return new Tooltip(init.self, this); }
} }
public class Valued { }
public class Tooltip : IToolTip public class Tooltip : IToolTip
{ {
@@ -34,12 +34,10 @@ namespace OpenRA.Mods.RA
TooltipInfo Info; TooltipInfo Info;
public string Name() { return Info.Name; } public string Name() { return Info.Name; }
public Player Owner() { return self.Owner; } public Player Owner() { return self.Owner; }
public Stance Stance() { return self.World.LocalPlayer.Stances[self.Owner]; } public Stance Stance() { return self.World.LocalPlayer.Stances[self.Owner]; }
public Tooltip( Actor self, TooltipInfo info ) public Tooltip(Actor self, TooltipInfo info)
{ {
this.self = self; this.self = self;
Info = info; Info = info;

View File

@@ -16,6 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class WaterPaletteRotationInfo : TraitInfo<WaterPaletteRotation> {} class WaterPaletteRotationInfo : TraitInfo<WaterPaletteRotation> {}
class WaterPaletteRotation : ITick, IPaletteModifier class WaterPaletteRotation : ITick, IPaletteModifier
{ {
float t = 0; float t = 0;

View File

@@ -110,15 +110,14 @@ namespace OpenRA.Mods.RA
if (limitedAmmo != null && !limitedAmmo.HasAmmo()) if (limitedAmmo != null && !limitedAmmo.HasAmmo())
return; return;
if( !Combat.IsInRange( self.CenterLocation, Info.Range, target ) ) if (!Combat.IsInRange(self.CenterLocation, Info.Range, target)) return;
return; if (Combat.IsInRange(self.CenterLocation, Info.MinRange, target)) return;
if( Combat.IsInRange( self.CenterLocation, Info.MinRange, target ) )
return;
if (!IsValidAgainst(self.World, target)) return; if (!IsValidAgainst(self.World, target)) return;
var barrel = Barrels[Burst % Barrels.Length]; var barrel = Barrels[Burst % Barrels.Length];
var destMove = target.IsActor ? target.Actor.TraitOrDefault<IMove>() : null; var destMove = target.IsActor ? target.Actor.TraitOrDefault<IMove>() : null;
var turreted = self.TraitOrDefault<Turreted>();
var args = new ProjectileArgs var args = new ProjectileArgs
{ {
@@ -134,7 +133,7 @@ namespace OpenRA.Mods.RA
destAltitude = destMove != null ? destMove.Altitude : 0, destAltitude = destMove != null ? destMove.Altitude : 0,
facing = barrel.Facing + facing = barrel.Facing +
(self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : (turreted != null ? turreted.turretFacing :
facing != null ? facing.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0)), facing != null ? facing.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0)),
firepowerModifier = self.TraitsImplementing<IFirepowerModifier>() firepowerModifier = self.TraitsImplementing<IFirepowerModifier>()