SubscribeEvent() has been split into SubscribeNetworkEvent() and SubscribeLocalEvent() methods on EntitySystem.

Most methods on EntityEventBus now require callers to specify the source (Local or Network) of the events.
This commit is contained in:
Acruid
2020-02-19 17:08:59 -08:00
parent e719745b10
commit ee6eec9c40
18 changed files with 42 additions and 41 deletions

View File

@@ -81,7 +81,7 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
base.Startup();
SnapGrid.OnPositionChanged += SnapGridOnPositionChanged;
Owner.EntityManager.EventBus.RaiseEvent(new IconSmoothDirtyEvent(Owner,null, SnapGrid.Offset, Mode));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, 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(new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
}
private void SnapGridOnPositionChanged()
{
Owner.EntityManager.EventBus.RaiseEvent(new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode));
_lastPosition = (Owner.Transform.GridID, SnapGrid.Position);
}

View File

@@ -33,7 +33,7 @@ namespace Content.Client.GameObjects.Components
base.Startup();
_snapGridComponent.OnPositionChanged += SnapGridOnPositionChanged;
Owner.EntityManager.EventBus.RaiseEvent(new SubFloorHideDirtyEvent(Owner));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new SubFloorHideDirtyEvent(Owner));
}
/// <inheritdoc />
@@ -45,12 +45,12 @@ namespace Content.Client.GameObjects.Components
return;
_snapGridComponent.OnPositionChanged -= SnapGridOnPositionChanged;
Owner.EntityManager.EventBus.RaiseEvent(new SubFloorHideDirtyEvent(Owner));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new SubFloorHideDirtyEvent(Owner));
}
private void SnapGridOnPositionChanged()
{
Owner.EntityManager.EventBus.RaiseEvent(new SubFloorHideDirtyEvent(Owner));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new SubFloorHideDirtyEvent(Owner));
}
}

View File

@@ -31,7 +31,7 @@ namespace Content.Client.GameObjects.Components
base.Startup();
_snapGrid.OnPositionChanged += SnapGridOnPositionChanged;
Owner.EntityManager.EventBus.RaiseEvent(new WindowSmoothDirtyEvent(Owner));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, 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(new WindowSmoothDirtyEvent(Owner));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new WindowSmoothDirtyEvent(Owner));
}
public void UpdateSprite()

View File

@@ -111,7 +111,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
_requestCancelTokenSource = new CancellationTokenSource();
response =
await AwaitNetMessage<ExamineSystemMessages.ExamineInfoResponseMessage>(_requestCancelTokenSource
await AwaitNetworkEvent<ExamineSystemMessages.ExamineInfoResponseMessage>(_requestCancelTokenSource
.Token);
}
catch (TaskCanceledException)

View File

@@ -30,7 +30,7 @@ namespace Content.Client.GameObjects.EntitySystems
/// <inheritdoc />
public override void Initialize()
{
SubscribeEvent<IconSmoothDirtyEvent>(HandleDirtyEvent);
SubscribeLocalEvent<IconSmoothDirtyEvent>(HandleDirtyEvent);
IoCManager.InjectDependencies(this);
}

View File

@@ -23,7 +23,7 @@ namespace Content.Client.GameObjects.EntitySystems
public override void Initialize()
{
SubscribeEvent<PlayMeleeWeaponAnimationMessage>(PlayWeaponArc);
SubscribeNetworkEvent<PlayMeleeWeaponAnimationMessage>(PlayWeaponArc);
EntityQuery = new TypeEntityQuery(typeof(MeleeWeaponArcAnimationComponent));
}

View File

@@ -28,7 +28,7 @@ namespace Content.Client.GameObjects.EntitySystems
_mapManager.GridChanged += MapManagerOnGridChanged;
_mapManager.TileChanged += MapManagerOnTileChanged;
SubscribeEvent<SubFloorHideDirtyEvent>(HandleDirtyEvent);
SubscribeLocalEvent<SubFloorHideDirtyEvent>(HandleDirtyEvent);
}
private void HandleDirtyEvent(SubFloorHideDirtyEvent ev)

View File

@@ -40,7 +40,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
base.Initialize();
SubscribeEvent<VerbSystemMessages.VerbsResponseMessage>(FillEntityPopup);
SubscribeNetworkEvent<VerbSystemMessages.VerbsResponseMessage>(FillEntityPopup);
IoCManager.InjectDependencies(this);

