Files
OpenRA/OpenRA.Mods.Common/Traits/ProximityCapturable.cs
let5sne.win10 9cf6ebb986
Some checks failed
Continuous Integration / Linux (.NET 8.0) (push) Has been cancelled
Continuous Integration / Windows (.NET 8.0) (push) Has been cancelled
Initial commit: OpenRA game engine
Fork from OpenRA/OpenRA with one-click launch script (start-ra.cmd)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 21:46:54 +08:00

58 lines
1.8 KiB
C#

#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* 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, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using OpenRA.Graphics;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Actor can be captured by units within a certain range.")]
public class ProximityCapturableInfo : ProximityCapturableBaseInfo
{
[Desc("Maximum range at which a " + nameof(ProximityCaptor) + " actor can initiate the capture.")]
public readonly WDist Range = WDist.FromCells(5);
public override object Create(ActorInitializer init) { return new ProximityCapturable(init, this); }
}
public class ProximityCapturable : ProximityCapturableBase
{
public new readonly ProximityCapturableInfo Info;
public ProximityCapturable(ActorInitializer init, ProximityCapturableInfo info)
: base(init, info)
{
Info = info;
}
protected override int CreateTrigger(Actor self)
{
return self.World.ActorMap.AddProximityTrigger(self.CenterPosition, Info.Range, WDist.Zero, ActorEntered, ActorLeft);
}
protected override void RemoveTrigger(Actor self, int trigger)
{
self.World.ActorMap.RemoveProximityTrigger(trigger);
}
protected override void TickInner(Actor self)
{
self.World.ActorMap.UpdateProximityTrigger(trigger, self.CenterPosition, Info.Range, WDist.Zero);
}
protected override IRenderable GetRenderable(Actor self, WorldRenderer wr)
{
return new RangeCircleAnnotationRenderable(self.CenterPosition, Info.Range, 0, self.Owner.Color, 1, Color.Black, 3);
}
}
}