Drop items on entering dead or crit states (#1082)
* Drop items on dead or crit
This commit is contained in:
committed by
GitHub
parent
21c41f28ed
commit
952fa9f7ed
@@ -78,7 +78,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
|
|
||||||
if (weapon.Automatic || canFireSemi)
|
if (weapon.Automatic || canFireSemi)
|
||||||
{
|
{
|
||||||
Logger.Debug(IoCManager.Resolve<IGameTiming>().CurTick.ToString());
|
|
||||||
weapon.SyncFirePos(worldPos);
|
weapon.SyncFirePos(worldPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ namespace Content.Server.GameObjects
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Drop(string slot, GridCoordinates coords)
|
public bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (!CanDrop(slot))
|
if (!CanDrop(slot))
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ namespace Content.Server.GameObjects
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
if (doMobChecks && !_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
item.RemovedFromSlot();
|
item.RemovedFromSlot();
|
||||||
@@ -216,7 +216,7 @@ namespace Content.Server.GameObjects
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Drop(IEntity entity, GridCoordinates coords)
|
public bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
@@ -229,10 +229,10 @@ namespace Content.Server.GameObjects
|
|||||||
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Drop(slot, coords);
|
return Drop(slot, coords, doMobChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Drop(string slot)
|
public bool Drop(string slot, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (!CanDrop(slot))
|
if (!CanDrop(slot))
|
||||||
{
|
{
|
||||||
@@ -242,7 +242,7 @@ namespace Content.Server.GameObjects
|
|||||||
var inventorySlot = hands[slot];
|
var inventorySlot = hands[slot];
|
||||||
var item = inventorySlot.ContainedEntity.GetComponent<ItemComponent>();
|
var item = inventorySlot.ContainedEntity.GetComponent<ItemComponent>();
|
||||||
|
|
||||||
if (!_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
if (doMobChecks && !_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!inventorySlot.Remove(inventorySlot.ContainedEntity))
|
if (!inventorySlot.Remove(inventorySlot.ContainedEntity))
|
||||||
@@ -263,7 +263,7 @@ namespace Content.Server.GameObjects
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Drop(IEntity entity)
|
public bool Drop(IEntity entity, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
@@ -276,10 +276,10 @@ namespace Content.Server.GameObjects
|
|||||||
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Drop(slot);
|
return Drop(slot, doMobChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Drop(string slot, BaseContainer targetContainer)
|
public bool Drop(string slot, BaseContainer targetContainer, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (slot == null)
|
if (slot == null)
|
||||||
{
|
{
|
||||||
@@ -296,8 +296,15 @@ namespace Content.Server.GameObjects
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var inventorySlot = hands[slot];
|
var inventorySlot = hands[slot];
|
||||||
var item = inventorySlot.ContainedEntity.GetComponent<ItemComponent>();
|
var item = inventorySlot.ContainedEntity.GetComponent<ItemComponent>();
|
||||||
|
|
||||||
|
if (doMobChecks && !_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!inventorySlot.CanRemove(inventorySlot.ContainedEntity))
|
if (!inventorySlot.CanRemove(inventorySlot.ContainedEntity))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -324,7 +331,7 @@ namespace Content.Server.GameObjects
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Drop(IEntity entity, BaseContainer targetContainer)
|
public bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
@@ -337,7 +344,7 @@ namespace Content.Server.GameObjects
|
|||||||
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
throw new ArgumentException("Entity must be held in one of our hands.", nameof(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Drop(slot, targetContainer);
|
return Drop(slot, targetContainer, doMobChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ namespace Content.Server.GameObjects.Components.Instruments
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StandingStateHelper.DropAllItemsInHands(mob);
|
StandingStateHelper.DropAllItemsInHands(mob, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstrumentPlayer = null;
|
InstrumentPlayer = null;
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ namespace Content.Server.GameObjects
|
|||||||
if(entity.TryGetComponent(out StunnableComponent stun))
|
if(entity.TryGetComponent(out StunnableComponent stun))
|
||||||
stun.CancelAll();
|
stun.CancelAll();
|
||||||
|
|
||||||
StandingStateHelper.Down(entity, playSound:false);
|
StandingStateHelper.Down(entity);
|
||||||
|
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidable))
|
if (entity.TryGetComponent(out CollidableComponent collidable))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace Content.Server.GameObjects.Components.Mobs
|
|||||||
if (seconds <= 0f)
|
if (seconds <= 0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StandingStateHelper.DropAllItemsInHands(Owner);
|
StandingStateHelper.DropAllItemsInHands(Owner, false);
|
||||||
|
|
||||||
_stunnedTimer = seconds;
|
_stunnedTimer = seconds;
|
||||||
_lastStun = _gameTiming.CurTime;
|
_lastStun = _gameTiming.CurTime;
|
||||||
|
|||||||
@@ -80,13 +80,15 @@ namespace Content.Server.Interfaces.GameObjects
|
|||||||
/// Drops the item contained in the slot to the same position as our entity.
|
/// Drops the item contained in the slot to the same position as our entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="slot">The slot of which to drop to drop the item.</param>
|
/// <param name="slot">The slot of which to drop to drop the item.</param>
|
||||||
|
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||||
/// <returns>True on success, false if something blocked the drop.</returns>
|
/// <returns>True on success, false if something blocked the drop.</returns>
|
||||||
bool Drop(string slot);
|
bool Drop(string slot, bool doMobChecks = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops an item held by one of our hand slots to the same position as our owning entity.
|
/// Drops an item held by one of our hand slots to the same position as our owning entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The item to drop.</param>
|
/// <param name="entity">The item to drop.</param>
|
||||||
|
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||||
/// <returns>True on success, false if something blocked the drop.</returns>
|
/// <returns>True on success, false if something blocked the drop.</returns>
|
||||||
/// <exception cref="ArgumentNullException">
|
/// <exception cref="ArgumentNullException">
|
||||||
/// Thrown if <see cref="entity"/> is null.
|
/// Thrown if <see cref="entity"/> is null.
|
||||||
@@ -94,15 +96,16 @@ namespace Content.Server.Interfaces.GameObjects
|
|||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
bool Drop(IEntity entity);
|
bool Drop(IEntity entity, bool doMobChecks = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops the item in a slot.
|
/// Drops the item in a slot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="slot">The slot to drop the item from.</param>
|
/// <param name="slot">The slot to drop the item from.</param>
|
||||||
/// <param name="coords"></param>
|
/// <param name="coords"></param>
|
||||||
|
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||||
/// <returns>True if an item was dropped, false otherwise.</returns>
|
/// <returns>True if an item was dropped, false otherwise.</returns>
|
||||||
bool Drop(string slot, GridCoordinates coords);
|
bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drop the specified entity in our hands to a certain position.
|
/// Drop the specified entity in our hands to a certain position.
|
||||||
@@ -113,6 +116,7 @@ namespace Content.Server.Interfaces.GameObjects
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="entity">The entity to drop, must be held in one of the hands.</param>
|
/// <param name="entity">The entity to drop, must be held in one of the hands.</param>
|
||||||
/// <param name="coords">The coordinates to drop the entity at.</param>
|
/// <param name="coords">The coordinates to drop the entity at.</param>
|
||||||
|
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// True if the drop succeeded,
|
/// True if the drop succeeded,
|
||||||
/// false if it failed (due to failing to eject from our hand slot, etc...)
|
/// false if it failed (due to failing to eject from our hand slot, etc...)
|
||||||
@@ -123,26 +127,28 @@ namespace Content.Server.Interfaces.GameObjects
|
|||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
bool Drop(IEntity entity, GridCoordinates coords);
|
bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drop the item contained in a slot into another container.
|
/// Drop the item contained in a slot into another container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="slot">The slot of which to drop the entity.</param>
|
/// <param name="slot">The slot of which to drop the entity.</param>
|
||||||
/// <param name="targetContainer">The container to drop into.</param>
|
/// <param name="targetContainer">The container to drop into.</param>
|
||||||
|
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||||
/// <returns>True on success, false if something was blocked (insertion or removal).</returns>
|
/// <returns>True on success, false if something was blocked (insertion or removal).</returns>
|
||||||
/// <exception cref="InvalidOperationException">
|
/// <exception cref="InvalidOperationException">
|
||||||
/// Thrown if dry-run checks reported OK to remove and insert,
|
/// Thrown if dry-run checks reported OK to remove and insert,
|
||||||
/// but practical remove or insert returned false anyways.
|
/// but practical remove or insert returned false anyways.
|
||||||
/// This is an edge-case that is currently unhandled.
|
/// This is an edge-case that is currently unhandled.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
bool Drop(string slot, BaseContainer targetContainer);
|
bool Drop(string slot, BaseContainer targetContainer, bool doMobChecks = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops an item in one of the hands into a container.
|
/// Drops an item in one of the hands into a container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The item to drop.</param>
|
/// <param name="entity">The item to drop.</param>
|
||||||
/// <param name="targetContainer">The container to drop into.</param>
|
/// <param name="targetContainer">The container to drop into.</param>
|
||||||
|
/// <param name="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||||
/// <returns>True on success, false if something was blocked (insertion or removal).</returns>
|
/// <returns>True on success, false if something was blocked (insertion or removal).</returns>
|
||||||
/// <exception cref="InvalidOperationException">
|
/// <exception cref="InvalidOperationException">
|
||||||
/// Thrown if dry-run checks reported OK to remove and insert,
|
/// Thrown if dry-run checks reported OK to remove and insert,
|
||||||
@@ -155,7 +161,7 @@ namespace Content.Server.Interfaces.GameObjects
|
|||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
bool Drop(IEntity entity, BaseContainer targetContainer);
|
bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks whether the item in the specified hand can be dropped.
|
/// Checks whether the item in the specified hand can be dropped.
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace Content.Server.Mobs
|
|||||||
.PlayFromEntity(AudioHelpers.GetRandomFileFromSoundCollection("bodyfall"), entity, AudioHelpers.WithVariation(0.25f));
|
.PlayFromEntity(AudioHelpers.GetRandomFileFromSoundCollection("bodyfall"), entity, AudioHelpers.WithVariation(0.25f));
|
||||||
|
|
||||||
if(dropItems)
|
if(dropItems)
|
||||||
DropAllItemsInHands(entity);
|
DropAllItemsInHands(entity, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -61,13 +61,13 @@ namespace Content.Server.Mobs
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DropAllItemsInHands(IEntity entity)
|
public static void DropAllItemsInHands(IEntity entity, bool doMobChecks = true)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out IHandsComponent hands)) return;
|
if (!entity.TryGetComponent(out IHandsComponent hands)) return;
|
||||||
|
|
||||||
foreach (var heldItem in hands.GetAllHeldItems())
|
foreach (var heldItem in hands.GetAllHeldItems())
|
||||||
{
|
{
|
||||||
hands.Drop(heldItem.Owner);
|
hands.Drop(heldItem.Owner, doMobChecks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user