Updates for the netcode refactor. (#69)

* Updates for the netcode refactor.

* Change HandsGui to control.

Why? No idea but drawing of it works again.

* Fix hand change sync.

* Update submodule
This commit is contained in:
Pieter-Jan Briers
2018-05-13 11:54:21 +02:00
committed by GitHub
parent 20cf3a6a9b
commit 85b4be3ff4
5 changed files with 15 additions and 32 deletions

View File

@@ -17,7 +17,7 @@ using SS14.Shared.Maths;
namespace Content.Client.UserInterface namespace Content.Client.UserInterface
{ {
public class HandsGui : HBoxContainer public class HandsGui : Control
{ {
private static readonly Color _inactiveColor = new Color(90, 90, 90); private static readonly Color _inactiveColor = new Color(90, 90, 90);
private const int BOX_SPACING = 1; private const int BOX_SPACING = 1;

View File

@@ -30,6 +30,7 @@ namespace Content.Server.GameObjects
} }
activeIndex = value; activeIndex = value;
Dirty();
} }
} }
@@ -107,6 +108,7 @@ namespace Content.Server.GameObjects
} }
var slot = hands[index]; var slot = hands[index];
Dirty();
return slot.Insert(item.Owner); return slot.Insert(item.Owner);
} }
@@ -153,6 +155,7 @@ namespace Content.Server.GameObjects
// TODO: The item should be dropped to the container our owner is in, if any. // TODO: The item should be dropped to the container our owner is in, if any.
var itemTransform = item.Owner.GetComponent<TransformComponent>(); var itemTransform = item.Owner.GetComponent<TransformComponent>();
itemTransform.LocalPosition = Owner.GetComponent<TransformComponent>().LocalPosition; itemTransform.LocalPosition = Owner.GetComponent<TransformComponent>().LocalPosition;
Dirty();
return true; return true;
} }
@@ -178,7 +181,7 @@ namespace Content.Server.GameObjects
var slot = ContainerManagerComponent.Create<ContainerSlot>(Name + "_" + index, Owner); var slot = ContainerManagerComponent.Create<ContainerSlot>(Name + "_" + index, Owner);
hands[index] = slot; hands[index] = slot;
if(!orderedHands.Contains(index)) if (!orderedHands.Contains(index))
{ {
orderedHands.Add(index); orderedHands.Add(index);
} }
@@ -186,6 +189,7 @@ namespace Content.Server.GameObjects
{ {
ActiveIndex = index; ActiveIndex = index;
} }
Dirty();
} }
public void RemoveHand(string index) public void RemoveHand(string index)
@@ -210,6 +214,7 @@ namespace Content.Server.GameObjects
activeIndex = orderedHands[0]; activeIndex = orderedHands[0];
} }
} }
Dirty();
} }
public bool HasHand(string index) public bool HasHand(string index)
@@ -234,7 +239,7 @@ namespace Content.Server.GameObjects
} }
return new HandsComponentState(dict, ActiveIndex); return new HandsComponentState(dict, ActiveIndex);
} }
private void SwapHands() private void SwapHands()
{ {
var index = orderedHands.FindIndex(x => x == ActiveIndex); var index = orderedHands.FindIndex(x => x == ActiveIndex);
@@ -246,12 +251,11 @@ namespace Content.Server.GameObjects
ActiveIndex = orderedHands[index]; ActiveIndex = orderedHands[index];
} }
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null) public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
{ {
base.HandleMessage(message, netChannel, component); base.HandleMessage(message, netChannel, component);
switch (message) switch (message)
{ {
case ClientChangedHandMsg msg: case ClientChangedHandMsg msg:
@@ -293,7 +297,7 @@ namespace Content.Server.GameObjects
break; break;
case BoundKeyFunctions.ActivateItemInHand: case BoundKeyFunctions.ActivateItemInHand:
var used = GetActiveHand?.Owner; var used = GetActiveHand?.Owner;
if(used != null) if (used != null)
{ {
InteractionSystem.TryUseInteraction(Owner, used); InteractionSystem.TryUseInteraction(Owner, used);
} }

View File

@@ -45,7 +45,7 @@ namespace Content.Server.GameObjects
/// <returns></returns> /// <returns></returns>
bool Remove(IEntity toremove) bool Remove(IEntity toremove)
{ {
if(storage.Remove(toremove)) if (storage.Remove(toremove))
{ {
StorageUsed -= toremove.GetComponent<StoreableComponent>().ObjectSize; StorageUsed -= toremove.GetComponent<StoreableComponent>().ObjectSize;
UpdateClientInventory(); UpdateClientInventory();
@@ -61,7 +61,7 @@ namespace Content.Server.GameObjects
/// <returns></returns> /// <returns></returns>
bool Insert(IEntity toinsert) bool Insert(IEntity toinsert)
{ {
if(CanInsert(toinsert) && storage.Insert(toinsert)) if (CanInsert(toinsert) && storage.Insert(toinsert))
{ {
StorageUsed += toinsert.GetComponent<StoreableComponent>().ObjectSize; StorageUsed += toinsert.GetComponent<StoreableComponent>().ObjectSize;
UpdateClientInventory(); UpdateClientInventory();
@@ -77,7 +77,7 @@ namespace Content.Server.GameObjects
/// <returns></returns> /// <returns></returns>
bool CanInsert(IEntity toinsert) bool CanInsert(IEntity toinsert)
{ {
if(toinsert.TryGetComponent(out StoreableComponent store)) if (toinsert.TryGetComponent(out StoreableComponent store))
{ {
if (store.ObjectSize <= (StorageCapacityMax - StorageUsed)) if (store.ObjectSize <= (StorageCapacityMax - StorageUsed))
return true; return true;
@@ -95,7 +95,7 @@ namespace Content.Server.GameObjects
{ {
var hands = user.GetComponent<HandsComponent>(); var hands = user.GetComponent<HandsComponent>();
//Check that we can drop the item from our hands first otherwise we obviously cant put it inside //Check that we can drop the item from our hands first otherwise we obviously cant put it inside
if(hands.Drop(hands.ActiveIndex)) if (hands.Drop(hands.ActiveIndex))
{ {
var inserted = Insert(attackwith); var inserted = Insert(attackwith);
if (inserted) if (inserted)

View File

@@ -40,8 +40,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Client", "engine\SS14.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Client.Godot", "engine\SS14.Client.Godot\SS14.Client.Godot.csproj", "{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Client.Godot", "engine\SS14.Client.Godot\SS14.Client.Godot.csproj", "{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Shared.Bsdiff", "engine\SS14.Shared.Bsdiff\SS14.Shared.Bsdiff\SS14.Shared.Bsdiff.csproj", "{0E0723E8-D785-4F61-81F4-182A12BCAA52}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -235,24 +233,6 @@ Global
{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x64.Build.0 = Tools|Any CPU {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x64.Build.0 = Tools|Any CPU
{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x86.ActiveCfg = Tools|Any CPU {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x86.ActiveCfg = Tools|Any CPU
{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x86.Build.0 = Tools|Any CPU {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x86.Build.0 = Tools|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Debug|x64.ActiveCfg = Debug|x64
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Debug|x64.Build.0 = Debug|x64
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Debug|x86.ActiveCfg = Debug|x86
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Debug|x86.Build.0 = Debug|x86
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Release|Any CPU.Build.0 = Release|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Release|x64.ActiveCfg = Release|x64
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Release|x64.Build.0 = Release|x64
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Release|x86.ActiveCfg = Release|x86
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Release|x86.Build.0 = Release|x86
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Tools|Any CPU.ActiveCfg = Debug|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Tools|Any CPU.Build.0 = Debug|Any CPU
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Tools|x64.ActiveCfg = Debug|x64
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Tools|x64.Build.0 = Debug|x64
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Tools|x86.ActiveCfg = Debug|x86
{0E0723E8-D785-4F61-81F4-182A12BCAA52}.Tools|x86.Build.0 = Debug|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -265,7 +245,6 @@ Global
{C899FCA4-7037-4E49-ABC2-44DE72487110} = {3202E94D-E985-4181-9F69-F458A7F6574F} {C899FCA4-7037-4E49-ABC2-44DE72487110} = {3202E94D-E985-4181-9F69-F458A7F6574F}
{83429BD6-6358-4B18-BE51-401DF8EA2673} = {B01693E5-CF08-4DB7-8920-407F8D6603A1} {83429BD6-6358-4B18-BE51-401DF8EA2673} = {B01693E5-CF08-4DB7-8920-407F8D6603A1}
{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB} = {B01693E5-CF08-4DB7-8920-407F8D6603A1} {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB} = {B01693E5-CF08-4DB7-8920-407F8D6603A1}
{0E0723E8-D785-4F61-81F4-182A12BCAA52} = {B01693E5-CF08-4DB7-8920-407F8D6603A1}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A} SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A}

2
engine

Submodule engine updated: 1375da7f70...0a195fe3c7