View File

@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
base.Initialize();
SubscribeEvent<WindowSmoothDirtyEvent>(HandleDirtyEvent);
SubscribeLocalEvent<WindowSmoothDirtyEvent>(HandleDirtyEvent);
}
private void HandleDirtyEvent(WindowSmoothDirtyEvent ev)

View File

@@ -168,7 +168,8 @@ namespace Content.Server.GameObjects
currentstate = threshold;
Owner.RaiseEvent(new MobDamageStateChangedMessage(this));
EntityEventArgs toRaise = new MobDamageStateChangedMessage(this);
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, toRaise);
}
void IExAct.OnExplosion(ExplosionEventArgs eventArgs)

View File

@@ -35,7 +35,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeEvent<ExamineSystemMessages.RequestExamineInfoMessage>(ExamineInfoRequest);
SubscribeNetworkEvent<ExamineSystemMessages.RequestExamineInfoMessage>(ExamineInfoRequest);
IoCManager.InjectDependencies(this);
}

View File

@@ -333,7 +333,7 @@ namespace Content.Server.GameObjects.EntitySystems
private void InteractionActivate(IEntity user, IEntity used)
{
var activateMsg = new ActivateInWorldMessage(user, used);
RaiseEvent(activateMsg);
RaiseLocalEvent(activateMsg);
if (activateMsg.Handled)
{
return;
@@ -509,7 +509,7 @@ namespace Content.Server.GameObjects.EntitySystems
private void InteractAfterAttack(IEntity user, IEntity weapon, GridCoordinates clickLocation)
{
var message = new AfterAttackMessage(user, weapon, null, clickLocation);
RaiseEvent(message);
RaiseLocalEvent(message);
if (message.Handled)
{
return;
@@ -531,7 +531,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void Interaction(IEntity user, IEntity weapon, IEntity attacked, GridCoordinates clickLocation)
{
var attackMsg = new AttackByMessage(user, weapon, attacked, clickLocation);
RaiseEvent(attackMsg);
RaiseLocalEvent(attackMsg);
if (attackMsg.Handled)
{
return;
@@ -553,7 +553,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
var afterAtkMsg = new AfterAttackMessage(user, weapon, attacked, clickLocation);
RaiseEvent(afterAtkMsg);
RaiseLocalEvent(afterAtkMsg);
if (afterAtkMsg.Handled)
{
return;
@@ -579,7 +579,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void Interaction(IEntity user, IEntity attacked)
{
var message = new AttackHandMessage(user, attacked);
RaiseEvent(message);
RaiseLocalEvent(message);
if (message.Handled)
{
return;
@@ -630,7 +630,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
var useMsg = new UseInHandMessage(user, used);
RaiseEvent(useMsg);
RaiseLocalEvent(useMsg);
if (useMsg.Handled)
{
return;
@@ -668,7 +668,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void ThrownInteraction(IEntity user, IEntity thrown)
{
var throwMsg = new ThrownMessage(user, thrown);
RaiseEvent(throwMsg);
RaiseLocalEvent(throwMsg);
if (throwMsg.Handled)
{
return;
@@ -690,7 +690,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void LandInteraction(IEntity user, IEntity landing, GridCoordinates landLocation)
{
var landMsg = new LandMessage(user, landing, landLocation);
RaiseEvent(landMsg);
RaiseLocalEvent(landMsg);
if (landMsg.Handled)
{
return;
@@ -724,7 +724,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void DroppedInteraction(IEntity user, IEntity item)
{
var dropMsg = new DroppedMessage(user, item);
RaiseEvent(dropMsg);
RaiseLocalEvent(dropMsg);
if (dropMsg.Handled)
{
return;
@@ -746,7 +746,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void HandSelectedInteraction(IEntity user, IEntity item)
{
var handSelectedMsg = new HandSelectedMessage(user, item);
RaiseEvent(handSelectedMsg);
RaiseLocalEvent(handSelectedMsg);
if (handSelectedMsg.Handled)
{
return;
@@ -768,7 +768,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void HandDeselectedInteraction(IEntity user, IEntity item)
{
var handDeselectedMsg = new HandDeselectedMessage(user, item);
RaiseEvent(handDeselectedMsg);
RaiseLocalEvent(handDeselectedMsg);
if (handDeselectedMsg.Handled)
{
return;
@@ -791,7 +791,7 @@ namespace Content.Server.GameObjects.EntitySystems
public void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, GridCoordinates clickLocation)
{
var rangedMsg = new RangedAttackMessage(user, weapon, attacked, clickLocation);
RaiseEvent(rangedMsg);
RaiseLocalEvent(rangedMsg);
if (rangedMsg.Handled)
return;
@@ -812,7 +812,7 @@ namespace Content.Server.GameObjects.EntitySystems
}
var afterAtkMsg = new AfterAttackMessage(user, weapon, attacked, clickLocation);
RaiseEvent(afterAtkMsg);
RaiseLocalEvent(afterAtkMsg);
if (afterAtkMsg.Handled)
return;

View File

@@ -23,8 +23,8 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeEvent<SetTargetZoneMessage>(SetTargetZoneHandler);
SubscribeEvent<SetCombatModeActiveMessage>(SetCombatModeActiveHandler);
SubscribeNetworkEvent<SetTargetZoneMessage>(SetTargetZoneHandler);
SubscribeNetworkEvent<SetCombatModeActiveMessage>(SetCombatModeActiveHandler);
var inputSystem = EntitySystemManager.GetEntitySystem<InputSystem>();
inputSystem.BindMap.BindFunction(ContentKeyFunctions.ToggleCombatMode,

View File

@@ -41,8 +41,8 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeEvent<EntRemovedFromContainerMessage>(HandleContainerModified);
SubscribeEvent<EntInsertedIntoContainerMessage>(HandleContainerModified);
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleContainerModified);
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleContainerModified);
var input = EntitySystemManager.GetEntitySystem<InputSystem>();
input.BindMap.BindFunction(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands));

View File

@@ -74,8 +74,8 @@ namespace Content.Server.GameObjects.EntitySystems
input.BindMap.BindFunction(EngineKeyFunctions.MoveDown, moveDownCmdHandler);
input.BindMap.BindFunction(EngineKeyFunctions.Run, runCmdHandler);
SubscribeEvent<PlayerAttachSystemMessage>(PlayerAttached);
SubscribeEvent<PlayerDetachedSystemMessage>(PlayerDetached);
SubscribeLocalEvent<PlayerAttachSystemMessage>(PlayerAttached);
SubscribeLocalEvent<PlayerDetachedSystemMessage>(PlayerDetached);
_audioSystem = EntitySystemManager.GetEntitySystem<AudioSystem>();
}

View File

@@ -14,8 +14,8 @@ namespace Content.Server.GameObjects.EntitySystems
/// <inheritdoc />
public override void Initialize()
{
SubscribeEvent<EntRemovedFromContainerMessage>(HandleEntityRemovedFromContainer);
SubscribeEvent<EntInsertedIntoContainerMessage>(HandleEntityInsertedIntoContainer);
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleEntityRemovedFromContainer);
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleEntityInsertedIntoContainer);
EntityQuery = new TypeEntityQuery(typeof(ServerStorageComponent));
}

View File

@@ -20,8 +20,8 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
SubscribeEvent<RequestVerbsMessage>(RequestVerbs);
SubscribeEvent<UseVerbMessage>(UseVerb);
SubscribeNetworkEvent<RequestVerbsMessage>(RequestVerbs);
SubscribeNetworkEvent<UseVerbMessage>(UseVerb);
IoCManager.InjectDependencies(this);
}

View File

@@ -34,7 +34,7 @@ namespace Content.Server.GameTicking.GameRules
{
_chatManager.DispatchServerAnnouncement("The game is now a death match. Kill everybody else to win!");
_entityManager.EventBus.SubscribeEvent<MobDamageStateChangedMessage>(_onMobDamageStateChanged, this);
_entityManager.EventBus.SubscribeEvent<MobDamageStateChangedMessage>(EventSource.Local, this, _onMobDamageStateChanged);
_playerManager.PlayerStatusChanged += PlayerManagerOnPlayerStatusChanged;
}
@@ -42,7 +42,7 @@ namespace Content.Server.GameTicking.GameRules
{
base.Removed();
_entityManager.EventBus.UnsubscribeEvent<MobDamageStateChangedMessage>(this);
_entityManager.EventBus.UnsubscribeEvent<MobDamageStateChangedMessage>(EventSource.Local, this);
_playerManager.PlayerStatusChanged -= PlayerManagerOnPlayerStatusChanged;
}