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,10 +1,15 @@
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Shared.GameObjects;
using SS14.Server.Interfaces.GameObjects;
using SS14.Server.Interfaces.Player;
using SS14.Shared.GameObjects;
using SS14.Shared.Input;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.Network;
using SS14.Shared.IoC;
using SS14.Shared.Utility;
using YamlDotNet.RepresentationModel;
@@ -81,6 +86,8 @@ namespace Content.Server.GameObjects
return slot.Item;
}
public IItemComponent GetActiveHand => GetHand(ActiveIndex);
/// <summary>
/// Enumerates over the hand keys, returning the active hand first.
/// </summary>
@@ -233,19 +240,40 @@ namespace Content.Server.GameObjects
ActiveIndex = orderedHands[index];
}
public override void HandleMessage(object owner, ComponentMessage message)
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
{
base.HandleMessage(owner, message);
base.HandleMessage(message, netChannel, component);
switch (message)
{
case ClientChangedHandMsg msg:
if (HasHand(msg.Index))
ActiveIndex = msg.Index;
break;
{
var playerMan = IoCManager.Resolve<IPlayerManager>();
var session = playerMan.GetSessionByChannel(netChannel);
var playerentity = session.AttachedEntity;
if (playerentity == Owner && HasHand(msg.Index))
ActiveIndex = msg.Index;
break;
}
case ActivateInhandMsg msg:
{
var playerMan = IoCManager.Resolve<IPlayerManager>();
var session = playerMan.GetSessionByChannel(netChannel);
var playerentity = session.AttachedEntity;
var used = GetActiveHand?.Owner;
if (playerentity == Owner && used != null)
{
InteractionSystem.TryUseInteraction(Owner, used);
}
break;
}
//Boundkeychangedmsg only works for the player entity
case BoundKeyChangedMsg msg:
if(msg.State != BoundKeyState.Down)
if (msg.State != BoundKeyState.Down)
return;
switch (msg.Function)
{
@@ -255,6 +283,13 @@ namespace Content.Server.GameObjects
case BoundKeyFunctions.Drop:
Drop(ActiveIndex);
break;
case BoundKeyFunctions.ActivateItemInHand:
var used = GetActiveHand?.Owner;
if(used != null)
{
InteractionSystem.TryUseInteraction(Owner, used);
}
break;
}
break;
}