- fixed RGB staff. Нагло и совершенно бездумно спизжен код визденов
This commit is contained in:
@@ -2,6 +2,7 @@ using Content.Shared.Actions;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Server.Actions;
|
||||
|
||||
@@ -58,13 +59,21 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
|
||||
private void OnAfterInteract(EntityUid uid, ActionOnInteractComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (args.Handled || component.ActionEntities == null)
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (component.ActionEntities is not { } actionEnts)
|
||||
{
|
||||
if (!TryComp<ActionsContainerComponent>(uid, out var actionsContainerComponent))
|
||||
return;
|
||||
|
||||
actionEnts = actionsContainerComponent.Container.ContainedEntities.ToList();
|
||||
}
|
||||
|
||||
// First, try entity target actions
|
||||
if (args.Target != null)
|
||||
{
|
||||
var entOptions = GetValidActions<EntityTargetActionComponent>(component.ActionEntities, args.CanReach);
|
||||
var entOptions = GetValidActions<EntityTargetActionComponent>(actionEnts, args.CanReach);
|
||||
for (var i = entOptions.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var action = entOptions[i];
|
||||
@@ -77,8 +86,6 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
var (entActId, entAct) = _random.Pick(entOptions);
|
||||
if (entAct.Event != null)
|
||||
{
|
||||
entAct.Event.Performer = args.User;
|
||||
entAct.Event.Action = entActId;
|
||||
entAct.Event.Target = args.Target.Value;
|
||||
}
|
||||
|
||||
@@ -87,29 +94,6 @@ public sealed class ActionOnInteractSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// else: try world target actions
|
||||
var options = GetValidActions<WorldTargetActionComponent>(component.ActionEntities, args.CanReach);
|
||||
for (var i = options.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var action = options[i];
|
||||
if (!_actions.ValidateWorldTarget(args.User, args.ClickLocation, action))
|
||||
options.RemoveAt(i);
|
||||
}
|
||||
|
||||
if (options.Count == 0)
|
||||
return;
|
||||
|
||||
var (actId, act) = _random.Pick(options);
|
||||
if (act.Event != null)
|
||||
{
|
||||
act.Event.Performer = args.User;
|
||||
act.Event.Action = actId;
|
||||
act.Event.Target = args.ClickLocation;
|
||||
}
|
||||
|
||||
_actions.PerformAction(args.User, null, actId, act, act.Event, _timing.CurTime, false);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private bool ValidAction(BaseActionComponent action, bool canReach = true)
|
||||
|
||||
Reference in New Issue
Block a user