Interaction Features (#101)

Various minor interaction features.

There is no concept of gravity in the game yet, so items drift through space or the hallways of a station until they are stopped. Thrown items do not collide with walls because making them collidable makes them collide with EVERYTHING, including the player. We need collision groups in the physics system.

Because of the previous problems the velocity things are throw at is set quite low, it can be tweaked after the other mentioned issues are resolved.
This commit is contained in:
Acruid
2018-08-22 01:19:47 -07:00
committed by Pieter-Jan Briers
parent cd4442b81e
commit ed39649721
11 changed files with 170 additions and 17 deletions

View File

@@ -89,6 +89,18 @@ namespace Content.Server.GameObjects.EntitySystems
bool UseEntity(IEntity user);
}
/// <summary>
/// This interface gives components behavior when being activated in the world.
/// </summary>
public interface IActivate
{
/// <summary>
/// Called when this component is activated by another entity.
/// </summary>
/// <param name="user">Entity that activated this component.</param>
void Activate(IEntity user);
}
/// <summary>
/// Governs interactions during clicking on entities
/// </summary>
@@ -101,6 +113,26 @@ namespace Content.Server.GameObjects.EntitySystems
{
var inputSys = EntitySystemManager.GetEntitySystem<InputSystem>();
inputSys.BindMap.BindFunction(ContentKeyFunctions.UseItemInHand, new PointerInputCmdHandler(HandleUseItemInHand));
inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld, new PointerInputCmdHandler((HandleUseItemInWorld)));
}
private void HandleUseItemInWorld(ICommonSession session, GridLocalCoordinates coords, EntityUid uid)
{
if(!EntityManager.TryGetEntity(uid, out var used))
return;
if(!used.TryGetComponent(out IActivate activateComp))
return;
var playerEnt = ((IPlayerSession) session).AttachedEntity;
if(playerEnt == null || !playerEnt.IsValid())
return;
if (!playerEnt.Transform.LocalPosition.InRange(used.Transform.LocalPosition, INTERACTION_RANGE))
return;
activateComp.Activate(playerEnt);
}
private void HandleUseItemInHand(ICommonSession session, GridLocalCoordinates coords, EntityUid uid)
@@ -112,7 +144,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
//Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
if (!EntityManager.TryGetEntity(clickedUid, out var attacked))
return;
attacked = null;
//Verify player has a transform component
if (!player.TryGetComponent<ITransformComponent>(out var playerTransform))