Storage Component (toolboxes, backpacks, etc) (#57)

* Fix
Finish and update submodule
Comments code, changes network messages
FIXES THE USE INTERACTION SO YOU CAN ACTUALLY ACTIVATE THINGS NOW
Need engine commits
We'll figure out what to do about this shit later eh mates? Maybe have a script in the build process that automatically moves them over to godot/scenes
Changes some prototypes and fixes stuff
Fixes some more bugs, makes storage values show up properly
Part 3
Part 2
Storage Take 1

* Doneso
This commit is contained in:
clusterfack
2018-04-22 06:11:38 -05:00
committed by Pieter-Jan Briers
parent 74193d1182
commit ea05c593aa
22 changed files with 1044 additions and 54 deletions

View File

@@ -1,4 +1,5 @@
using Content.Client.Interfaces.GameObjects;
using Content.Client.GameObjects;
using Content.Client.Interfaces.GameObjects;
using SS14.Client.GameObjects;
using SS14.Client.Graphics;
using SS14.Client.Graphics.Drawing;
@@ -11,6 +12,7 @@ using SS14.Client.UserInterface;
using SS14.Client.UserInterface.Controls;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using SS14.Shared.Maths;
namespace Content.Client.UserInterface
@@ -63,16 +65,8 @@ namespace Content.Client.UserInterface
protected override void Draw(DrawingHandle handle)
{
if (_playerManager?.LocalPlayer == null)
{
if (!TryGetHands(out IHandsComponent hands))
return;
}
IEntity entity = _playerManager.LocalPlayer.ControlledEntity;
if (entity == null || !entity.TryGetComponent<IHandsComponent>(out var hands))
{
return;
}
var leftActive = hands.ActiveIndex == "left";
@@ -98,20 +92,35 @@ namespace Content.Client.UserInterface
}
}
public void UpdateHandIcons()
/// <summary>
/// Gets the hands component controling this gui, returns true if successful and false if failure
/// </summary>
/// <param name="hands"></param>
/// <returns></returns>
private bool TryGetHands(out IHandsComponent hands)
{
UpdateDraw();
if (_playerManager?.LocalPlayer.ControlledEntity == null)
hands = null;
if (_playerManager?.LocalPlayer == null)
{
return;
return false;
}
IEntity entity = _playerManager.LocalPlayer.ControlledEntity;
if (!entity.TryGetComponent<IHandsComponent>(out var hands))
if (entity == null || !entity.TryGetComponent(out hands))
{
return;
return false;
}
return true;
}
public void UpdateHandIcons()
{
UpdateDraw();
if (!TryGetHands(out IHandsComponent hands))
return;
var left = hands.GetEntity("left");
var right = hands.GetEntity("right");
@@ -146,14 +155,21 @@ namespace Content.Client.UserInterface
private void SendSwitchHandTo(string index)
{
IEntity entity = _playerManager.LocalPlayer.ControlledEntity;
if (!entity.TryGetComponent<IHandsComponent>(out var hands))
{
if (!TryGetHands(out IHandsComponent hands))
return;
}
hands.SendChangeHand(index);
}
private void UseActiveHand()
{
if (!TryGetHands(out IHandsComponent hands))
return;
//Todo: remove hands interface, so weird
((HandsComponent)hands).UseActiveHand();
}
protected override bool HasPoint(Vector2 point)
{
return handL.Contains((Vector2i)point) || handR.Contains((Vector2i)point);
@@ -163,18 +179,28 @@ namespace Content.Client.UserInterface
{
base.MouseDown(args);
if (args.Button != Mouse.Button.Right)
{
return;
}
var lefthandcontains = handL.Contains((Vector2i)args.RelativePosition);
var righthandcontains = handR.Contains((Vector2i)args.RelativePosition);
if (handL.Contains((Vector2i)args.RelativePosition))
if (args.Button == Mouse.Button.Left)
{
SendSwitchHandTo("left");
if (!TryGetHands(out IHandsComponent hands))
return;
if ((hands.ActiveIndex == "left" && lefthandcontains)
|| (hands.ActiveIndex == "right" && righthandcontains))
UseActiveHand();
}
if (handR.Contains((Vector2i)args.RelativePosition))
else if (args.Button == Mouse.Button.Right)
{
SendSwitchHandTo("right");
if (lefthandcontains)
{
SendSwitchHandTo("left");
}
if (righthandcontains)
{
SendSwitchHandTo("right");
}
}
}