Removed the Sender object from events. If you needed this field, add it to the event class.
This commit is contained in:
@@ -81,7 +81,7 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
base.Startup();
|
||||
|
||||
SnapGrid.OnPositionChanged += SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new IconSmoothDirtyEvent(null, SnapGrid.Offset, Mode));
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new IconSmoothDirtyEvent(Owner,null, SnapGrid.Offset, Mode));
|
||||
if (Mode == IconSmoothingMode.Corners)
|
||||
{
|
||||
var state0 = $"{StateBase}0";
|
||||
@@ -203,12 +203,12 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
base.Shutdown();
|
||||
|
||||
SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new IconSmoothDirtyEvent(_lastPosition, SnapGrid.Offset, Mode));
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
|
||||
}
|
||||
|
||||
private void SnapGridOnPositionChanged()
|
||||
{
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new IconSmoothDirtyEvent(_lastPosition, SnapGrid.Offset, Mode));
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
|
||||
_lastPosition = (Owner.Transform.GridID, SnapGrid.Position);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
@@ -32,7 +33,7 @@ namespace Content.Client.GameObjects.Components
|
||||
base.Startup();
|
||||
|
||||
_snapGridComponent.OnPositionChanged += SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new SubFloorHideDirtyEvent());
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new SubFloorHideDirtyEvent(Owner));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -44,14 +45,22 @@ namespace Content.Client.GameObjects.Components
|
||||
return;
|
||||
|
||||
_snapGridComponent.OnPositionChanged -= SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new SubFloorHideDirtyEvent());
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new SubFloorHideDirtyEvent(Owner));
|
||||
}
|
||||
|
||||
private void SnapGridOnPositionChanged()
|
||||
{
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new SubFloorHideDirtyEvent());
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new SubFloorHideDirtyEvent(Owner));
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class SubFloorHideDirtyEvent : EntitySystemMessage { }
|
||||
internal sealed class SubFloorHideDirtyEvent : EntitySystemMessage
|
||||
{
|
||||
public IEntity Sender { get; }
|
||||
|
||||
public SubFloorHideDirtyEvent(IEntity sender)
|
||||
{
|
||||
Sender = sender;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Content.Client.GameObjects.Components
|
||||
base.Startup();
|
||||
|
||||
_snapGrid.OnPositionChanged += SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new WindowSmoothDirtyEvent());
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new WindowSmoothDirtyEvent(Owner));
|
||||
|
||||
var state0 = $"{_stateBase}0";
|
||||
_sprite.LayerMapSet(CornerLayers.SE, _sprite.AddLayerState(state0));
|
||||
@@ -54,7 +54,7 @@ namespace Content.Client.GameObjects.Components
|
||||
|
||||
private void SnapGridOnPositionChanged()
|
||||
{
|
||||
Owner.EntityManager.EventBus.RaiseEvent(Owner, new WindowSmoothDirtyEvent());
|
||||
Owner.EntityManager.EventBus.RaiseEvent(new WindowSmoothDirtyEvent(Owner));
|
||||
}
|
||||
|
||||
public void UpdateSprite()
|
||||
|
||||
@@ -53,11 +53,12 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDirtyEvent(object sender, IconSmoothDirtyEvent ev)
|
||||
private void HandleDirtyEvent(IconSmoothDirtyEvent ev)
|
||||
{
|
||||
// Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us.
|
||||
// This is simpler to implement. If you want to optimize it be my guest.
|
||||
if (sender is IEntity senderEnt && senderEnt.IsValid() &&
|
||||
var senderEnt = ev.Sender;
|
||||
if (senderEnt.IsValid() &&
|
||||
senderEnt.TryGetComponent(out IconSmoothComponent iconSmooth)
|
||||
&& iconSmooth.Running)
|
||||
{
|
||||
@@ -137,15 +138,17 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
/// </summary>
|
||||
public sealed class IconSmoothDirtyEvent : EntitySystemMessage
|
||||
{
|
||||
public IconSmoothDirtyEvent((GridId grid, MapIndices pos)? lastPosition, SnapGridOffset offset, IconSmoothingMode mode)
|
||||
public IconSmoothDirtyEvent(IEntity sender, (GridId grid, MapIndices pos)? lastPosition, SnapGridOffset offset, IconSmoothingMode mode)
|
||||
{
|
||||
LastPosition = lastPosition;
|
||||
Offset = offset;
|
||||
Mode = mode;
|
||||
Sender = sender;
|
||||
}
|
||||
|
||||
public (GridId grid, MapIndices pos)? LastPosition { get; }
|
||||
public SnapGridOffset Offset { get; }
|
||||
public IconSmoothingMode Mode { get; }
|
||||
public IEntity Sender { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayWeaponArc(object sender, PlayMeleeWeaponAnimationMessage msg)
|
||||
private void PlayWeaponArc(PlayMeleeWeaponAnimationMessage msg)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(msg.ArcPrototype, out MeleeWeaponAnimationPrototype weaponArc))
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using Content.Shared.Maps;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -32,15 +31,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
SubscribeEvent<SubFloorHideDirtyEvent>(HandleDirtyEvent);
|
||||
}
|
||||
|
||||
private void HandleDirtyEvent(object sender, SubFloorHideDirtyEvent ev)
|
||||
private void HandleDirtyEvent(SubFloorHideDirtyEvent ev)
|
||||
{
|
||||
if (!(sender is IEntity senderEnt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var grid = _mapManager.GetGrid(senderEnt.Transform.GridID);
|
||||
var indices = grid.WorldToTile(senderEnt.Transform.WorldPosition);
|
||||
var grid = _mapManager.GetGrid(ev.Sender.Transform.GridID);
|
||||
var indices = grid.WorldToTile(ev.Sender.Transform.WorldPosition);
|
||||
UpdateTile(grid, indices);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
OpenContextMenu(entity, new ScreenCoordinates(_inputManager.MouseScreenPosition));
|
||||
}
|
||||
|
||||
private void FillEntityPopup(object sender, VerbSystemMessages.VerbsResponseMessage msg)
|
||||
private void FillEntityPopup(VerbSystemMessages.VerbsResponseMessage msg)
|
||||
{
|
||||
if (_currentEntity != msg.Entity || !_entityManager.TryGetEntity(_currentEntity, out var entity))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -19,11 +19,11 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
SubscribeEvent<WindowSmoothDirtyEvent>(HandleDirtyEvent);
|
||||
}
|
||||
|
||||
private void HandleDirtyEvent(object sender, WindowSmoothDirtyEvent ev)
|
||||
private void HandleDirtyEvent(WindowSmoothDirtyEvent ev)
|
||||
{
|
||||
if (sender is IEntity senderEnt && senderEnt.HasComponent<WindowComponent>())
|
||||
if (ev.Sender.HasComponent<WindowComponent>())
|
||||
{
|
||||
_dirtyEntities.Enqueue(senderEnt);
|
||||
_dirtyEntities.Enqueue(ev.Sender);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,5 +50,11 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
/// </summary>
|
||||
public sealed class WindowSmoothDirtyEvent : EntitySystemMessage
|
||||
{
|
||||
public IEntity Sender { get; }
|
||||
|
||||
public WindowSmoothDirtyEvent(IEntity sender)
|
||||
{
|
||||
Sender = sender;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user