add support power charge bar
This commit is contained in:
@@ -102,6 +102,7 @@
|
|||||||
<Compile Include="Buildings\TechTree.cs" />
|
<Compile Include="Buildings\TechTree.cs" />
|
||||||
<Compile Include="Buildings\Util.cs" />
|
<Compile Include="Buildings\Util.cs" />
|
||||||
<Compile Include="ProximityCaptor.cs" />
|
<Compile Include="ProximityCaptor.cs" />
|
||||||
|
<Compile Include="SupportPowers\SupportPowerChargeBar.cs" />
|
||||||
<Compile Include="Valued.cs" />
|
<Compile Include="Valued.cs" />
|
||||||
<Compile Include="Combat.cs" />
|
<Compile Include="Combat.cs" />
|
||||||
<Compile Include="Player\SurrenderOnDisconnect.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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,11 @@ namespace OpenRA.Mods.RA
|
|||||||
init.world.ActorRemoved += ActorRemoved;
|
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)
|
void ActorAdded(Actor a)
|
||||||
{
|
{
|
||||||
if (a.Owner != self.Owner || !a.HasTrait<SupportPower>())
|
if (a.Owner != self.Owner || !a.HasTrait<SupportPower>())
|
||||||
@@ -43,7 +48,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
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))
|
if (Powers.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -70,7 +75,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
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);
|
Powers[key].Instances.Remove(t);
|
||||||
if (Powers[key].Instances.Count == 0 && !Powers[key].Disabled)
|
if (Powers[key].Instances.Count == 0 && !Powers[key].Disabled)
|
||||||
Powers.Remove(key);
|
Powers.Remove(key);
|
||||||
@@ -96,6 +101,17 @@ namespace OpenRA.Mods.RA
|
|||||||
Powers[key].Target();
|
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
|
public class SupportPowerInstance
|
||||||
{
|
{
|
||||||
readonly SupportPowerManager Manager;
|
readonly SupportPowerManager Manager;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ MSLO:
|
|||||||
SpawnOffset: 10,0
|
SpawnOffset: 10,0
|
||||||
CanPowerDown:
|
CanPowerDown:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
|
SupportPowerChargeBar:
|
||||||
|
|
||||||
GAP:
|
GAP:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
CanPowerDown:
|
CanPowerDown:
|
||||||
@@ -211,6 +213,7 @@ IRON:
|
|||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
BeginChargeSound: ironchg1.aud
|
BeginChargeSound: ironchg1.aud
|
||||||
EndChargeSound: ironrdy1.aud
|
EndChargeSound: ironrdy1.aud
|
||||||
|
SupportPowerChargeBar:
|
||||||
|
|
||||||
PDOX:
|
PDOX:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
@@ -250,6 +253,7 @@ PDOX:
|
|||||||
EndChargeSound: chrordy1.aud
|
EndChargeSound: chrordy1.aud
|
||||||
Duration: 30
|
Duration: 30
|
||||||
KillCargo: yes
|
KillCargo: yes
|
||||||
|
SupportPowerChargeBar:
|
||||||
|
|
||||||
TSLA:
|
TSLA:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
@@ -546,6 +550,7 @@ ATEK:
|
|||||||
LongDesc: Reveals the entire map
|
LongDesc: Reveals the entire map
|
||||||
RevealDelay: 15
|
RevealDelay: 15
|
||||||
LaunchSound: satlnch1.aud
|
LaunchSound: satlnch1.aud
|
||||||
|
SupportPowerChargeBar:
|
||||||
|
|
||||||
WEAP:
|
WEAP:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -770,6 +775,7 @@ AFLD:
|
|||||||
DropItems: E1,E1,E1,E3,E3
|
DropItems: E1,E1,E1,E3,E3
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
|
SupportPowerChargeBar:
|
||||||
|
|
||||||
POWR:
|
POWR:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
Reference in New Issue
Block a user