Wieldable/two-handed weapons (#4554)
* wielding kinda works * rough out all the edges, wielding works nicely * popups + loc * increase damage & extra damage against whitelist * small fixes * forgot to actually do that * reviews * reviews + thing * use resistances and not extradamageagainstwhitelist * slashy * make increasedamageonwield and melee hit events work with modifiersets * Silly individual
This commit is contained in:
53
Content.Shared/Hands/Components/HandVirtualItemComponent.cs
Normal file
53
Content.Shared/Hands/Components/HandVirtualItemComponent.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Hands.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed class HandVirtualItemComponent : Component
|
||||
{
|
||||
private EntityUid _blockingEntity;
|
||||
public override string Name => "HandVirtualItem";
|
||||
|
||||
/// <summary>
|
||||
/// The entity blocking this hand.
|
||||
/// </summary>
|
||||
public EntityUid BlockingEntity
|
||||
{
|
||||
get => _blockingEntity;
|
||||
set
|
||||
{
|
||||
_blockingEntity = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new VirtualItemComponentState(BlockingEntity);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not VirtualItemComponentState pullState)
|
||||
return;
|
||||
|
||||
_blockingEntity = pullState.BlockingEntity;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VirtualItemComponentState : ComponentState
|
||||
{
|
||||
public readonly EntityUid BlockingEntity;
|
||||
|
||||
public VirtualItemComponentState(EntityUid blockingEntity)
|
||||
{
|
||||
BlockingEntity = blockingEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Hands.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed class HandVirtualPullComponent : Component
|
||||
{
|
||||
private EntityUid _pulledEntity;
|
||||
public override string Name => "HandVirtualPull";
|
||||
|
||||
public EntityUid PulledEntity
|
||||
{
|
||||
get => _pulledEntity;
|
||||
set
|
||||
{
|
||||
_pulledEntity = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new VirtualPullComponentState(_pulledEntity);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
if (curState is not VirtualPullComponentState pullState)
|
||||
return;
|
||||
|
||||
_pulledEntity = pullState.PulledEntity;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class VirtualPullComponentState : ComponentState
|
||||
{
|
||||
public readonly EntityUid PulledEntity;
|
||||
|
||||
public VirtualPullComponentState(EntityUid pulledEntity)
|
||||
{
|
||||
PulledEntity = pulledEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,23 @@ namespace Content.Shared.Hands.Components
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryGetHandHoldingEntity(IEntity entity, [NotNullWhen(true)] out Hand? handFound)
|
||||
/// <summary>
|
||||
/// Returns the number of hands that have no items in them.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetFreeHands()
|
||||
{
|
||||
int acc = 0;
|
||||
foreach (var hand in Hands)
|
||||
{
|
||||
if (hand.HeldEntity == null)
|
||||
acc += 1;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
public bool TryGetHandHoldingEntity(IEntity entity, [NotNullWhen(true)] out Hand? handFound)
|
||||
{
|
||||
handFound = null;
|
||||
|
||||
@@ -418,6 +434,7 @@ namespace Content.Shared.Hands.Components
|
||||
Logger.Error($"{nameof(SharedHandsComponent)} on {Owner} could not remove {heldEntity} from {handContainer}.");
|
||||
return;
|
||||
}
|
||||
|
||||
OnHeldEntityRemovedFromHand(heldEntity, hand.ToHandState());
|
||||
|
||||
HandsModified();
|
||||
|
||||
Reference in New Issue
Block a user