Move Burns from RA to Common, move RallyPoint to Traits folder
This commit is contained in:
51
OpenRA.Mods.Common/Traits/Burns.cs
Normal file
51
OpenRA.Mods.Common/Traits/Burns.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
[Desc("This actor will play a fire animation over its body and take damage over time.")]
|
||||
class BurnsInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
public readonly string Anim = "1";
|
||||
public readonly int Damage = 1;
|
||||
public readonly int Interval = 8;
|
||||
|
||||
public object Create(ActorInitializer init) { return new Burns(init.self, this); }
|
||||
}
|
||||
|
||||
class Burns : ITick, ISync
|
||||
{
|
||||
[Sync] int ticks;
|
||||
BurnsInfo Info;
|
||||
|
||||
public Burns(Actor self, BurnsInfo info)
|
||||
{
|
||||
Info = info;
|
||||
|
||||
var anim = new Animation(self.World, "fire", () => 0);
|
||||
anim.IsDecoration = true;
|
||||
anim.PlayRepeating(Info.Anim);
|
||||
self.Trait<RenderSprites>().Add("fire", anim);
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (--ticks <= 0)
|
||||
{
|
||||
self.InflictDamage(self, Info.Damage, null);
|
||||
ticks = Info.Interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
77
OpenRA.Mods.Common/Traits/RallyPoint.cs
Normal file
77
OpenRA.Mods.Common/Traits/RallyPoint.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
[Desc("Used to waypoint units after production or repair is finished.")]
|
||||
public class RallyPointInfo : ITraitInfo
|
||||
{
|
||||
public readonly CVec RallyPoint = new CVec(1, 3);
|
||||
public readonly string IndicatorPalettePrefix = "player";
|
||||
|
||||
public object Create(ActorInitializer init) { return new RallyPoint(init.self, this); }
|
||||
}
|
||||
|
||||
public class RallyPoint : IIssueOrder, IResolveOrder, ISync
|
||||
{
|
||||
[Sync] public CPos Location;
|
||||
|
||||
public RallyPoint(Actor self, RallyPointInfo info)
|
||||
{
|
||||
Location = self.Location + info.RallyPoint;
|
||||
self.World.AddFrameEndTask(w => w.Add(new Effects.RallyPoint(self, info.IndicatorPalettePrefix)));
|
||||
}
|
||||
|
||||
public IEnumerable<IOrderTargeter> Orders
|
||||
{
|
||||
get { yield return new RallyPointOrderTargeter(); }
|
||||
}
|
||||
|
||||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
||||
{
|
||||
if (order.OrderID == "SetRallyPoint")
|
||||
return new Order(order.OrderID, self, false) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition), SuppressVisualFeedback = true };
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "SetRallyPoint")
|
||||
Location = order.TargetLocation;
|
||||
}
|
||||
|
||||
class RallyPointOrderTargeter : IOrderTargeter
|
||||
{
|
||||
public string OrderID { get { return "SetRallyPoint"; } }
|
||||
public int OrderPriority { get { return 0; } }
|
||||
|
||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Terrain)
|
||||
return false;
|
||||
|
||||
var location = self.World.Map.CellContaining(target.CenterPosition);
|
||||
if (self.World.Map.Contains(location))
|
||||
{
|
||||
cursor = "ability";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsQueued { get { return false; } } // unused
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user