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)
|
||||
{
|
||||
Logger.Debug(IoCManager.Resolve<IGameTiming>().CurTick.ToString());
|
||||
weapon.SyncFirePos(worldPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Content.Server.GameObjects
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Drop(string slot, GridCoordinates coords)
|
||||
public bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true)
|
||||
{
|
||||
if (!CanDrop(slot))
|
||||
{
|
||||
@@ -204,7 +204,7 @@ namespace Content.Server.GameObjects
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
||||
if (doMobChecks && !_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
||||
return false;
|
||||
|
||||
item.RemovedFromSlot();
|
||||
@@ -216,7 +216,7 @@ namespace Content.Server.GameObjects
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Drop(IEntity entity, GridCoordinates coords)
|
||||
public bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
@@ -242,7 +242,7 @@ namespace Content.Server.GameObjects
|
||||
var inventorySlot = hands[slot];
|
||||
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;
|
||||
|
||||
if (!inventorySlot.Remove(inventorySlot.ContainedEntity))
|
||||
@@ -263,7 +263,7 @@ namespace Content.Server.GameObjects
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Drop(IEntity entity)
|
||||
public bool Drop(IEntity entity, bool doMobChecks = true)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -296,8 +296,15 @@ namespace Content.Server.GameObjects
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var inventorySlot = hands[slot];
|
||||
var item = inventorySlot.ContainedEntity.GetComponent<ItemComponent>();
|
||||
|
||||
if (doMobChecks && !_entitySystemManager.GetEntitySystem<InteractionSystem>().TryDroppedInteraction(Owner, item.Owner))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!inventorySlot.CanRemove(inventorySlot.ContainedEntity))
|
||||
{
|
||||
return false;
|
||||
@@ -324,7 +331,7 @@ namespace Content.Server.GameObjects
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Drop(IEntity entity, BaseContainer targetContainer)
|
||||
public bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
return Drop(slot, targetContainer);
|
||||
return Drop(slot, targetContainer, doMobChecks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
}
|
||||
else
|
||||
{
|
||||
StandingStateHelper.DropAllItemsInHands(mob);
|
||||
StandingStateHelper.DropAllItemsInHands(mob, false);
|
||||
}
|
||||
|
||||
InstrumentPlayer = null;
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace Content.Server.GameObjects
|
||||
if(entity.TryGetComponent(out StunnableComponent stun))
|
||||
stun.CancelAll();
|
||||
|
||||
StandingStateHelper.Down(entity, playSound:false);
|
||||
StandingStateHelper.Down(entity);
|
||||
|
||||
if (entity.TryGetComponent(out CollidableComponent collidable))
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
if (seconds <= 0f)
|
||||
return;
|
||||
|
||||
StandingStateHelper.DropAllItemsInHands(Owner);
|
||||
StandingStateHelper.DropAllItemsInHands(Owner, false);
|
||||
|
||||
_stunnedTimer = seconds;
|
||||
_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.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
bool Drop(string slot);
|
||||
bool Drop(string slot, bool doMobChecks = true);
|
||||
|
||||
/// <summary>
|
||||
/// Drops an item held by one of our hand slots to the same position as our owning entity.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// Thrown if <see cref="entity"/> is null.
|
||||
@@ -94,15 +96,16 @@ namespace Content.Server.Interfaces.GameObjects
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
||||
/// </exception>
|
||||
bool Drop(IEntity entity);
|
||||
bool Drop(IEntity entity, bool doMobChecks = true);
|
||||
|
||||
/// <summary>
|
||||
/// Drops the item in a slot.
|
||||
/// </summary>
|
||||
/// <param name="slot">The slot to drop the item from.</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>
|
||||
bool Drop(string slot, GridCoordinates coords);
|
||||
bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true);
|
||||
|
||||
/// <summary>
|
||||
/// Drop the specified entity in our hands to a certain position.
|
||||
@@ -113,6 +116,7 @@ namespace Content.Server.Interfaces.GameObjects
|
||||
/// </remarks>
|
||||
/// <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="doMobChecks">Whether to check the <see cref="ActionBlockerSystem.CanDrop()"/> for the mob or not.</param>
|
||||
/// <returns>
|
||||
/// True if the drop succeeded,
|
||||
/// 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">
|
||||
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
||||
/// </exception>
|
||||
bool Drop(IEntity entity, GridCoordinates coords);
|
||||
bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true);
|
||||
|
||||
/// <summary>
|
||||
/// Drop the item contained in a slot into another container.
|
||||
/// </summary>
|
||||
/// <param name="slot">The slot of which to drop the entity.</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>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if dry-run checks reported OK to remove and insert,
|
||||
/// but practical remove or insert returned false anyways.
|
||||
/// This is an edge-case that is currently unhandled.
|
||||
/// </exception>
|
||||
bool Drop(string slot, BaseContainer targetContainer);
|
||||
bool Drop(string slot, BaseContainer targetContainer, bool doMobChecks = true);
|
||||
|
||||
/// <summary>
|
||||
/// Drops an item in one of the hands into a container.
|
||||
/// </summary>
|
||||
/// <param name="entity">The item to drop.</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>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if dry-run checks reported OK to remove and insert,
|
||||
@@ -155,7 +161,7 @@ namespace Content.Server.Interfaces.GameObjects
|
||||
/// <exception cref="ArgumentException">
|
||||
/// Thrown if <see cref="entity"/> is not actually held in any hand.
|
||||
/// </exception>
|
||||
bool Drop(IEntity entity, BaseContainer targetContainer);
|
||||
bool Drop(IEntity entity, BaseContainer targetContainer, bool doMobChecks = true);
|
||||
|
||||
/// <summary>
|
||||
/// 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));
|
||||
|
||||
if(dropItems)
|
||||
DropAllItemsInHands(entity);
|
||||
DropAllItemsInHands(entity, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -61,13 +61,13 @@ namespace Content.Server.Mobs
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void DropAllItemsInHands(IEntity entity)
|
||||
public static void DropAllItemsInHands(IEntity entity, bool doMobChecks = true)
|
||||
{
|
||||
if (!entity.TryGetComponent(out IHandsComponent hands)) return;
|
||||
|
||||
foreach (var heldItem in hands.GetAllHeldItems())
|
||||
{
|
||||
hands.Drop(heldItem.Owner);
|
||||
hands.Drop(heldItem.Owner, doMobChecks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user