* Start work on stripping.

* more strippable work

* Stripping works

* Nullable

* MORE NULLABLE

* nullable moment

* life is pain

* Interaction check.

* Update Content.Client/GameObjects/Components/HUD/Inventory/StrippableBoundUserInterface.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Client/GameObjects/Components/HUD/Inventory/StrippableBoundUserInterface.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/HandsComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/HandsComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/HandsComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/StrippableComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/StrippableComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/HandsComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/StrippableComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/StrippableComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Shared/GameObjects/Components/GUI/SharedStrippableComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Update Content.Server/GameObjects/Components/GUI/StrippableComponent.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Rename InventoryComponent and HandsComponent's OnChanged event to OnItemChanged

* Apply suggestions from code review

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

* Use static EquipmentSlotDefines

* Do not expose ContainerSlot on Inventory or Hands.

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Víctor Aguilera Puerto
2020-08-15 20:33:42 +02:00
committed by GitHub
parent e047262289
commit c3df108b27
12 changed files with 700 additions and 32 deletions

View File

@@ -42,6 +42,8 @@ namespace Content.Server.GameObjects.Components.GUI
private string? _activeHand;
private uint _nextHand;
public event Action? OnItemChanged;
[ViewVariables(VVAccess.ReadWrite)]
public string? ActiveHand
{
@@ -60,6 +62,8 @@ namespace Content.Server.GameObjects.Components.GUI
[ViewVariables] private readonly List<Hand> _hands = new List<Hand>();
public IEnumerable<string> Hands => _hands.Select(h => h.Name);
// Mostly arbitrary.
public const float PickupRange = 2;
@@ -105,6 +109,12 @@ namespace Content.Server.GameObjects.Components.GUI
return GetHand(handName)?.Entity?.GetComponent<ItemComponent>();
}
public bool TryGetItem(string handName, [MaybeNullWhen(false)] out ItemComponent item)
{
item = GetItem(handName);
return item != null;
}
public ItemComponent? GetActiveHand => ActiveHand == null
? null
: GetItem(ActiveHand);
@@ -136,6 +146,8 @@ namespace Content.Server.GameObjects.Components.GUI
{
if (PutInHand(item, hand, false))
{
OnItemChanged?.Invoke();
return true;
}
}
@@ -156,6 +168,7 @@ namespace Content.Server.GameObjects.Components.GUI
if (success)
{
item.Owner.Transform.LocalPosition = Vector2.Zero;
OnItemChanged?.Invoke();
}
_entitySystemManager.GetEntitySystem<InteractionSystem>().HandSelectedInteraction(Owner, item.Owner);
@@ -250,6 +263,8 @@ namespace Content.Server.GameObjects.Components.GUI
container.Insert(item.Owner);
}
OnItemChanged?.Invoke();
Dirty();
return true;
}
@@ -300,6 +315,8 @@ namespace Content.Server.GameObjects.Components.GUI
container.Insert(item.Owner);
}
OnItemChanged?.Invoke();
Dirty();
return true;
}
@@ -364,6 +381,8 @@ namespace Content.Server.GameObjects.Components.GUI
throw new InvalidOperationException();
}
OnItemChanged?.Invoke();
Dirty();
return true;
}
@@ -415,6 +434,8 @@ namespace Content.Server.GameObjects.Components.GUI
ActiveHand ??= name;
OnItemChanged?.Invoke();
Dirty();
}
@@ -435,6 +456,8 @@ namespace Content.Server.GameObjects.Components.GUI
_activeHand = _hands.FirstOrDefault()?.Name;
}
OnItemChanged?.Invoke();
Dirty();
}
@@ -645,7 +668,7 @@ namespace Content.Server.GameObjects.Components.GUI
Dirty();
if (!message.Entity.TryGetComponent(out IPhysicsComponent physics))
if (!message.Entity.TryGetComponent(out ICollidableComponent physics))
{
return;
}