add support power charge bar
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
<Compile Include="Buildings\TechTree.cs" />
|
||||
<Compile Include="Buildings\Util.cs" />
|
||||
<Compile Include="ProximityCaptor.cs" />
|
||||
<Compile Include="SupportPowers\SupportPowerChargeBar.cs" />
|
||||
<Compile Include="Valued.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Player\SurrenderOnDisconnect.cs" />
|
||||
|
||||
43
OpenRA.Mods.RA/SupportPowers/SupportPowerChargeBar.cs
Normal file
43
OpenRA.Mods.RA/SupportPowers/SupportPowerChargeBar.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class SupportPowerChargeBarInfo : ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new SupportPowerChargeBar(init.self); }
|
||||
}
|
||||
|
||||
class SupportPowerChargeBar : ISelectionBar
|
||||
{
|
||||
Actor self;
|
||||
public SupportPowerChargeBar(Actor self) { this.self = self; }
|
||||
|
||||
public float GetValue()
|
||||
{
|
||||
// only people we like should see our charge status.
|
||||
if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] != Stance.Ally)
|
||||
return 0;
|
||||
|
||||
var spm = self.Owner.PlayerActor.Trait<SupportPowerManager>();
|
||||
var power = spm.GetPowersForActor(self).FirstOrDefault(sp => !sp.Disabled);
|
||||
|
||||
if (power == null) return 0;
|
||||
|
||||
return 1 - (float)power.RemainingTime / power.TotalTime;
|
||||
}
|
||||
|
||||
public Color GetColor() { return Color.Magenta; }
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,11 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
init.world.ActorAdded += ActorAdded;
|
||||
init.world.ActorRemoved += ActorRemoved;
|
||||
}
|
||||
|
||||
static string MakeKey(SupportPower sp)
|
||||
{
|
||||
return sp.Info.AllowMultiple ? sp.Info.OrderName + "_" + sp.self.ActorID : sp.Info.OrderName;
|
||||
}
|
||||
|
||||
void ActorAdded(Actor a)
|
||||
@@ -42,8 +47,8 @@ namespace OpenRA.Mods.RA
|
||||
return;
|
||||
|
||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
||||
{
|
||||
var key = (t.Info.AllowMultiple) ? t.Info.OrderName+"_"+a.ActorID : t.Info.OrderName;
|
||||
{
|
||||
var key = MakeKey(t);
|
||||
|
||||
if (Powers.ContainsKey(key))
|
||||
{
|
||||
@@ -69,8 +74,8 @@ namespace OpenRA.Mods.RA
|
||||
return;
|
||||
|
||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
||||
{
|
||||
var key = (t.Info.AllowMultiple) ? t.Info.OrderName+"_"+a.ActorID : t.Info.OrderName;
|
||||
{
|
||||
var key = MakeKey(t);
|
||||
Powers[key].Instances.Remove(t);
|
||||
if (Powers[key].Instances.Count == 0 && !Powers[key].Disabled)
|
||||
Powers.Remove(key);
|
||||
@@ -94,6 +99,17 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
if (Powers.ContainsKey(key))
|
||||
Powers[key].Target();
|
||||
}
|
||||
|
||||
static readonly SupportPowerInstance[] NoInstances;
|
||||
|
||||
public IEnumerable<SupportPowerInstance> GetPowersForActor(Actor a)
|
||||
{
|
||||
if (a.Owner != self.Owner || !a.HasTrait<SupportPower>())
|
||||
return NoInstances;
|
||||
|
||||
return a.TraitsImplementing<SupportPower>()
|
||||
.Select(t => Powers[MakeKey(t)]);
|
||||
}
|
||||
|
||||
public class SupportPowerInstance
|
||||
|
||||
@@ -35,6 +35,8 @@ MSLO:
|
||||
SpawnOffset: 10,0
|
||||
CanPowerDown:
|
||||
RequiresPower:
|
||||
SupportPowerChargeBar:
|
||||
|
||||
GAP:
|
||||
RequiresPower:
|
||||
CanPowerDown:
|
||||
@@ -211,6 +213,7 @@ IRON:
|
||||
SelectTargetSound: slcttgt1.aud
|
||||
BeginChargeSound: ironchg1.aud
|
||||
EndChargeSound: ironrdy1.aud
|
||||
SupportPowerChargeBar:
|
||||
|
||||
PDOX:
|
||||
RequiresPower:
|
||||
@@ -250,6 +253,7 @@ PDOX:
|
||||
EndChargeSound: chrordy1.aud
|
||||
Duration: 30
|
||||
KillCargo: yes
|
||||
SupportPowerChargeBar:
|
||||
|
||||
TSLA:
|
||||
RequiresPower:
|
||||
@@ -546,6 +550,7 @@ ATEK:
|
||||
LongDesc: Reveals the entire map
|
||||
RevealDelay: 15
|
||||
LaunchSound: satlnch1.aud
|
||||
SupportPowerChargeBar:
|
||||
|
||||
WEAP:
|
||||
Inherits: ^Building
|
||||
@@ -770,6 +775,7 @@ AFLD:
|
||||
DropItems: E1,E1,E1,E3,E3
|
||||
SelectTargetSound: slcttgt1.aud
|
||||
ProductionBar:
|
||||
SupportPowerChargeBar:
|
||||
|
||||
POWR:
|
||||
Inherits: ^Building
|
||||
|
||||
Reference in New Issue
Block a user