Drop items on entering dead or crit states (#1082)

* Drop items on dead or crit
This commit is contained in:
Víctor Aguilera Puerto
2020-06-07 16:48:53 +02:00
committed by GitHub
parent 21c41f28ed
commit 952fa9f7ed
7 changed files with 36 additions and 24 deletions

View File

@@ -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>

View File

@@ -322,7 +322,7 @@ namespace Content.Server.GameObjects.Components.Instruments
}
else
{
StandingStateHelper.DropAllItemsInHands(mob);
StandingStateHelper.DropAllItemsInHands(mob, false);
}
InstrumentPlayer = null;

View File

@@ -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))
{

View File

@@ -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;