push the check-synchash-doesn't-change pattern into a utility fn. furthur reduce the number of uses on Game.world
This commit is contained in:
@@ -47,7 +47,6 @@ namespace OpenRA
|
|||||||
var map = modData.PrepareMap(uid);
|
var map = modData.PrepareMap(uid);
|
||||||
|
|
||||||
viewport = new Viewport(new float2(Renderer.Resolution), map.TopLeft, map.BottomRight, Renderer);
|
viewport = new Viewport(new float2(Renderer.Resolution), map.TopLeft, map.BottomRight, Renderer);
|
||||||
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.
|
|
||||||
world = new World(modData.Manifest, map);
|
world = new World(modData.Manifest, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +100,7 @@ namespace OpenRA
|
|||||||
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
|
||||||
public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } }
|
public static int LocalClientId { get { return orderManager.Connection.LocalClientId; } }
|
||||||
|
|
||||||
static void Tick()
|
static void Tick( World world, OrderManager orderManager, Viewport viewPort )
|
||||||
{
|
{
|
||||||
if (orderManager.Connection.ConnectionState != lastConnectionState)
|
if (orderManager.Connection.ConnectionState != lastConnectionState)
|
||||||
{
|
{
|
||||||
@@ -159,7 +158,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
internal static event Action LobbyInfoChanged = () => { };
|
internal static event Action LobbyInfoChanged = () => { };
|
||||||
|
|
||||||
internal static void SyncLobbyInfo(string data)
|
internal static void SyncLobbyInfo( World world, string data)
|
||||||
{
|
{
|
||||||
LobbyInfo = Session.Deserialize(data);
|
LobbyInfo = Session.Deserialize(data);
|
||||||
|
|
||||||
@@ -186,6 +185,7 @@ namespace OpenRA
|
|||||||
public static event Action BeforeGameStart = () => {};
|
public static event Action BeforeGameStart = () => {};
|
||||||
internal static void StartGame(string map)
|
internal static void StartGame(string map)
|
||||||
{
|
{
|
||||||
|
world = null;
|
||||||
BeforeGameStart();
|
BeforeGameStart();
|
||||||
LoadMap(map);
|
LoadMap(map);
|
||||||
if (orderManager.GameStarted) return;
|
if (orderManager.GameStarted) return;
|
||||||
@@ -200,23 +200,20 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void DispatchMouseInput(MouseInputEvent ev, MouseEventArgs e, Modifiers modifierKeys)
|
public static void DispatchMouseInput(MouseInputEvent ev, MouseEventArgs e, Modifiers modifierKeys)
|
||||||
{
|
{
|
||||||
if (world == null)
|
var world = Game.world;
|
||||||
return;
|
if (world == null) return;
|
||||||
|
|
||||||
int sync = world.SyncHash();
|
|
||||||
var initialWorld = world;
|
|
||||||
|
|
||||||
var mi = new MouseInput
|
Sync.CheckSyncUnchanged( world, () =>
|
||||||
{
|
{
|
||||||
Button = (MouseButton)(int)e.Button,
|
var mi = new MouseInput
|
||||||
Event = ev,
|
{
|
||||||
Location = new int2(e.Location),
|
Button = (MouseButton)(int)e.Button,
|
||||||
Modifiers = modifierKeys,
|
Event = ev,
|
||||||
};
|
Location = new int2( e.Location ),
|
||||||
Widget.HandleInput(world, mi);
|
Modifiers = modifierKeys,
|
||||||
|
};
|
||||||
if (sync != world.SyncHash() && world == initialWorld)
|
Widget.HandleInput( world, mi );
|
||||||
throw new InvalidOperationException("Desync in DispatchMouseInput");
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsHost
|
public static bool IsHost
|
||||||
@@ -231,16 +228,13 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static void HandleKeyEvent(KeyInput e)
|
public static void HandleKeyEvent(KeyInput e)
|
||||||
{
|
{
|
||||||
if (world == null)
|
var world = Game.world;
|
||||||
return;
|
if( world == null ) return;
|
||||||
|
|
||||||
int sync = world.SyncHash();
|
|
||||||
|
|
||||||
if (Widget.HandleKeyPress(e))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (sync != Game.world.SyncHash())
|
Sync.CheckSyncUnchanged( world, () =>
|
||||||
throw new InvalidOperationException("Desync in OnKeyPress");
|
{
|
||||||
|
Widget.HandleKeyPress( e );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Modifiers modifiers;
|
static Modifiers modifiers;
|
||||||
@@ -324,7 +318,7 @@ namespace OpenRA
|
|||||||
internal static void Run()
|
internal static void Run()
|
||||||
{
|
{
|
||||||
while (!quit)
|
while (!quit)
|
||||||
{
|
{
|
||||||
Tick( world, orderManager, viewport );
|
Tick( world, orderManager, viewport );
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ namespace OpenRA.Graphics
|
|||||||
if (world.OrderGenerator != null)
|
if (world.OrderGenerator != null)
|
||||||
world.OrderGenerator.RenderBeforeWorld(world);
|
world.OrderGenerator.RenderBeforeWorld(world);
|
||||||
|
|
||||||
foreach (var image in worldSprites)
|
foreach( var image in worldSprites )
|
||||||
image.Sprite.DrawAt(image.Pos, image.Palette);
|
image.Sprite.DrawAt( image.Pos, this.GetPaletteIndex( image.Palette ) );
|
||||||
uiOverlay.Draw(world);
|
uiOverlay.Draw(world);
|
||||||
|
|
||||||
if (world.OrderGenerator != null)
|
if (world.OrderGenerator != null)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace OpenRA.Network
|
|||||||
}
|
}
|
||||||
case "SyncInfo":
|
case "SyncInfo":
|
||||||
{
|
{
|
||||||
Game.SyncLobbyInfo(order.TargetString);
|
Game.SyncLobbyInfo( world, order.TargetString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "SetStance":
|
case "SetStance":
|
||||||
|
|||||||
@@ -129,5 +129,22 @@ namespace OpenRA
|
|||||||
return p.Index * 0x567;
|
return p.Index * 0x567;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CheckSyncUnchanged( World world, Action fn )
|
||||||
|
{
|
||||||
|
int sync = world.SyncHash();
|
||||||
|
fn();
|
||||||
|
if( sync != world.SyncHash() )
|
||||||
|
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T CheckSyncUnchanged<T>( World world, Func<T> fn )
|
||||||
|
{
|
||||||
|
int sync = world.SyncHash();
|
||||||
|
var ret = fn();
|
||||||
|
if( sync != world.SyncHash() )
|
||||||
|
throw new InvalidOperationException( "Desync in DispatchMouseInput" );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Orders;
|
using OpenRA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
@@ -109,9 +109,8 @@ namespace OpenRA.Widgets
|
|||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
{
|
{
|
||||||
var world = Game.world;
|
var world = Game.world;
|
||||||
int sync = world.SyncHash();
|
return Sync.CheckSyncUnchanged( world, () =>
|
||||||
try
|
{
|
||||||
{
|
|
||||||
if (!world.GameHasStarted)
|
if (!world.GameHasStarted)
|
||||||
return "default";
|
return "default";
|
||||||
|
|
||||||
@@ -122,29 +121,24 @@ namespace OpenRA.Widgets
|
|||||||
Modifiers = Game.GetModifierKeys()
|
Modifiers = Game.GetModifierKeys()
|
||||||
};
|
};
|
||||||
|
|
||||||
return Game.world.OrderGenerator.GetCursor( world, Game.viewport.ViewToWorld(mi).ToInt2(), mi );
|
return world.OrderGenerator.GetCursor( world, Game.viewport.ViewToWorld(mi).ToInt2(), mi );
|
||||||
}
|
} );
|
||||||
finally
|
|
||||||
{
|
|
||||||
if( sync != world.SyncHash() )
|
|
||||||
throw new InvalidOperationException( "Desync in InputControllerWidget.GetCursor" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleKeyPressInner(KeyInput e)
|
public override bool HandleKeyPressInner(KeyInput e)
|
||||||
{
|
{
|
||||||
if (e.Event == KeyInputEvent.Down)
|
if (e.Event == KeyInputEvent.Down)
|
||||||
{
|
{
|
||||||
if (e.KeyName.Length == 1 && char.IsDigit(e.KeyName[0]))
|
if (e.KeyName.Length == 1 && char.IsDigit(e.KeyName[0]))
|
||||||
{
|
{
|
||||||
Game.world.Selection.DoControlGroup(Game.world, e.KeyName[0] - '0', e.Modifiers);
|
Game.world.Selection.DoControlGroup(Game.world, e.KeyName[0] - '0', e.Modifiers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.KeyChar == '\b')
|
if (e.KeyChar == '\b')
|
||||||
{
|
{
|
||||||
GotoNextBase();
|
GotoNextBase();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
|
if( world.LocalPlayer == null ) return;
|
||||||
|
|
||||||
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||||
|
|
||||||
var digitCollection = "digits-" + world.LocalPlayer.Country.Race;
|
var digitCollection = "digits-" + world.LocalPlayer.Country.Race;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
|
if( world.LocalPlayer == null ) return;
|
||||||
|
|
||||||
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
||||||
|
|
||||||
var power = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
var power = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||||
|
|||||||
@@ -120,7 +120,9 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
|
if( world.LocalPlayer == null ) return;
|
||||||
|
|
||||||
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
||||||
|
|
||||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(ChromeProvider.GetImage(radarCollection, "left"), radarOrigin);
|
Game.Renderer.RgbaSpriteRenderer.DrawSprite(ChromeProvider.GetImage(radarCollection, "left"), radarOrigin);
|
||||||
|
|||||||
@@ -15,91 +15,93 @@ using System.Linq;
|
|||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets
|
namespace OpenRA.Mods.RA.Widgets
|
||||||
{
|
{
|
||||||
class SpecialPowerBinWidget : Widget
|
class SpecialPowerBinWidget : Widget
|
||||||
{
|
{
|
||||||
static Dictionary<string, Sprite> spsprites;
|
static Dictionary<string, Sprite> spsprites;
|
||||||
Animation ready;
|
Animation ready;
|
||||||
Animation clock;
|
Animation clock;
|
||||||
readonly List<Pair<Rectangle, Action<MouseInput>>> buttons = new List<Pair<Rectangle,Action<MouseInput>>>();
|
readonly List<Pair<Rectangle, Action<MouseInput>>> buttons = new List<Pair<Rectangle,Action<MouseInput>>>();
|
||||||
|
|
||||||
public SpecialPowerBinWidget() : base() { }
|
public SpecialPowerBinWidget() : base() { }
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
if (spsprites == null)
|
if (spsprites == null)
|
||||||
spsprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
|
spsprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
u => u.Image,
|
u => u.Image,
|
||||||
u => SpriteSheetBuilder.LoadAllSprites(u.Image)[0]);
|
u => SpriteSheetBuilder.LoadAllSprites(u.Image)[0]);
|
||||||
|
|
||||||
ready = new Animation("pips");
|
ready = new Animation("pips");
|
||||||
ready.PlayRepeating("ready");
|
ready.PlayRepeating("ready");
|
||||||
clock = new Animation("clock");
|
clock = new Animation("clock");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Rectangle EventBounds
|
public override Rectangle EventBounds
|
||||||
{
|
{
|
||||||
get { return buttons.Any() ? buttons.Select(b => b.First).Aggregate(Rectangle.Union) : Bounds; }
|
get { return buttons.Any() ? buttons.Select(b => b.First).Aggregate(Rectangle.Union) : Bounds; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleInputInner(MouseInput mi)
|
public override bool HandleInputInner(MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Event == MouseInputEvent.Down)
|
if (mi.Event == MouseInputEvent.Down)
|
||||||
{
|
{
|
||||||
var action = buttons.Where(a => a.First.Contains(mi.Location.ToPoint()))
|
var action = buttons.Where(a => a.First.Contains(mi.Location.ToPoint()))
|
||||||
.Select(a => a.Second).FirstOrDefault();
|
.Select(a => a.Second).FirstOrDefault();
|
||||||
if (action == null)
|
if (action == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
action(mi);
|
action(mi);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawInner(World world)
|
public override void DrawInner(World world)
|
||||||
{
|
{
|
||||||
buttons.Clear();
|
buttons.Clear();
|
||||||
|
|
||||||
var powers = world.LocalPlayer.PlayerActor.TraitsImplementing<SupportPower>();
|
if( world.LocalPlayer == null ) return;
|
||||||
var numPowers = powers.Count(p => p.IsAvailable);
|
|
||||||
if (numPowers == 0) return;
|
var powers = world.LocalPlayer.PlayerActor.TraitsImplementing<SupportPower>();
|
||||||
var rectBounds = RenderBounds;
|
var numPowers = powers.Count(p => p.IsAvailable);
|
||||||
WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"),new float2(rectBounds.X,rectBounds.Y));
|
if (numPowers == 0) return;
|
||||||
for (var i = 1; i < numPowers; i++)
|
var rectBounds = RenderBounds;
|
||||||
WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world,"specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51));
|
WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"),new float2(rectBounds.X,rectBounds.Y));
|
||||||
|
for (var i = 1; i < numPowers; i++)
|
||||||
|
WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world,"specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51));
|
||||||
WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world,"specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51));
|
WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world,"specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51));
|
||||||
|
|
||||||
// Hack Hack Hack
|
// Hack Hack Hack
|
||||||
rectBounds.Width = 69;
|
rectBounds.Width = 69;
|
||||||
rectBounds.Height = 10 + numPowers * 51 + 21;
|
rectBounds.Height = 10 + numPowers * 51 + 21;
|
||||||
|
|
||||||
var y = rectBounds.Y + 10;
|
var y = rectBounds.Y + 10;
|
||||||
foreach (var sp in powers)
|
foreach (var sp in powers)
|
||||||
{
|
{
|
||||||
var image = spsprites[sp.Info.Image];
|
var image = spsprites[sp.Info.Image];
|
||||||
if (sp.IsAvailable)
|
if (sp.IsAvailable)
|
||||||
{
|
{
|
||||||
var drawPos = new float2(rectBounds.X + 5, y);
|
var drawPos = new float2(rectBounds.X + 5, y);
|
||||||
var rect = new Rectangle(rectBounds.X + 5, y, 64, 48);
|
var rect = new Rectangle(rectBounds.X + 5, y, 64, 48);
|
||||||
|
|
||||||
if (rect.Contains(Viewport.LastMousePos.ToPoint()))
|
if (rect.Contains(Viewport.LastMousePos.ToPoint()))
|
||||||
{
|
{
|
||||||
var pos = drawPos.ToInt2();
|
var pos = drawPos.ToInt2();
|
||||||
var tl = new int2(pos.X-3,pos.Y-3);
|
var tl = new int2(pos.X-3,pos.Y-3);
|
||||||
var m = new int2(pos.X+64+3,pos.Y+48+3);
|
var m = new int2(pos.X+64+3,pos.Y+48+3);
|
||||||
var br = tl + new int2(64+3+20,60);
|
var br = tl + new int2(64+3+20,60);
|
||||||
|
|
||||||
if (sp.Info.LongDesc != null)
|
if (sp.Info.LongDesc != null)
|
||||||
br += Game.Renderer.RegularFont.Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
|
br += Game.Renderer.RegularFont.Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
|
||||||
else
|
else
|
||||||
br += new int2(300,0);
|
br += new int2(300,0);
|
||||||
|
|
||||||
var border = WidgetUtils.GetBorderSizes("dialog4");
|
var border = WidgetUtils.GetBorderSizes("dialog4");
|
||||||
@@ -109,47 +111,47 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]),
|
WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]),
|
||||||
PanelSides.Top | PanelSides.Right);
|
PanelSides.Top | PanelSides.Right);
|
||||||
WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y),
|
WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y),
|
||||||
PanelSides.Left | PanelSides.Right | PanelSides.Bottom);
|
PanelSides.Left | PanelSides.Right | PanelSides.Bottom);
|
||||||
|
|
||||||
pos += new int2(77, 5);
|
pos += new int2(77, 5);
|
||||||
Game.Renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);
|
Game.Renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);
|
||||||
|
|
||||||
pos += new int2(0,20);
|
pos += new int2(0,20);
|
||||||
Game.Renderer.BoldFont.DrawText(WorldUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
|
Game.Renderer.BoldFont.DrawText(WorldUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
|
||||||
Game.Renderer.BoldFont.DrawText("/ {0}".F(WorldUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
|
Game.Renderer.BoldFont.DrawText("/ {0}".F(WorldUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
|
||||||
|
|
||||||
if (sp.Info.LongDesc != null)
|
if (sp.Info.LongDesc != null)
|
||||||
{
|
{
|
||||||
pos += new int2(0, 20);
|
pos += new int2(0, 20);
|
||||||
Game.Renderer.RegularFont.DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
|
Game.Renderer.RegularFont.DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetUtils.DrawSHP(image, drawPos);
|
WidgetUtils.DrawSHP(image, drawPos);
|
||||||
|
|
||||||
clock.PlayFetchIndex("idle",
|
clock.PlayFetchIndex("idle",
|
||||||
() => (sp.TotalTime - sp.RemainingTime)
|
() => (sp.TotalTime - sp.RemainingTime)
|
||||||
* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
|
* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
|
||||||
clock.Tick();
|
clock.Tick();
|
||||||
|
|
||||||
WidgetUtils.DrawSHP(clock.Image, drawPos);
|
WidgetUtils.DrawSHP(clock.Image, drawPos);
|
||||||
|
|
||||||
if (sp.IsReady)
|
if (sp.IsReady)
|
||||||
{
|
{
|
||||||
ready.Play("ready");
|
ready.Play("ready");
|
||||||
WidgetUtils.DrawSHP(ready.Image, drawPos + new float2((64 - ready.Image.size.X) / 2, 2));
|
WidgetUtils.DrawSHP(ready.Image, drawPos + new float2((64 - ready.Image.size.X) / 2, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons.Add(Pair.New(rect,HandleSupportPower(sp)));
|
buttons.Add(Pair.New(rect,HandleSupportPower(sp)));
|
||||||
|
|
||||||
y += 51;
|
y += 51;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Action<MouseInput> HandleSupportPower(SupportPower sp)
|
Action<MouseInput> HandleSupportPower(SupportPower sp)
|
||||||
{
|
{
|
||||||
return mi => { if (mi.Button == MouseButton.Left) sp.Activate(); };
|
return mi => { if (mi.Button == MouseButton.Left) sp.Activate(); };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user