Fix monkey kitchen spike dragdrop (#3450)
* Fix monkey kitchen spike dragdrop I also aligned the behavior with tg (need combat mode on + mob alive). It still needs to do damage over time and buckle the target but baby steps. * Cleanup * Fix kitchenspike layers Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Content.Client.State;
|
using Content.Client.State;
|
||||||
using Content.Client.Utility;
|
using Content.Client.Utility;
|
||||||
using Content.Shared.GameObjects.EntitySystemMessages;
|
using Content.Shared.GameObjects.EntitySystemMessages;
|
||||||
@@ -313,22 +314,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
|
|
||||||
// check if it's able to be dropped on by current dragged entity
|
// check if it's able to be dropped on by current dragged entity
|
||||||
var dropArgs = new DragDropEventArgs(_dragger, args.Coordinates, _dragDropHelper.Dragged, entity);
|
var dropArgs = new DragDropEventArgs(_dragger, args.Coordinates, _dragDropHelper.Dragged, entity);
|
||||||
var valid = true;
|
|
||||||
var anyDragDrop = false;
|
|
||||||
var dragDropOn = new List<IDragDropOn>();
|
|
||||||
|
|
||||||
foreach (var comp in entity.GetAllComponents<IDragDropOn>())
|
// TODO: Cache valid CanDragDrops
|
||||||
{
|
if (ValidDragDrop(dropArgs) != true) continue;
|
||||||
anyDragDrop = true;
|
|
||||||
|
|
||||||
if (!comp.CanDragDropOn(dropArgs))
|
|
||||||
{
|
|
||||||
valid = false;
|
|
||||||
dragDropOn.Add(comp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid || !anyDragDrop) continue;
|
|
||||||
if (!dropArgs.InRangeUnobstructed(ignoreInsideBlocker: true))
|
if (!dropArgs.InRangeUnobstructed(ignoreInsideBlocker: true))
|
||||||
{
|
{
|
||||||
outOfRange = true;
|
outOfRange = true;
|
||||||
@@ -345,12 +334,6 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
|
|
||||||
draggable.Drop(dropArgs);
|
draggable.Drop(dropArgs);
|
||||||
|
|
||||||
// Don't fail if it isn't handled as server may do something with it
|
|
||||||
foreach (var comp in dragDropOn)
|
|
||||||
{
|
|
||||||
if (!comp.DragDropOn(dropArgs)) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
_dragDropHelper.EndDrag();
|
_dragDropHelper.EndDrag();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -394,21 +377,11 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
!inRangeSprite.Visible ||
|
!inRangeSprite.Visible ||
|
||||||
pvsEntity == _dragDropHelper.Dragged) continue;
|
pvsEntity == _dragDropHelper.Dragged) continue;
|
||||||
|
|
||||||
var valid = (bool?) null;
|
|
||||||
// check if it's able to be dropped on by current dragged entity
|
// check if it's able to be dropped on by current dragged entity
|
||||||
var dropArgs = new DragDropEventArgs(_dragger!, pvsEntity.Transform.Coordinates, _dragDropHelper.Dragged, pvsEntity);
|
var dropArgs = new DragDropEventArgs(_dragger!, pvsEntity.Transform.Coordinates, _dragDropHelper.Dragged, pvsEntity);
|
||||||
|
|
||||||
foreach (var comp in pvsEntity.GetAllComponents<IDragDropOn>())
|
var valid = ValidDragDrop(dropArgs);
|
||||||
{
|
if (valid == null) continue;
|
||||||
valid = comp.CanDragDropOn(dropArgs);
|
|
||||||
|
|
||||||
if (valid.Value)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can't do anything so no highlight
|
|
||||||
if (!valid.HasValue)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// We'll do a final check given server-side does this before any dragdrop can take place.
|
// We'll do a final check given server-side does this before any dragdrop can take place.
|
||||||
if (valid.Value)
|
if (valid.Value)
|
||||||
@@ -434,6 +407,43 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
_highlightedSprites.Clear();
|
_highlightedSprites.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Are these args valid for drag-drop?
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="eventArgs"></param>
|
||||||
|
/// <returns>null if the target doesn't support IDragDropOn</returns>
|
||||||
|
private bool? ValidDragDrop(DragDropEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
bool? valid = null;
|
||||||
|
|
||||||
|
foreach (var comp in eventArgs.Target.GetAllComponents<IDragDropOn>())
|
||||||
|
{
|
||||||
|
if (!comp.CanDragDropOn(eventArgs))
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
// dragDropOn.Add(comp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
valid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valid != true) return valid;
|
||||||
|
|
||||||
|
// Need at least one IDraggable to return true or else we can't do shit
|
||||||
|
valid = false;
|
||||||
|
|
||||||
|
foreach (var comp in eventArgs.User.GetAllComponents<IDraggable>())
|
||||||
|
{
|
||||||
|
if (!comp.CanDrop(eventArgs)) continue;
|
||||||
|
valid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ namespace Content.Client
|
|||||||
"Matchstick",
|
"Matchstick",
|
||||||
"Matchbox",
|
"Matchbox",
|
||||||
"BlockGameArcade",
|
"BlockGameArcade",
|
||||||
"Butcherable",
|
|
||||||
"Rehydratable",
|
"Rehydratable",
|
||||||
"Headset",
|
"Headset",
|
||||||
"ComputerBoard",
|
"ComputerBoard",
|
||||||
|
|||||||
@@ -168,11 +168,6 @@ namespace Content.Server.GameObjects.Components.Buckle
|
|||||||
|
|
||||||
if (!to.TryGetComponent(out strap))
|
if (!to.TryGetComponent(out strap))
|
||||||
{
|
{
|
||||||
var message = Loc.GetString(Owner == user
|
|
||||||
? "You can't buckle yourself there!"
|
|
||||||
: "You can't buckle {0:them} there!", Owner);
|
|
||||||
Owner.PopupMessage(user, message);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Server.GameObjects.EntitySystems.DoAfter;
|
|||||||
using Content.Server.Interfaces.Chat;
|
using Content.Server.Interfaces.Chat;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
using Content.Server.Utility;
|
using Content.Server.Utility;
|
||||||
|
using Content.Shared.GameObjects.Components.Nutrition;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Content.Shared.Kitchen;
|
using Content.Shared.Kitchen;
|
||||||
@@ -69,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Spikeable(IEntity user, IEntity victim, [NotNullWhen(true)] out ButcherableComponent? butcherable)
|
private bool Spikeable(IEntity user, IEntity victim, [NotNullWhen(true)] out SharedButcherableComponent? butcherable)
|
||||||
{
|
{
|
||||||
butcherable = null;
|
butcherable = null;
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
var victimUid = victim.Uid;
|
var victimUid = victim.Uid;
|
||||||
if (_beingButchered.Contains(victimUid)) return;
|
if (_beingButchered.Contains(victimUid)) return;
|
||||||
|
|
||||||
ButcherableComponent? butcherable;
|
SharedButcherableComponent? butcherable;
|
||||||
|
|
||||||
if (!Spikeable(user, victim, out butcherable)) return;
|
if (!Spikeable(user, victim, out butcherable)) return;
|
||||||
|
|
||||||
@@ -143,8 +144,11 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
}
|
}
|
||||||
|
|
||||||
Owner.PopupMessageEveryone(Loc.GetString("{0:theName} has forced {1:theName} onto the spike, killing them instantly!", user, victim));
|
Owner.PopupMessageEveryone(Loc.GetString("{0:theName} has forced {1:theName} onto the spike, killing them instantly!", user, victim));
|
||||||
|
// TODO: Need to be able to leave them on the spike to do DoT, see ss13.
|
||||||
victim.Delete();
|
victim.Delete();
|
||||||
return;
|
|
||||||
|
if (SpikeSound != null)
|
||||||
|
EntitySystem.Get<AudioSystem>().PlayFromEntity(SpikeSound, Owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
|
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Kitchen
|
namespace Content.Shared.GameObjects.Components.Nutrition
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates that the entity can be thrown on a kitchen spike for butchering.
|
/// Indicates that the entity can be thrown on a kitchen spike for butchering.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ButcherableComponent : Component
|
public class SharedButcherableComponent : Component, IDraggable
|
||||||
{
|
{
|
||||||
public override string Name => "Butcherable";
|
public override string Name => "Butcherable";
|
||||||
|
|
||||||
@@ -21,6 +22,10 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
[DataField("meat")]
|
[DataField("meat")]
|
||||||
private string? _meatPrototype;
|
private string? _meatPrototype;
|
||||||
|
|
||||||
|
public bool CanDrop(CanDropEventArgs args)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
using Content.Shared.GameObjects.Components.Mobs.State;
|
||||||
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
@@ -12,22 +13,25 @@ namespace Content.Shared.Kitchen
|
|||||||
{
|
{
|
||||||
public override string Name => "KitchenSpike";
|
public override string Name => "KitchenSpike";
|
||||||
|
|
||||||
[ViewVariables] [DataField("delay")] protected float SpikeDelay = 10;
|
[ViewVariables]
|
||||||
|
[DataField("delay")]
|
||||||
|
protected float SpikeDelay = 12.0f;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("sound")]
|
||||||
|
protected string? SpikeSound = "/Audio/Effects/Fluids/splat.ogg";
|
||||||
|
|
||||||
bool IDragDropOn.CanDragDropOn(DragDropEventArgs eventArgs)
|
bool IDragDropOn.CanDragDropOn(DragDropEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!eventArgs.Dragged.TryGetComponent<IMobStateComponent>(out var state))
|
if (eventArgs.User == eventArgs.Dragged ||
|
||||||
|
!eventArgs.Dragged.TryGetComponent<IMobStateComponent>(out var state) ||
|
||||||
|
(eventArgs.User.TryGetComponent(out SharedCombatModeComponent? combatMode) && !combatMode.IsInCombatMode))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Wouldn't we just need the CanMove check?
|
// TODO: Once we get silicons need to check organic
|
||||||
if (state.IsDead() || state.IsCritical() || state.IsIncapacitated() || !ActionBlockerSystem.CanMove(eventArgs.Dragged))
|
return !state.IsDead();
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract bool DragDropOn(DragDropEventArgs eventArgs);
|
public abstract bool DragDropOn(DragDropEventArgs eventArgs);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
mask:
|
mask:
|
||||||
- Impassable
|
- Impassable
|
||||||
layer:
|
layer:
|
||||||
- Impassable
|
- MobImpassable
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
# temp to make clickmask work
|
# temp to make clickmask work
|
||||||
sprite: Constructible/Misc/kitchen.rsi
|
sprite: Constructible/Misc/kitchen.rsi
|
||||||
|
|||||||
Reference in New Issue
Block a user