InputSystem Messages (#37)
* Misc Cleanup. * Removed BoundKeyChangeEventArgs. * Nothing uses EntityEventArgs now. * Rebase fixes. * Updated Engine. Fixed .gitmodules file.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
b005d661f8
commit
3f89f3f0f7
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,4 +1,4 @@
|
||||
[submodule "engine"]
|
||||
path = engine
|
||||
url = https://github.com/space-wizards/space-station-14.git
|
||||
branch = 98b7e4ee9ede281f5159539fbb9dba3d08a015cf
|
||||
branch = master
|
||||
@@ -1,19 +1,19 @@
|
||||
using Content.Server.Interfaces.GameObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Interfaces.GameObjects;
|
||||
using Content.Shared.GameObjects;
|
||||
using SS14.Server.GameObjects.Events;
|
||||
using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.Input;
|
||||
using SS14.Shared.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
using SS14.Shared.Enums;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
public class HandsComponent : SharedHandsComponent, IHandsComponent
|
||||
{
|
||||
private string activeIndex;
|
||||
|
||||
public string ActiveIndex
|
||||
{
|
||||
get => activeIndex;
|
||||
@@ -48,16 +48,13 @@ namespace Content.Server.GameObjects
|
||||
AddHand(node.AsString());
|
||||
}
|
||||
}
|
||||
|
||||
Owner.SubscribeEvent<BoundKeyChangeEventArgs>(OnKeyChange, this);
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
inventory = null;
|
||||
Owner.UnsubscribeEvent<BoundKeyChangeEventArgs>(this);
|
||||
Owner.UnsubscribeEvent<ClickedOnEntityEventArgs>(this);
|
||||
base.OnRemove();
|
||||
}
|
||||
|
||||
@@ -223,27 +220,7 @@ namespace Content.Server.GameObjects
|
||||
}
|
||||
return new HandsComponentState(dict, ActiveIndex);
|
||||
}
|
||||
|
||||
// Game logic goes here.
|
||||
public void OnKeyChange(object sender, EntityEventArgs uncast)
|
||||
{
|
||||
var cast = (BoundKeyChangeEventArgs)uncast;
|
||||
if (cast.Actor != Owner || cast.KeyState != BoundKeyState.Down)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cast.KeyFunction)
|
||||
{
|
||||
case BoundKeyFunctions.SwitchHands:
|
||||
SwapHands();
|
||||
break;
|
||||
case BoundKeyFunctions.Drop:
|
||||
Drop(ActiveIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SwapHands()
|
||||
{
|
||||
var index = orderedHands.FindIndex(x => x == ActiveIndex);
|
||||
@@ -266,6 +243,20 @@ namespace Content.Server.GameObjects
|
||||
if (HasHand(msg.Index))
|
||||
ActiveIndex = msg.Index;
|
||||
break;
|
||||
|
||||
case BoundKeyChangedMsg msg:
|
||||
if(msg.State != BoundKeyState.Down)
|
||||
return;
|
||||
switch (msg.Function)
|
||||
{
|
||||
case BoundKeyFunctions.SwitchHands:
|
||||
SwapHands();
|
||||
break;
|
||||
case BoundKeyFunctions.Drop:
|
||||
Drop(ActiveIndex);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ using SS14.Server.Interfaces.GameObjects;
|
||||
using SS14.Shared.GameObjects;
|
||||
using SS14.Shared.GameObjects.System;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
using SS14.Shared.IoC;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SS14.Shared.Enums;
|
||||
using SS14.Shared.Input;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
@@ -44,17 +42,17 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeEvent<ClickedOnEntityEventArgs>(UserInteraction, this);
|
||||
SubscribeEvent<ClickedOnEntityMessage>(UserInteraction);
|
||||
}
|
||||
|
||||
public void UserInteraction(object sender, EntityEventArgs arg)
|
||||
private void UserInteraction(object sender, EntityEventArgs arg)
|
||||
{
|
||||
ClickedOnEntityEventArgs e = (ClickedOnEntityEventArgs)arg;
|
||||
var e = (ClickedOnEntityMessage)arg;
|
||||
if (e.MouseButton != ClickType.Left)
|
||||
return;
|
||||
|
||||
IEntity user = EntityManager.GetEntity(e.Clicker);
|
||||
IEntity attacked = EntityManager.GetEntity(e.Clicked);
|
||||
var user = EntityManager.GetEntity(e.Owner);
|
||||
var attacked = EntityManager.GetEntity(e.Clicked);
|
||||
|
||||
if (!user.TryGetComponent<IServerTransformComponent>(out var userTransform))
|
||||
{
|
||||
|
||||
2
engine
2
engine
Submodule engine updated: 98b7e4ee9e...659b57940c
Reference in New Issue
Block a user