Partial hand ECS (#5634)

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
Co-authored-by: Paul <ritter.paul1@googlemail.com>
This commit is contained in:
Leon Friedrich
2022-01-05 17:53:08 +13:00
committed by GitHub
parent 03ad20758e
commit adbc4ee5b0
34 changed files with 781 additions and 963 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Client.Items.UI;
using Robust.Client.UserInterface;
using Robust.Shared.GameObjects;
@@ -7,10 +7,10 @@ namespace Content.Client.Items.Managers
{
public interface IItemSlotManager
{
bool OnButtonPressed(GUIBoundKeyEventArgs args, EntityUid item);
void UpdateCooldown(ItemSlotButton? cooldownTexture, EntityUid entity);
bool OnButtonPressed(GUIBoundKeyEventArgs args, EntityUid? item);
void UpdateCooldown(ItemSlotButton? cooldownTexture, EntityUid? entity);
bool SetItemSlot(ItemSlotButton button, EntityUid? entity);
void HoverInSlot(ItemSlotButton button, EntityUid entity, bool fits);
void HoverInSlot(ItemSlotButton button, EntityUid? entity, bool fits);
event Action<EntitySlotHighlightedEventArgs>? EntityHighlightedUpdated;
bool IsHighlighted(EntityUid? uid);

View File

@@ -53,34 +53,34 @@ namespace Content.Client.Items.Managers
button.StorageButton.Visible = _entityManager.HasComponent<ClientStorageComponent>(entity);
}
button.Entity = entity;
button.Entity = entity ?? default;
// im lazy
button.UpdateSlotHighlighted();
return true;
}
public bool OnButtonPressed(GUIBoundKeyEventArgs args, EntityUid item)
public bool OnButtonPressed(GUIBoundKeyEventArgs args, EntityUid? item)
{
if (item == default)
if (item == null)
return false;
if (args.Function == ContentKeyFunctions.ExamineEntity)
{
_entitySystemManager.GetEntitySystem<ExamineSystem>()
.DoExamine(item);
.DoExamine(item.Value);
}
else if (args.Function == ContentKeyFunctions.OpenContextMenu)
{
_entitySystemManager.GetEntitySystem<VerbSystem>().VerbMenu.OpenVerbMenu(item);
_entitySystemManager.GetEntitySystem<VerbSystem>().VerbMenu.OpenVerbMenu(item.Value);
}
else if (args.Function == ContentKeyFunctions.ActivateItemInWorld)
{
_entityManager.EntityNetManager?.SendSystemNetworkMessage(new InteractInventorySlotEvent(item, altInteract: false));
_entityManager.EntityNetManager?.SendSystemNetworkMessage(new InteractInventorySlotEvent(item.Value, altInteract: false));
}
else if (args.Function == ContentKeyFunctions.AltActivateItemInWorld)
{
_entityManager.RaisePredictiveEvent(new InteractInventorySlotEvent(item, altInteract: true));
_entityManager.RaisePredictiveEvent(new InteractInventorySlotEvent(item.Value, altInteract: true));
}
else
{
@@ -90,7 +90,7 @@ namespace Content.Client.Items.Managers
return true;
}
public void UpdateCooldown(ItemSlotButton? button, EntityUid entity)
public void UpdateCooldown(ItemSlotButton? button, EntityUid? entity)
{
var cooldownDisplay = button?.CooldownDisplay;
@@ -99,7 +99,7 @@ namespace Content.Client.Items.Managers
return;
}
if (entity == default || _entityManager.Deleted(entity) ||
if (entity == null || _entityManager.Deleted(entity) ||
!_entityManager.TryGetComponent(entity, out ItemCooldownComponent? cooldown) ||
!cooldown.CooldownStart.HasValue ||
!cooldown.CooldownEnd.HasValue)
@@ -119,9 +119,9 @@ namespace Content.Client.Items.Managers
cooldownDisplay.Visible = ratio > -1f;
}
public void HoverInSlot(ItemSlotButton button, EntityUid entity, bool fits)
public void HoverInSlot(ItemSlotButton button, EntityUid? entity, bool fits)
{
if (entity == default || !button.MouseIsHovering)
if (entity == null || !button.MouseIsHovering)
{
button.ClearHover();
return;
@@ -135,7 +135,7 @@ namespace Content.Client.Items.Managers
// Set green / red overlay at 50% transparency
var hoverEntity = _entityManager.SpawnEntity("hoverentity", MapCoordinates.Nullspace);
var hoverSprite = _entityManager.GetComponent<SpriteComponent>(hoverEntity);
hoverSprite.CopyFrom(_entityManager.GetComponent<SpriteComponent>(entity));
hoverSprite.CopyFrom(_entityManager.GetComponent<SpriteComponent>(entity.Value));
hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127);
button.HoverSpriteView.Sprite = hoverSprite;