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>
This commit is contained in:
62
OpenRA.Mods.Common/Traits/World/BridgeLayer.cs
Normal file
62
OpenRA.Mods.Common/Traits/World/BridgeLayer.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
#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 System.Collections.Immutable;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
interface IBridgeSegment
|
||||
{
|
||||
void Repair(Actor repairer);
|
||||
void Demolish(Actor saboteur, BitSet<DamageType> damageTypes);
|
||||
|
||||
string Type { get; }
|
||||
DamageState DamageState { get; }
|
||||
ImmutableArray<CVec> NeighbourOffsets { get; }
|
||||
bool Valid { get; }
|
||||
CPos Location { get; }
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World)]
|
||||
sealed class BridgeLayerInfo : TraitInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new BridgeLayer(init.World); }
|
||||
}
|
||||
|
||||
sealed class BridgeLayer
|
||||
{
|
||||
readonly CellLayer<Actor> bridges;
|
||||
|
||||
public BridgeLayer(World world)
|
||||
{
|
||||
bridges = new CellLayer<Actor>(world.Map);
|
||||
}
|
||||
|
||||
public Actor this[CPos cell] => bridges[cell];
|
||||
|
||||
public void Add(Actor b)
|
||||
{
|
||||
var buildingInfo = b.Info.TraitInfo<BuildingInfo>();
|
||||
foreach (var c in buildingInfo.PathableTiles(b.Location))
|
||||
bridges[c] = b;
|
||||
}
|
||||
|
||||
public void Remove(Actor b)
|
||||
{
|
||||
var buildingInfo = b.Info.TraitInfo<BuildingInfo>();
|
||||
foreach (var c in buildingInfo.PathableTiles(b.Location))
|
||||
if (bridges[c] == b)
|
||||
bridges[c] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user