Add popup message extension for players in range except for the source (#1962)

This commit is contained in:
DrSmugleaf
2020-08-30 11:28:46 +02:00
committed by GitHub
parent 827eab17d0
commit 9ec3ddf368
6 changed files with 100 additions and 79 deletions

View File

@@ -8,7 +8,7 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameObjects;
using Content.Server.GameObjects.EntitySystems.DoAfter;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Interactable;
@@ -17,7 +17,6 @@ using Content.Shared.Interfaces;
using Robust.Server.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -258,16 +257,31 @@ namespace Content.Server.GameObjects.Components.Interactable
public SuicideKind Suicide(IEntity victim, IChatManager chat)
{
string othersMessage;
string selfMessage;
if (TryWeld(5, victim, silent: true))
{
PlaySoundCollection(WeldSoundCollection);
PopupMessageOtherClientsInRange(victim, Loc.GetString("{0:theName} welds {0:their} every orifice closed! It looks like {0:theyre} trying to commit suicide!", victim), 15);
_notifyManager.PopupMessage(victim, victim, Loc.GetString("You weld your every orifice closed!"));
othersMessage =
Loc.GetString(
"{0:theName} welds {0:their} every orifice closed! It looks like {0:theyre} trying to commit suicide!",
victim);
victim.PopupMessageOtherClients(othersMessage);
selfMessage = Loc.GetString("You weld your every orifice closed!");
victim.PopupMessage(selfMessage);
return SuicideKind.Heat;
}
PopupMessageOtherClientsInRange(victim, Loc.GetString("{0:theName} bashes themselves with the unlit welding torch!", victim), 15);
_notifyManager.PopupMessage(victim, victim, Loc.GetString("You bash yourself with the unlit welding torch!"));
othersMessage = Loc.GetString("{0:theName} bashes themselves with the unlit welding torch!", victim);
victim.PopupMessageOtherClients(othersMessage);
selfMessage = Loc.GetString("You bash yourself with the unlit welding torch!");
victim.PopupMessage(selfMessage);
return SuicideKind.Blunt;
}
@@ -275,22 +289,5 @@ namespace Content.Server.GameObjects.Components.Interactable
{
Dirty();
}
private void PopupMessageOtherClientsInRange(IEntity source, string message, int maxReceiveDistance)
{
var viewers = _playerManager.GetPlayersInRange(source.Transform.GridPosition, maxReceiveDistance);
foreach (var viewer in viewers)
{
var viewerEntity = viewer.AttachedEntity;
if (viewerEntity == null || source == viewerEntity)
{
continue;
}
source.PopupMessage(viewer.AttachedEntity, message);
}
}
}
}

View File

@@ -500,29 +500,18 @@ namespace Content.Server.GameObjects.Components.Kitchen
headCount++;
}
}
PopupMessageOtherClientsInRange(victim, Loc.GetString("{0:theName} is trying to cook {0:their} head!", victim), 15);
_notifyManager.PopupMessage(victim, victim, Loc.GetString("You cook your head!"));
var othersMessage = Loc.GetString("{0:theName} is trying to cook {0:their} head!", victim);
victim.PopupMessageOtherClients(othersMessage);
var selfMessage = Loc.GetString("You cook your head!");
victim.PopupMessage(selfMessage);
_currentCookTimerTime = 10;
ClickSound();
_uiDirty = true;
wzhzhzh();
return SuicideKind.Heat;
}
private void PopupMessageOtherClientsInRange(IEntity source, string message, int maxReceiveDistance)
{
var viewers = _playerManager.GetPlayersInRange(source.Transform.GridPosition, maxReceiveDistance);
foreach (var viewer in viewers)
{
var viewerEntity = viewer.AttachedEntity;
if (viewerEntity == null || source == viewerEntity)
{
continue;
}
source.PopupMessage(viewer.AttachedEntity, message);
}
}
}
}

View File

@@ -17,6 +17,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System;
using Content.Server.Utility;
namespace Content.Server.GameObjects.Components.Movement
{
@@ -207,8 +208,12 @@ namespace Content.Server.GameObjects.Components.Movement
// we may potentially need additional logic since we're forcing a player onto a climbable
// there's also the cases where the user might collide with the person they are forcing onto the climbable that i haven't accounted for
PopupMessageOtherClientsInRange(user, Loc.GetString("{0:theName} forces {1:theName} onto {2:theName}!", user, entityToMove, Owner), 15);
user.PopupMessage(user, Loc.GetString("You force {0:theName} onto {1:theName}!", entityToMove, Owner));
var othersMessage = Loc.GetString("{0:theName} forces {1:theName} onto {2:theName}!", user,
entityToMove, Owner);
user.PopupMessageOtherClients(othersMessage);
var selfMessage = Loc.GetString("You force {0:theName} onto {1:theName}!", entityToMove, Owner);
user.PopupMessage(selfMessage);
}
}
@@ -243,25 +248,11 @@ namespace Content.Server.GameObjects.Components.Movement
climbMode.TryMoveTo(user.Transform.WorldPosition, endPoint);
PopupMessageOtherClientsInRange(user, Loc.GetString("{0:theName} jumps onto {1:theName}!", user, Owner), 15);
user.PopupMessage(user, Loc.GetString("You jump onto {0:theName}!", Owner));
}
}
var othersMessage = Loc.GetString("{0:theName} jumps onto {1:theName}!", user, Owner);
user.PopupMessageOtherClients(othersMessage);
private void PopupMessageOtherClientsInRange(IEntity source, string message, int maxReceiveDistance)
{
var viewers = _playerManager.GetPlayersInRange(source.Transform.GridPosition, maxReceiveDistance);
foreach (var viewer in viewers)
{
var viewerEntity = viewer.AttachedEntity;
if (viewerEntity == null || source == viewerEntity)
{
continue;
}
source.PopupMessage(viewer.AttachedEntity, message);
var selfMessage = Loc.GetString("You jump onto {0:theName}!", Owner);
user.PopupMessage(selfMessage);
}
}