Improve hands & pulling (#4389)
This commit is contained in:
committed by
GitHub
parent
73e4946e27
commit
632e72b817
@@ -50,6 +50,8 @@ namespace Content.Shared.Pulling.Components
|
||||
return;
|
||||
}
|
||||
|
||||
var eventBus = Owner.EntityManager.EventBus;
|
||||
|
||||
// New value. Abandon being pulled by any existing object.
|
||||
if (_puller != null)
|
||||
{
|
||||
@@ -64,10 +66,9 @@ namespace Content.Shared.Pulling.Components
|
||||
{
|
||||
var message = new PullStoppedMessage(oldPullerPhysics, _physics);
|
||||
|
||||
oldPuller.SendMessage(null, message);
|
||||
Owner.SendMessage(null, message);
|
||||
eventBus.RaiseLocalEvent(oldPuller.Uid, message, broadcast: false);
|
||||
eventBus.RaiseLocalEvent(Owner.Uid, message);
|
||||
|
||||
oldPuller.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
|
||||
_physics.WakeBody();
|
||||
}
|
||||
// else-branch warning is handled below
|
||||
@@ -125,14 +126,14 @@ namespace Content.Shared.Pulling.Components
|
||||
|
||||
var pullAttempt = new PullAttemptMessage(pullerPhysics, _physics);
|
||||
|
||||
value.SendMessage(null, pullAttempt);
|
||||
eventBus.RaiseLocalEvent(value.Uid, pullAttempt, broadcast: false);
|
||||
|
||||
if (pullAttempt.Cancelled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Owner.SendMessage(null, pullAttempt);
|
||||
eventBus.RaiseLocalEvent(Owner.Uid, pullAttempt);
|
||||
|
||||
if (pullAttempt.Cancelled)
|
||||
{
|
||||
@@ -147,10 +148,8 @@ namespace Content.Shared.Pulling.Components
|
||||
|
||||
var message = new PullStartedMessage(PullerPhysics, _physics);
|
||||
|
||||
_puller.SendMessage(null, message);
|
||||
Owner.SendMessage(null, message);
|
||||
|
||||
_puller.EntityManager.EventBus.RaiseEvent(EventSource.Local, message);
|
||||
eventBus.RaiseLocalEvent(_puller.Uid, message, broadcast: false);
|
||||
eventBus.RaiseLocalEvent(Owner.Uid, message);
|
||||
|
||||
var union = PullerPhysics.GetWorldAABB().Union(_physics.GetWorldAABB());
|
||||
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
|
||||
@@ -335,29 +334,6 @@ namespace Content.Shared.Pulling.Components
|
||||
Puller = entity;
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
|
||||
if (message is not PullMessage pullMessage ||
|
||||
pullMessage.Pulled.Owner != Owner)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pulledStatus = Owner.GetComponentOrNull<SharedAlertsComponent>();
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case PullStartedMessage:
|
||||
pulledStatus?.ShowAlert(AlertType.Pulled);
|
||||
break;
|
||||
case PullStoppedMessage:
|
||||
pulledStatus?.ClearAlert(AlertType.Pulled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRemove()
|
||||
{
|
||||
TryStopPull();
|
||||
|
||||
Reference in New Issue
Block a user