Update copyright header. Normalize line endings to LF.
This commit is contained in:
@@ -1,75 +1,75 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* 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 LICENSE.
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Effects;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class DrawLineToTargetInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Ticks = 60;
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(this); }
|
||||
}
|
||||
|
||||
public class DrawLineToTarget : IPostRenderSelection
|
||||
{
|
||||
DrawLineToTargetInfo Info;
|
||||
public DrawLineToTarget(DrawLineToTargetInfo info)
|
||||
{
|
||||
this.Info = info;
|
||||
}
|
||||
|
||||
Target target;
|
||||
int lifetime;
|
||||
Color c;
|
||||
|
||||
public void SetTarget(Actor self, Target target, Color c)
|
||||
{
|
||||
this.target = target;
|
||||
lifetime = Info.Ticks;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public void SetTargetSilently(Actor self, Target target, Color c)
|
||||
{
|
||||
this.target = target;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||
{
|
||||
if (self.IsIdle) return;
|
||||
|
||||
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
|
||||
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
||||
return;
|
||||
|
||||
if (!target.IsValid)
|
||||
return;
|
||||
|
||||
var p = target.CenterLocation;
|
||||
var move = self.TraitOrDefault<IMove>();
|
||||
var origin = move != null ? self.CenterLocation - new int2(0, move.Altitude) : self.CenterLocation;
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, p, c, c);
|
||||
for (bool b = false; !b; p = origin, b = true)
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(-1, -1), p + new float2(-1, 1), c, c);
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(-1, 1), p + new float2(1, 1), c, c);
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(1, 1), p + new float2(1, -1), c, c);
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(1, -1), p + new float2(-1, -1), c, c);
|
||||
}
|
||||
}
|
||||
using OpenRA.Effects;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public class DrawLineToTargetInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Ticks = 60;
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(this); }
|
||||
}
|
||||
|
||||
public class DrawLineToTarget : IPostRenderSelection
|
||||
{
|
||||
DrawLineToTargetInfo Info;
|
||||
public DrawLineToTarget(DrawLineToTargetInfo info)
|
||||
{
|
||||
this.Info = info;
|
||||
}
|
||||
|
||||
Target target;
|
||||
int lifetime;
|
||||
Color c;
|
||||
|
||||
public void SetTarget(Actor self, Target target, Color c)
|
||||
{
|
||||
this.target = target;
|
||||
lifetime = Info.Ticks;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public void SetTargetSilently(Actor self, Target target, Color c)
|
||||
{
|
||||
this.target = target;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||
{
|
||||
if (self.IsIdle) return;
|
||||
|
||||
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
|
||||
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
||||
return;
|
||||
|
||||
if (!target.IsValid)
|
||||
return;
|
||||
|
||||
var p = target.CenterLocation;
|
||||
var move = self.TraitOrDefault<IMove>();
|
||||
var origin = move != null ? self.CenterLocation - new int2(0, move.Altitude) : self.CenterLocation;
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, p, c, c);
|
||||
for (bool b = false; !b; p = origin, b = true)
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(-1, -1), p + new float2(-1, 1), c, c);
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(-1, 1), p + new float2(1, 1), c, c);
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(1, 1), p + new float2(1, -1), c, c);
|
||||
Game.Renderer.LineRenderer.DrawLine(p + new float2(1, -1), p + new float2(-1, -1), c, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LineTargetExts
|
||||
@@ -98,6 +98,6 @@ namespace OpenRA.Traits
|
||||
line.SetTargetSilently(self, target, color);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user