Add interaction checks to all interactions (#923)

This commit is contained in:
chairbender
2020-05-23 02:27:31 -07:00
committed by GitHub
parent af0ec2aeb9
commit 6a4d78cfac
63 changed files with 311 additions and 101 deletions

View File

@@ -4,6 +4,7 @@ using Content.Shared.GameObjects.Components.Markers;
using Robust.Client.Interfaces.Console;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
@@ -48,8 +49,7 @@ namespace Content.Client.Commands
public bool Execute(IDebugConsole console, params string[] args)
{
IoCManager.Resolve<IEntitySystemManager>()
.GetEntitySystem<SubFloorHideSystem>()
EntitySystem.Get<SubFloorHideSystem>()
.EnableAll ^= true;
return false;

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Sound;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Random;
@@ -9,6 +10,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Timers;
using Robust.Shared.Utility;
namespace Content.Client.GameObjects.Components.Sound
{
@@ -54,7 +56,7 @@ namespace Content.Client.GameObjects.Components.Sound
Timer.Spawn((int) schedule.Delay + (_random.Next((int) schedule.RandomDelay)),() =>
{
if (!schedule.Play) return; // We make sure this hasn't changed.
if (_audioSystem == null) _audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
if (_audioSystem == null) _audioSystem = EntitySystem.Get<AudioSystem>();
_audioStreams.Add(schedule,_audioSystem.Play(schedule.Filename, Owner, schedule.AudioParams));
if (schedule.Times == 0) return;
@@ -87,7 +89,7 @@ namespace Content.Client.GameObjects.Components.Sound
public override void Initialize()
{
base.Initialize();
IoCManager.Resolve<IEntitySystemManager>().TryGetEntitySystem(out _audioSystem);
EntitySystem.TryGet(out _audioSystem);
}
public override void ExposeData(ObjectSerializer serializer)

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.Access;
using Content.Shared.GameObjects.Components.Access;
using Robust.Server.GameObjects.Components.Container;

View File

@@ -14,6 +14,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Content.Server.Utility;
using Robust.Shared.Map;
namespace Content.Server.GameObjects.Components.Cargo

View File

@@ -2,6 +2,7 @@
using Content.Server.GameObjects.Components.Metabolism;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Shared.GameObjects;
@@ -110,6 +111,8 @@ namespace Content.Server.GameObjects.Components.Chemistry
/// <param name="eventArgs"></param>
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
//Make sure we have the attacking entity
if (eventArgs.Attacked == null || !_internalContents.Injector)
{

View File

@@ -4,12 +4,15 @@ using System.Text;
using Content.Server.GameObjects.Components.Nutrition;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Chemistry
{
@@ -25,6 +28,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
#pragma warning disable 649
[Dependency] private readonly IServerNotifyManager _notifyManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
public override string Name => "Pourable";

View File

@@ -5,6 +5,7 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.GameObjects.Components.Power;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Server.GameObjects.Components.Container;

View File

@@ -1,6 +1,7 @@
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Command;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;

View File

@@ -4,12 +4,14 @@ using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Utility;
using Content.Shared.Construction;
using Content.Shared.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Random;
@@ -18,6 +20,8 @@ using Robust.Shared.Localization;
using Robust.Shared.ViewVariables;
using static Content.Shared.Construction.ConstructionStepMaterial;
using static Content.Shared.Construction.ConstructionStepTool;
using Robust.Shared.Utility;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Construction
{
@@ -46,17 +50,15 @@ namespace Content.Server.GameObjects.Components.Construction
Sprite = Owner.GetComponent<SpriteComponent>();
Transform = Owner.GetComponent<ITransformComponent>();
var systemman = IoCManager.Resolve<IEntitySystemManager>();
}
public bool AttackBy(AttackByEventArgs eventArgs)
{
var playerEntity = eventArgs.User;
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
if (!interactionSystem.InRangeUnobstructed(playerEntity.Transform.MapPosition, Owner.Transform.WorldPosition, ignoredEnt: Owner, insideBlockerValid: Prototype.CanBuildInImpassable))
// default interaction check for AttackBy allows inside blockers, so we will check if its blocked if
// we're not allowed to build on impassable stuff
if (Prototype.CanBuildInImpassable == false)
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, playerEntity,
_localizationManager.GetString("You can't reach there!"));
if (!InteractionChecks.InRangeUnobstructed(eventArgs, false))
return false;
}
@@ -124,7 +126,7 @@ namespace Content.Server.GameObjects.Components.Construction
{
return false;
}
var sound = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
var sound = EntitySystem.Get<AudioSystem>();
switch (step)
{

View File

@@ -1,12 +1,14 @@
using System;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Construction;
using Content.Shared.GameObjects.Components.Construction;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Network;
@@ -16,6 +18,7 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Construction
{
@@ -47,16 +50,13 @@ namespace Content.Server.GameObjects.Components.Construction
{
var prototype = _prototypeManager.Index<ConstructionPrototype>(prototypeName);
var transform = Owner.Transform;
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
if (!interactionSystem.InRangeUnobstructed(loc.ToMap(_mapManager), Owner.Transform.WorldPosition, ignoredEnt: Owner, insideBlockerValid: prototype.CanBuildInImpassable))
if (!InteractionChecks.InRangeUnobstructed(Owner, loc.ToMapPos(_mapManager),
ignoredEnt: Owner, insideBlockerValid: prototype.CanBuildInImpassable))
{
_notifyManager.PopupMessage(transform.GridPosition, Owner,
_localizationManager.GetString("You can't reach there!"));
return;
}
if (prototype.Stages.Count < 2)
{
throw new InvalidOperationException($"Prototype '{prototypeName}' does not have enough stages.");

View File

@@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.VendingMachines;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Doors;
using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Access;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Doors;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;

View File

@@ -2,6 +2,7 @@ using System;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.Interfaces;
using Robust.Shared.GameObjects;

View File

@@ -2,6 +2,7 @@ using System;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.Interfaces;
using Robust.Shared.GameObjects;
@@ -59,6 +60,8 @@ namespace Content.Server.GameObjects.Components.Fluids
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
Solution solution;
if (eventArgs.Attacked == null)
{

View File

@@ -9,6 +9,7 @@ using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
@@ -17,6 +18,7 @@ using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using Timer = Robust.Shared.Timers.Timer;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Fluids
{
@@ -137,8 +139,7 @@ namespace Content.Server.GameObjects.Components.Fluids
return true;
}
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
entitySystemManager.GetEntitySystem<AudioSystem>().Play(_spillSound);
EntitySystem.Get<AudioSystem>().Play(_spillSound);
return true;
}

View File

@@ -3,6 +3,7 @@ using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Gravity;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Robust.Server.GameObjects;
@@ -11,10 +12,12 @@ using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.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;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Gravity
{
@@ -101,6 +104,7 @@ namespace Content.Server.GameObjects.Components.Gravity
public bool AttackBy(AttackByEventArgs eventArgs)
{
if (!eventArgs.AttackWith.TryGetComponent<WelderComponent>(out var welder)) return false;
if (welder.TryUse(5.0f))
{
// Repair generator
@@ -110,10 +114,9 @@ namespace Content.Server.GameObjects.Components.Gravity
breakable.broken = false;
_intact = true;
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
var notifyManager = IoCManager.Resolve<IServerNotifyManager>();
entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/welder2.ogg", Owner);
EntitySystem.Get<AudioSystem>().Play("/Audio/items/welder2.ogg", Owner);
notifyManager.PopupMessage(Owner, eventArgs.User, Loc.GetString("You repair the gravity generator with the welder"));
return true;

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
@@ -24,6 +25,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
if (eventArgs.Attacked == null)
{
return;

View File

@@ -3,6 +3,7 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Mobs;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Instruments;
using NFluidsynth;
using Robust.Server.GameObjects;

View File

@@ -2,6 +2,7 @@
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components;
using Content.Shared.Interfaces;

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Maps;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
@@ -25,17 +26,11 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
public void AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID);
var tile = mapGrid.GetTileRef(eventArgs.ClickLocation);
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
float distance = coordinates.Distance(_mapManager, Owner.Transform.GridPosition);
if (distance > InteractionSystem.InteractionRange)
{
return;
}
var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
if (tileDef.CanCrowbar)
{

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Maps;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
@@ -40,18 +41,11 @@ namespace Content.Server.GameObjects.Components.Items
}
public void AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
var attacked = eventArgs.Attacked;
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID);
var tile = mapGrid.GetTileRef(eventArgs.ClickLocation);
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
float distance = coordinates.Distance(_mapManager, Owner.Transform.GridPosition);
if (distance > InteractionSystem.InteractionRange)
{
return;
}
var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
if (tileDef.IsSubFloor && attacked == null && Stack.Use(1))
{

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Storage;
using Robust.Server.GameObjects;

View File

@@ -4,6 +4,7 @@ using Content.Server.GameObjects.Components.Destructible;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Throw;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Items;
using Content.Shared.Physics;
@@ -12,6 +13,7 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Map;
@@ -23,6 +25,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects
{
@@ -35,7 +38,6 @@ namespace Content.Server.GameObjects
#pragma warning disable 649
[Dependency] private readonly IRobustRandom _robustRandom;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649
@@ -97,8 +99,7 @@ namespace Content.Server.GameObjects
var userPos = user.Transform.MapPosition;
var itemPos = Owner.Transform.WorldPosition;
return _entitySystemManager.GetEntitySystem<InteractionSystem>()
.InRangeUnobstructed(userPos, itemPos, ignoredEnt: Owner, insideBlockerValid:true);
return InteractionChecks.InRangeUnobstructed(user, itemPos, ignoredEnt: Owner, insideBlockerValid:true);
}
public bool AttackHand(AttackHandEventArgs eventArgs)

View File

@@ -5,6 +5,7 @@ using Content.Server.GameObjects.Components;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Storage;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects;
@@ -149,6 +150,8 @@ namespace Content.Server.GameObjects
return false;
}
return PlayerInsertEntity(eventArgs.User);
}

View File

@@ -21,6 +21,7 @@ using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.Localization;
using Content.Server.Interfaces;
using Content.Server.Utility;
using Robust.Shared.Audio;
namespace Content.Server.GameObjects.Components.Kitchen
@@ -177,6 +178,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
{
return;
}
UpdateUserInterface();
_userInterface.Open(actor.playerSession);

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components;
using Content.Shared.Interfaces;
using Content.Shared.Preferences.Appearance;

View File

@@ -4,6 +4,7 @@ using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Medical;
using Content.Server.GameObjects.Components.Power;
using Content.Server.Utility;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container;
using Robust.Server.GameObjects.Components.UserInterface;
@@ -120,8 +121,10 @@ namespace Content.Server.GameObjects.Components.Medical
{
return;
}
if (!Powered)
return;
_userInterface.Open(actor.playerSession);
}

View File

@@ -1,6 +1,7 @@
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.Components.Weapon.Melee;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;

View File

@@ -6,11 +6,13 @@ using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Timers;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Movement
{
@@ -195,7 +197,7 @@ namespace Content.Server.GameObjects.Components.Movement
if (!immuneEntities.Contains(entity))
{
var position = _connectingTeleporter.Transform.GridPosition;
var soundPlayer = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
var soundPlayer = EntitySystem.Get<AudioSystem>();
// Departure
// Do we need to rate-limit sounds to stop ear BLAST?

View File

@@ -7,6 +7,7 @@ using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random;
@@ -16,6 +17,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.Timers;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Movement
{
@@ -141,7 +143,7 @@ namespace Content.Server.GameObjects.Components.Movement
Timer.Spawn(TimeSpan.FromSeconds(_chargeTime + _cooldown), () => SetState(ItemTeleporterState.Off));
if (_cooldownSound != null)
{
var soundPlayer = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
var soundPlayer = EntitySystem.Get<AudioSystem>();
soundPlayer.Play(_cooldownSound, Owner);
}
}
@@ -227,7 +229,7 @@ namespace Content.Server.GameObjects.Components.Movement
{
// Messy maybe?
GridCoordinates targetGrid = new GridCoordinates(vector, user.Transform.GridID);
var soundPlayer = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
var soundPlayer = EntitySystem.Get<AudioSystem>();
// If portals use those, otherwise just move em over
if (_portalAliveTime > 0.0f)

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Nutrition;
using Content.Shared.Interfaces;
@@ -11,11 +12,13 @@ using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Nutrition
{
@@ -99,23 +102,25 @@ namespace Content.Server.GameObjects.Components.Nutrition
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
UseDrink(eventArgs.Attacked);
}
private void UseDrink(IEntity user)
private void UseDrink(IEntity targetEntity)
{
if (user == null)
if (targetEntity == null)
{
return;
}
if (UsesLeft() == 0 && !_despawnOnFinish)
{
user.PopupMessage(user, _localizationManager.GetString("Empty"));
targetEntity.PopupMessage(targetEntity, _localizationManager.GetString("Empty"));
return;
}
if (user.TryGetComponent(out StomachComponent stomachComponent))
if (targetEntity.TryGetComponent(out StomachComponent stomachComponent))
{
_drinking = true;
var transferAmount = ReagentUnit.Min(_transferAmount, _contents.CurrentVolume);
@@ -125,17 +130,16 @@ namespace Content.Server.GameObjects.Components.Nutrition
// When we split Finish gets called which may delete the can so need to use the entity system for sound
if (_useSound != null)
{
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
var audioSystem = entitySystemManager.GetEntitySystem<AudioSystem>();
var audioSystem = EntitySystem.Get<AudioSystem>();
audioSystem.Play(_useSound, Owner, AudioParams.Default.WithVolume(-2f));
user.PopupMessage(user, _localizationManager.GetString("Slurp"));
targetEntity.PopupMessage(targetEntity, _localizationManager.GetString("Slurp"));
}
}
else
{
// Add it back in
_contents.TryAddSolution(split);
user.PopupMessage(user, _localizationManager.GetString("Can't drink"));
targetEntity.PopupMessage(targetEntity, _localizationManager.GetString("Can't drink"));
}
_drinking = false;
}

View File

@@ -2,6 +2,7 @@
using Content.Server.GameObjects.Components.Chemistry;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Nutrition;
using Content.Shared.Interfaces;
@@ -111,6 +112,8 @@ namespace Content.Server.GameObjects.Components.Nutrition
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
UseFood(eventArgs.Attacked);
}

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.UserInterface;

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Power;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.UserInterface;

View File

@@ -1,5 +1,6 @@
using System;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.Interfaces;

View File

@@ -1,6 +1,7 @@
using System;
using Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.Interfaces;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Audio;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
@@ -12,6 +13,7 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Power
{
@@ -126,7 +128,7 @@ namespace Content.Server.GameObjects.Components.Power
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("glassbreak");
var file = _random.Pick(soundCollection.PickFiles);
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>().Play(file, Owner);
EntitySystem.Get<AudioSystem>().Play(file, Owner);
State = LightBulbState.Broken;
}

View File

@@ -2,6 +2,7 @@
using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform;

View File

@@ -1,6 +1,7 @@
using System;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container;

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Power
{
@@ -15,8 +17,7 @@ namespace Content.Server.GameObjects.Components.Power
{
public Powernet()
{
var EntitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
var powerSystem = EntitySystemManager.GetEntitySystem<PowerSystem>();
var powerSystem = EntitySystem.Get<PowerSystem>();
powerSystem.Powernets.Add(this);
Uid = powerSystem.NewUid();
}
@@ -374,8 +375,7 @@ namespace Content.Server.GameObjects.Components.Power
/// </summary>
private void RemoveFromSystem()
{
var EntitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
EntitySystemManager.GetEntitySystem<PowerSystem>().Powernets.Remove(this);
EntitySystem.Get<PowerSystem>().Powernets.Remove(this);
}
#region Registration

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Robust.Server.GameObjects;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
@@ -25,6 +26,8 @@ namespace Content.Server.GameObjects.Components.Power
/// <inheritdoc />
public void AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GridID, out var grid))
return;

View File

@@ -8,6 +8,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Materials;
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.GameObjects.Components.Research;
@@ -150,6 +151,7 @@ namespace Content.Server.GameObjects.Components.Research
{
return;
}
OpenUserInterface(actor.playerSession);
}
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Research;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;
@@ -60,7 +61,6 @@ namespace Content.Server.GameObjects.Components.Research
return;
OpenUserInterface(actor.playerSession);
return;
}
public void UpdateUserInterface()

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
@@ -110,6 +111,7 @@ namespace Content.Server.GameObjects.Components.Research
{
return;
}
OpenUserInterface(actor.playerSession);
PlayKeyboardSound();
return;

View File

@@ -3,10 +3,12 @@ using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Research
{
@@ -73,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Research
{
base.Initialize();
Id = ServerCount++;
IoCManager.Resolve<IEntitySystemManager>()?.GetEntitySystem<ResearchSystem>()?.RegisterServer(this);
EntitySystem.Get<ResearchSystem>()?.RegisterServer(this);
Database = Owner.GetComponent<TechnologyDatabaseComponent>();
Owner.TryGetComponent(out _powerDevice);
}
@@ -82,7 +84,7 @@ namespace Content.Server.GameObjects.Components.Research
protected override void Shutdown()
{
base.Shutdown();
IoCManager.Resolve<IEntitySystemManager>()?.GetEntitySystem<ResearchSystem>()?.UnregisterServer(this);
EntitySystem.Get<ResearchSystem>()?.UnregisterServer(this);
}
public override void ExposeData(ObjectSerializer serializer)

View File

@@ -1,5 +1,6 @@
using System;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components;
using Content.Shared.Interfaces;
using Robust.Shared.GameObjects;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.VendingMachines;
using Content.Shared.VendingMachines;
using Robust.Server.GameObjects;

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.Interfaces;
using Content.Shared.Physics;
@@ -10,6 +11,7 @@ using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.EntitySystemMessages;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Timing;
@@ -18,6 +20,7 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
{
@@ -129,8 +132,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
Shaded = false
};
var mgr = IoCManager.Resolve<IEntitySystemManager>();
mgr.GetEntitySystem<EffectSystem>().CreateParticle(message);
EntitySystem.Get<EffectSystem>().CreateParticle(message);
Owner.GetComponent<SoundComponent>().Play(_fireSound, AudioParams.Default.WithVolume(-5));
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects;

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Content.Shared.Interfaces;
using Robust.Server.GameObjects;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Content.Shared.Interfaces;

View File

@@ -6,6 +6,7 @@ using Content.Server.GameObjects.Components.VendingMachines;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -13,6 +14,7 @@ using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
@@ -20,6 +22,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components
{
@@ -108,7 +111,7 @@ namespace Content.Server.GameObjects.Components
public override void Initialize()
{
base.Initialize();
_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
_audioSystem = EntitySystem.Get<AudioSystem>();
_appearance = Owner.GetComponent<AppearanceComponent>();
_appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen);
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
@@ -235,8 +238,7 @@ namespace Content.Server.GameObjects.Components
return;
}
var interactionSystem = IoCManager.Resolve<EntitySystemManager>().GetEntitySystem<InteractionSystem>();
if (!interactionSystem.InRangeUnobstructed(player.Transform.MapPosition, Owner.Transform.WorldPosition, ignoredEnt: Owner))
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(player.Transform.MapPosition, Owner.Transform.WorldPosition, ignoredEnt: Owner))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player, _localizationManager.GetString("You can't reach there!"));
return;
@@ -302,8 +304,7 @@ namespace Content.Server.GameObjects.Components
}
IsPanelOpen = !IsPanelOpen;
IoCManager.Resolve<IEntitySystemManager>()
.GetEntitySystem<AudioSystem>()
EntitySystem.Get<AudioSystem>()
.Play(IsPanelOpen ? "/Audio/machines/screwdriveropen.ogg" : "/Audio/machines/screwdriverclose.ogg");
return true;
}

View File

@@ -1,10 +1,13 @@
using Content.Server.GameObjects.Components.Interactable.Tools;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.Components
{
@@ -17,7 +20,7 @@ namespace Content.Server.GameObjects.Components
public override void Initialize()
{
base.Initialize();
_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
_audioSystem = EntitySystem.Get<AudioSystem>();
}
public bool AttackBy(AttackByEventArgs eventArgs)

View File

@@ -11,6 +11,7 @@ using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.EntitySystems
{
@@ -101,7 +102,7 @@ namespace Content.Server.GameObjects.EntitySystems
var processorId = args[0];
var entId = new EntityUid(int.Parse(args[1]));
var ent = IoCManager.Resolve<IEntityManager>().GetEntity(entId);
var aiSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AiSystem>();
var aiSystem = EntitySystem.Get<AiSystem>();
if (!aiSystem.ProcessorTypeExists(processorId))
{

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Timing;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Input;
using Content.Shared.Physics;
@@ -18,6 +19,7 @@ using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -27,36 +29,53 @@ namespace Content.Server.GameObjects.EntitySystems
{
/// <summary>
/// This interface gives components behavior when being clicked on or "attacked" by a user with an object in their hand
/// who is in range and has unobstructed reach of the target entity (allows inside blockers).
/// </summary>
public interface IAttackBy
{
/// <summary>
/// Called when using one object on another
/// Called when using one object on another when user is in range of the target entity.
/// </summary>
bool AttackBy(AttackByEventArgs eventArgs);
}
public class AttackByEventArgs : EventArgs
public class AttackByEventArgs : EventArgs, ITargetedAttackEventArgs
{
public IEntity User { get; set; }
public GridCoordinates ClickLocation { get; set; }
public IEntity AttackWith { get; set; }
public IEntity Attacked { get; set; }
}
public interface ITargetedAttackEventArgs
{
/// <summary>
/// Performer of the attack
/// </summary>
IEntity User { get; }
/// <summary>
/// Target of the attack
/// </summary>
IEntity Attacked { get; }
}
/// <summary>
/// This interface gives components behavior when being clicked on or "attacked" by a user with an empty hand
/// who is in range and has unobstructed reach of the target entity (allows inside blockers).
/// </summary>
public interface IAttackHand
{
/// <summary>
/// Called when a player directly interacts with an empty hand
/// Called when a player directly interacts with an empty hand when user is in range of the target entity.
/// </summary>
bool AttackHand(AttackHandEventArgs eventArgs);
}
public class AttackHandEventArgs : EventArgs
public class AttackHandEventArgs : EventArgs, ITargetedAttackEventArgs
{
public IEntity User { get; set; }
public IEntity Attacked { get; set; }
}
/// <summary>
@@ -80,8 +99,8 @@ namespace Content.Server.GameObjects.EntitySystems
}
/// <summary>
/// This interface gives components a behavior when clicking on another object and no interaction occurs
/// Doesn't pass what you clicked on as an argument, but if it becomes necessary we can add it later
/// This interface gives components a behavior when clicking on another object and no interaction occurs,
/// at any range.
/// </summary>
public interface IAfterAttack
{
@@ -116,19 +135,21 @@ namespace Content.Server.GameObjects.EntitySystems
}
/// <summary>
/// This interface gives components behavior when being activated in the world.
/// This interface gives components behavior when being activated in the world when the user
/// is in range and has unobstructed access to the target entity (allows inside blockers).
/// </summary>
public interface IActivate
{
/// <summary>
/// Called when this component is activated by another entity.
/// Called when this component is activated by another entity who is in range.
/// </summary>
void Activate(ActivateEventArgs eventArgs);
}
public class ActivateEventArgs : EventArgs
public class ActivateEventArgs : EventArgs, ITargetedAttackEventArgs
{
public IEntity User { get; set; }
public IEntity Attacked { get; set; }
}
/// <summary>
@@ -292,6 +313,7 @@ namespace Content.Server.GameObjects.EntitySystems
#pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IPhysicsManager _physicsManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public const float InteractionRange = 2;
@@ -359,7 +381,12 @@ namespace Content.Server.GameObjects.EntitySystems
return;
}
activateComp.Activate(new ActivateEventArgs {User = user});
// all activates should only fire when in range / unbostructed
var activateEventArgs = new ActivateEventArgs {User = user, Attacked = used};
if (InteractionChecks.InRangeUnobstructed(activateEventArgs))
{
activateComp.Activate(activateEventArgs);
}
}
private bool HandleWideAttack(ICommonSession session, GridCoordinates coords, EntityUid uid)
@@ -556,9 +583,12 @@ namespace Content.Server.GameObjects.EntitySystems
var attackBys = attacked.GetAllComponents<IAttackBy>().ToList();
var attackByEventArgs = new AttackByEventArgs
{
User = user, ClickLocation = clickLocation, AttackWith = weapon
User = user, ClickLocation = clickLocation, AttackWith = weapon, Attacked = attacked
};
// all AttackBys should only happen when in range / unobstructed, so no range check is needed
if (InteractionChecks.InRangeUnobstructed(attackByEventArgs))
{
foreach (var attackBy in attackBys)
{
if (attackBy.AttackBy(attackByEventArgs))
@@ -567,6 +597,7 @@ namespace Content.Server.GameObjects.EntitySystems
return;
}
}
}
var afterAtkMsg = new AfterAttackMessage(user, weapon, attacked, clickLocation);
RaiseLocalEvent(afterAtkMsg);
@@ -602,8 +633,11 @@ namespace Content.Server.GameObjects.EntitySystems
}
var attackHands = attacked.GetAllComponents<IAttackHand>().ToList();
var attackHandEventArgs = new AttackHandEventArgs {User = user};
var attackHandEventArgs = new AttackHandEventArgs {User = user, Attacked = attacked};
// all attackHands should only fire when in range / unbostructed
if (InteractionChecks.InRangeUnobstructed(attackHandEventArgs))
{
foreach (var attackHand in attackHands)
{
if (attackHand.AttackHand(attackHandEventArgs))
@@ -612,6 +646,7 @@ namespace Content.Server.GameObjects.EntitySystems
return;
}
}
}
// Else we run Activate.
InteractionActivate(user, attacked);

View File

@@ -30,6 +30,7 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.EntitySystems
{
@@ -105,7 +106,7 @@ namespace Content.Server.GameObjects.EntitySystems
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
return;
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
var interactionSystem = EntitySystem.Get<InteractionSystem>();
var oldItem = handsComp.GetActiveHand;
@@ -133,9 +134,8 @@ namespace Content.Server.GameObjects.EntitySystems
if (handsComp.GetActiveHand == null)
return false;
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
if(interactionSystem.InRangeUnobstructed(coords.ToMap(_mapManager), ent.Transform.WorldPosition, ignoredEnt: ent))
if(EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(coords.ToMap(_mapManager), ent.Transform.WorldPosition, ignoredEnt: ent))
if (coords.InRange(_mapManager, ent.Transform.GridPosition, InteractionSystem.InteractionRange))
{
handsComp.Drop(handsComp.ActiveIndex, coords);

View File

@@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Content.Server.Utility;
using Content.Shared.BodySystem;
@@ -41,6 +42,7 @@ namespace Content.Server.BodySystem
{
return;
}
if (actor.playerSession.AttachedEntity.TryGetComponent(out BodyManagerComponent attempt))
{
_userInterface.SetState(PrepareBodyScannerInterfaceState(attempt.Template, attempt.PartDictionary));

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Content.Server.BodySystem;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Utility;
using Content.Shared.BodySystem;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Items;
@@ -42,6 +43,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
{
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
if (eventArgs.Attacked == null)
return;
if (eventArgs.Attacked.TryGetComponent<BodySystem.BodyManagerComponent>(out BodySystem.BodyManagerComponent bodyManager))

View File

@@ -0,0 +1,100 @@
using System;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Interfaces;
using Content.Shared.Physics;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Content.Server.Utility
{
/// <summary>
/// Convenient methods for checking for various conditions commonly needed
/// for interactions.
/// </summary>
public static class InteractionChecks
{
/// <summary>
/// Default interaction check for targeted attack interaction types.
/// Same as <see cref="SharedInteractionSystem.InRangeUnobstructed"/>, but defaults to allow inside blockers.
/// Validates that attacker is in range of the attacked entity. Additionally shows a popup if
/// validation fails.
/// </summary>
public static bool InRangeUnobstructed(ITargetedAttackEventArgs eventArgs, bool insideBlockerValid = true)
{
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(eventArgs.User.Transform.MapPosition,
eventArgs.Attacked.Transform.WorldPosition, ignoredEnt: eventArgs.Attacked, insideBlockerValid: insideBlockerValid))
{
var localizationManager = IoCManager.Resolve<ILocalizationManager>();
eventArgs.Attacked.PopupMessage(eventArgs.User, localizationManager.GetString("You can't reach there!"));
return false;
}
return true;
}
/// <summary>
/// Default interaction check for after attack interaction types.
/// Same as <see cref="SharedInteractionSystem.InRangeUnobstructed"/>, but defaults to allow inside blockers.
/// Validates that attacker is in range of the attacked entity, if there is such an entity.
/// If there is no attacked entity, validates that they are in range of the clicked position.
/// Additionally shows a popup if validation fails.
/// </summary>
public static bool InRangeUnobstructed(AfterAttackEventArgs eventArgs, bool insideBlockerValid = true)
{
if (eventArgs.Attacked != null)
{
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(eventArgs.User.Transform.MapPosition,
eventArgs.Attacked.Transform.WorldPosition, ignoredEnt: eventArgs.Attacked, insideBlockerValid: insideBlockerValid))
{
var localizationManager = IoCManager.Resolve<ILocalizationManager>();
eventArgs.Attacked.PopupMessage(eventArgs.User, localizationManager.GetString("You can't reach there!"));
return false;
}
}
else
{
var mapManager = IoCManager.Resolve<IMapManager>();
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(eventArgs.User.Transform.MapPosition,
eventArgs.ClickLocation.ToMapPos(mapManager), ignoredEnt: eventArgs.User, insideBlockerValid: insideBlockerValid))
{
var localizationManager = IoCManager.Resolve<ILocalizationManager>();
eventArgs.User.PopupMessage(eventArgs.User, localizationManager.GetString("You can't reach there!"));
return false;
}
}
return true;
}
/// <summary>
/// Convenient static alternative to <see cref="SharedInteractionSystem.InRangeUnobstructed"/>, which also
/// shows a popup message if not in range.
/// </summary>
public static bool InRangeUnobstructed(IEntity user, Vector2 targetWorldCoords,
float range = SharedInteractionSystem.InteractionRange,
int collisionMask = (int) CollisionGroup.Impassable, IEntity ignoredEnt = null,
bool insideBlockerValid = false)
{
var interactionSystem = EntitySystem.Get<SharedInteractionSystem>();
if (!interactionSystem.InRangeUnobstructed(user.Transform.MapPosition, targetWorldCoords, range, collisionMask,
ignoredEnt, insideBlockerValid))
{
var localizationManager = IoCManager.Resolve<ILocalizationManager>();
user.PopupMessage(user, localizationManager.GetString("You can't reach there!"));
return false;
}
return true;
}
}
}

View File

@@ -3,7 +3,7 @@ using Content.Shared.GameObjects.Components.Mobs;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Utility;
namespace Content.Shared.GameObjects.EntitySystems
{
@@ -30,8 +30,7 @@ namespace Content.Shared.GameObjects.EntitySystems
return false;
}
return IoCManager.Resolve<IEntitySystemManager>()
.GetEntitySystem<SharedInteractionSystem>()
return EntitySystem.Get<SharedInteractionSystem>()
.InRangeUnobstructed(examiner.Transform.MapPosition, examined.Transform.MapPosition.Position,
ExamineRange, predicate: entity => entity == examiner || entity == examined, insideBlockerValid:true);
}

View File

@@ -37,7 +37,6 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="range">maximum distance between the two sets of coordinates.</param>
/// <param name="collisionMask">the mask to check for collisions</param>
/// <param name="predicate">.</param>
/// <param name="mapManager">Map manager containing the two GridIds.</param>
/// <param name="insideBlockerValid">if coordinates inside obstructions count as obstructed or not</param>
/// <returns>True if the two points are within a given range without being obstructed.</returns>
public bool InRangeUnobstructed(MapCoordinates coords, Vector2 otherCoords, float range = InteractionRange,
@@ -78,7 +77,6 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="range">maximum distance between the two sets of coordinates.</param>
/// <param name="collisionMask">the mask to check for collisions</param>
/// <param name="ignoredEnt">the entity to be ignored when checking for collisions.</param>
/// <param name="mapManager">Map manager containing the two GridIds.</param>
/// <param name="insideBlockerValid">if coordinates inside obstructions count as obstructed or not</param>
/// <returns>True if the two points are within a given range without being obstructed.</returns>
public bool InRangeUnobstructed(MapCoordinates coords, Vector2 otherCoords, float range = InteractionRange,