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:
64
OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs
Normal file
64
OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
#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.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Radar
|
||||
{
|
||||
[Desc("Provides a signature on the minimap.")]
|
||||
public class AppearsOnRadarInfo : ConditionalTraitInfo
|
||||
{
|
||||
[Desc("Use center position instead of occupied cells.")]
|
||||
public readonly bool UseLocation = false;
|
||||
|
||||
[Desc("Player relationships who can view this actor on radar.")]
|
||||
public readonly PlayerRelationship ValidRelationships = PlayerRelationship.Ally | PlayerRelationship.Neutral | PlayerRelationship.Enemy;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AppearsOnRadar(this); }
|
||||
}
|
||||
|
||||
public class AppearsOnRadar : ConditionalTrait<AppearsOnRadarInfo>, IRadarSignature
|
||||
{
|
||||
IRadarColorModifier modifier;
|
||||
|
||||
public AppearsOnRadar(AppearsOnRadarInfo info)
|
||||
: base(info) { }
|
||||
|
||||
protected override void Created(Actor self)
|
||||
{
|
||||
base.Created(self);
|
||||
modifier = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer)
|
||||
{
|
||||
var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer;
|
||||
if (IsTraitDisabled || (viewer != null && !Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(viewer))))
|
||||
return;
|
||||
|
||||
var color = self.OwnerColor();
|
||||
if (modifier != null)
|
||||
color = modifier.RadarColorOverride(self, color);
|
||||
|
||||
if (Info.UseLocation)
|
||||
{
|
||||
destinationBuffer.Add((self.Location, color));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var cell in self.OccupiesSpace.OccupiedCells())
|
||||
destinationBuffer.Add((cell.Cell, color));
|
||||
}
|
||||
}
|
||||
}
|
||||
25
OpenRA.Mods.Common/Traits/Radar/ProvidesRadar.cs
Normal file
25
OpenRA.Mods.Common/Traits/Radar/ProvidesRadar.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
#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
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Radar
|
||||
{
|
||||
[Desc("This actor enables the radar minimap.")]
|
||||
public class ProvidesRadarInfo : ConditionalTraitInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new ProvidesRadar(this); }
|
||||
}
|
||||
|
||||
public class ProvidesRadar : ConditionalTrait<ProvidesRadarInfo>
|
||||
{
|
||||
public ProvidesRadar(ProvidesRadarInfo info)
|
||||
: base(info) { }
|
||||
}
|
||||
}
|
||||
42
OpenRA.Mods.Common/Traits/Radar/RadarColorFromTerrain.cs
Normal file
42
OpenRA.Mods.Common/Traits/Radar/RadarColorFromTerrain.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#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.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Radar
|
||||
{
|
||||
public class RadarColorFromTerrainInfo : TraitInfo
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
public readonly string Terrain;
|
||||
|
||||
public Color GetColorFromTerrain(World world)
|
||||
{
|
||||
var terrainInfo = world.Map.Rules.TerrainInfo;
|
||||
return terrainInfo.TerrainTypes[terrainInfo.GetTerrainIndex(Terrain)].Color;
|
||||
}
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RadarColorFromTerrain(init.Self, this); }
|
||||
}
|
||||
|
||||
public class RadarColorFromTerrain : IRadarColorModifier
|
||||
{
|
||||
readonly Color c;
|
||||
|
||||
public RadarColorFromTerrain(Actor self, RadarColorFromTerrainInfo info)
|
||||
{
|
||||
c = info.GetColorFromTerrain(self.World);
|
||||
}
|
||||
|
||||
public Color RadarColorOverride(Actor self, Color color) { return c; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user