Interactable component system. (#9)
* InteractableComponent v1. Broken edition * It works!
This commit is contained in:
committed by
GitHub
parent
8c1fa84c6e
commit
7597cd9172
@@ -51,7 +51,6 @@ namespace Content.Server.GameObjects
|
||||
}
|
||||
|
||||
Owner.SubscribeEvent<BoundKeyChangeEventArgs>(OnKeyChange, this);
|
||||
Owner.SubscribeEvent<ClickedOnEntityEventArgs>(OnClick, this);
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
@@ -258,24 +257,6 @@ namespace Content.Server.GameObjects
|
||||
ActiveIndex = orderedHands[index];
|
||||
}
|
||||
|
||||
public void OnClick(object sender, EntityEventArgs uncast)
|
||||
{
|
||||
var cast = (ClickedOnEntityEventArgs)uncast;
|
||||
if (cast.MouseButton != MouseClickType.Left || Owner.EntityManager.GetEntity(cast.Clicker) != Owner)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var target = Owner.EntityManager.GetEntity(cast.Clicked);
|
||||
var targetTransform = target.GetComponent<IServerTransformComponent>();
|
||||
if (!target.TryGetComponent<IItemComponent>(out var item) || (targetTransform.WorldPosition - transform.WorldPosition).Length > PICKUP_RANGE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PutInHand(item, ActiveIndex, fallback: false);
|
||||
}
|
||||
|
||||
public override void HandleNetworkMessage(IncomingEntityComponentMessage message, NetConnection sender)
|
||||
{
|
||||
if (message.MessageParameters.Count != 1)
|
||||
|
||||
Reference in New Issue
Block a user