Move Render*Circle, ThrowsParticle and ParatroopersPower to appropriate locations
This commit is contained in:
@@ -157,9 +157,7 @@
|
||||
<Compile Include="ProductionBar.cs" />
|
||||
<Compile Include="ProximityCaptor.cs" />
|
||||
<Compile Include="ProximityCapturable.cs" />
|
||||
<Compile Include="RenderDetectionCircle.cs" />
|
||||
<Compile Include="RenderJammerCircle.cs" />
|
||||
<Compile Include="RenderRangeCircle.cs" />
|
||||
<Compile Include="Traits\Render\RenderJammerCircle.cs" />
|
||||
<Compile Include="Render\RenderBuildingWarFactory.cs" />
|
||||
<Compile Include="Render\RenderHarvester.cs" />
|
||||
<Compile Include="Render\RenderDisguise.cs" />
|
||||
@@ -171,12 +169,11 @@
|
||||
<Compile Include="SupportPowers\AirstrikePower.cs" />
|
||||
<Compile Include="Traits\SupportPowers\ChronoshiftPower.cs" />
|
||||
<Compile Include="Traits\SupportPowers\GpsPower.cs" />
|
||||
<Compile Include="Traits\SupportPowers\ParatroopersPower.cs" />
|
||||
<Compile Include="SupportPowers\NukePower.cs" />
|
||||
<Compile Include="SupportPowers\ParatroopersPower.cs" />
|
||||
<Compile Include="SupportPowers\SupportPower.cs" />
|
||||
<Compile Include="SupportPowers\SupportPowerChargeBar.cs" />
|
||||
<Compile Include="SupportPowers\SupportPowerManager.cs" />
|
||||
<Compile Include="ThrowsParticle.cs" />
|
||||
<Compile Include="TraitsInterfaces.cs" />
|
||||
<Compile Include="Traits\Buildings\Bridge.cs" />
|
||||
<Compile Include="Traits\Buildings\BridgeHut.cs" />
|
||||
@@ -224,7 +221,7 @@
|
||||
<Compile Include="Widgets\WorldCommandWidget.cs" />
|
||||
<Compile Include="Player\BaseAttackNotifier.cs" />
|
||||
<Compile Include="Player\HarvesterAttackNotifier.cs" />
|
||||
<Compile Include="RenderShroudCircle.cs" />
|
||||
<Compile Include="Traits\Render\RenderShroudCircle.cs" />
|
||||
<Compile Include="Traits\Infiltration\InfiltrateForCash.cs" />
|
||||
<Compile Include="Traits\Infiltration\InfiltrateForExploration.cs" />
|
||||
<Compile Include="Traits\Infiltration\InfiltrateForPowerOutage.cs" />
|
||||
@@ -297,7 +294,6 @@
|
||||
<Compile Include="DisableUpgrade.cs" />
|
||||
<Compile Include="Warheads\GrantUpgradeWarhead.cs" />
|
||||
<Compile Include="UpgradeActorsNear.cs" />
|
||||
<Compile Include="WithRangeCircle.cs" />
|
||||
<Compile Include="Scripting\Properties\TransformProperties.cs" />
|
||||
<Compile Include="UtilityCommands\ActorStatsExport.cs" />
|
||||
<Compile Include="UtilityCommands\ExportCharacterSeparatedRules.cs" />
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#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 System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
class RenderDetectionCircleInfo : ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new RenderDetectionCircle(init.Self); }
|
||||
}
|
||||
|
||||
class RenderDetectionCircle : IPostRenderSelection
|
||||
{
|
||||
Actor self;
|
||||
|
||||
public RenderDetectionCircle(Actor self) { this.self = self; }
|
||||
|
||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
yield break;
|
||||
|
||||
yield return new RangeCircleRenderable(
|
||||
self.CenterPosition,
|
||||
WRange.FromCells(self.Info.Traits.Get<DetectCloakedInfo>().Range),
|
||||
0,
|
||||
Color.FromArgb(128, Color.LimeGreen),
|
||||
Color.FromArgb(96, Color.Black));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
#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 System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
[Desc("Draw a circle indicating my weapon's range.")]
|
||||
class RenderRangeCircleInfo : ITraitInfo, IPlaceBuildingDecoration, Requires<AttackBaseInfo>
|
||||
{
|
||||
public readonly string RangeCircleType = null;
|
||||
|
||||
[Desc("Range to draw if no armaments are available")]
|
||||
public readonly WRange FallbackRange = WRange.Zero;
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||
{
|
||||
var armaments = ai.Traits.WithInterface<ArmamentInfo>();
|
||||
var range = FallbackRange;
|
||||
|
||||
if (armaments.Any())
|
||||
range = armaments.Select(a => w.Map.Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max();
|
||||
|
||||
if (range == WRange.Zero)
|
||||
yield break;
|
||||
|
||||
yield return new RangeCircleRenderable(
|
||||
centerPosition,
|
||||
range,
|
||||
0,
|
||||
Color.FromArgb(128, Color.Yellow),
|
||||
Color.FromArgb(96, Color.Black));
|
||||
|
||||
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
|
||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
|
||||
foreach (var r in a.Trait.RenderAfterWorld(wr))
|
||||
yield return r;
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new RenderRangeCircle(init.Self); }
|
||||
}
|
||||
|
||||
class RenderRangeCircle : IPostRenderSelection
|
||||
{
|
||||
Actor self;
|
||||
AttackBase attack;
|
||||
|
||||
public RenderRangeCircle(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
attack = self.Trait<AttackBase>();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
yield break;
|
||||
|
||||
yield return new RangeCircleRenderable(
|
||||
self.CenterPosition,
|
||||
attack.GetMaximumRange(),
|
||||
0,
|
||||
Color.FromArgb(128, Color.Yellow),
|
||||
Color.FromArgb(96, Color.Black));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
#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;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
class ThrowsParticleInfo : ITraitInfo, Requires<RenderSimpleInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
public readonly string Anim = null;
|
||||
|
||||
[Desc("Initial position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
[Desc("Minimum distance to throw the particle")]
|
||||
public readonly WRange MinThrowRange = new WRange(256);
|
||||
|
||||
[Desc("Maximum distance to throw the particle")]
|
||||
public readonly WRange MaxThrowRange = new WRange(768);
|
||||
|
||||
[Desc("Minimum angle to throw the particle")]
|
||||
public readonly WAngle MinThrowAngle = WAngle.FromDegrees(30);
|
||||
|
||||
[Desc("Maximum angle to throw the particle")]
|
||||
public readonly WAngle MaxThrowAngle = WAngle.FromDegrees(60);
|
||||
|
||||
[Desc("Speed to throw the particle (horizontal WPos/tick)")]
|
||||
public readonly int Velocity = 75;
|
||||
|
||||
[Desc("Maximum rotation rate")]
|
||||
public readonly float ROT = 15;
|
||||
|
||||
public object Create(ActorInitializer init) { return new ThrowsParticle(init, this); }
|
||||
}
|
||||
|
||||
class ThrowsParticle : ITick
|
||||
{
|
||||
WVec pos;
|
||||
WVec initialPos;
|
||||
WVec finalPos;
|
||||
WAngle angle;
|
||||
|
||||
int tick = 0;
|
||||
int length;
|
||||
|
||||
float facing;
|
||||
float rotation;
|
||||
|
||||
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info)
|
||||
{
|
||||
var self = init.Self;
|
||||
var rs = self.Trait<RenderSimple>();
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
|
||||
// TODO: Carry orientation over from the parent instead of just facing
|
||||
var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 0;
|
||||
facing = Turreted.GetInitialTurretFacing(init, 0);
|
||||
|
||||
// Calculate final position
|
||||
var throwRotation = WRot.FromFacing(Game.CosmeticRandom.Next(1024));
|
||||
var throwDistance = Game.CosmeticRandom.Next(info.MinThrowRange.Range, info.MaxThrowRange.Range);
|
||||
|
||||
initialPos = pos = info.Offset.Rotate(body.QuantizeOrientation(self, WRot.FromFacing(bodyFacing)));
|
||||
finalPos = initialPos + new WVec(throwDistance, 0, 0).Rotate(throwRotation);
|
||||
angle = new WAngle(Game.CosmeticRandom.Next(info.MinThrowAngle.Angle, info.MaxThrowAngle.Angle));
|
||||
length = (finalPos - initialPos).Length / info.Velocity;
|
||||
|
||||
// Facing rotation
|
||||
rotation = WRange.FromPDF(Game.CosmeticRandom, 2).Range * info.ROT / 1024;
|
||||
|
||||
var anim = new Animation(init.World, rs.GetImage(self), () => (int)facing);
|
||||
anim.PlayRepeating(info.Anim);
|
||||
rs.Add(info.Anim, new AnimationWithOffset(anim, () => pos, null));
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (tick == length)
|
||||
return;
|
||||
|
||||
pos = WVec.LerpQuadratic(initialPos, finalPos, angle, tick++, length);
|
||||
|
||||
// Spin the particle
|
||||
facing += rotation;
|
||||
rotation *= .9f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#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 System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
[Desc("Renders an arbitrary circle when selected or placing a structure")]
|
||||
class WithRangeCircleInfo : ITraitInfo, IPlaceBuildingDecoration
|
||||
{
|
||||
[Desc("Type of range circle. used to decide which circles to draw on other structures during building placement.")]
|
||||
public readonly string Type = null;
|
||||
|
||||
[Desc("Color of the circle")]
|
||||
public readonly Color Color = Color.FromArgb(128, Color.White);
|
||||
|
||||
[Desc("Range of the circle")]
|
||||
public readonly WRange Range = WRange.Zero;
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||
{
|
||||
yield return new RangeCircleRenderable(
|
||||
centerPosition,
|
||||
Range,
|
||||
0,
|
||||
Color,
|
||||
Color.FromArgb(96, Color.Black));
|
||||
|
||||
foreach (var a in w.ActorsWithTrait<WithRangeCircle>())
|
||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer && a.Trait.Info.Type == Type)
|
||||
foreach (var r in a.Trait.RenderAfterWorld(wr))
|
||||
yield return r;
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithRangeCircle(init.Self, this); }
|
||||
}
|
||||
|
||||
class WithRangeCircle : IPostRenderSelection
|
||||
{
|
||||
public readonly WithRangeCircleInfo Info;
|
||||
readonly Actor self;
|
||||
|
||||
public WithRangeCircle(Actor self, WithRangeCircleInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
yield break;
|
||||
|
||||
yield return new RangeCircleRenderable(
|
||||
self.CenterPosition,
|
||||
Info.Range,
|
||||
0,
|
||||
Info.Color,
|
||||
Color.FromArgb(96, Color.Black));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user