Map System Code Refactor (#204)
* Removes static `IoCManager` service locator calls from `Robust.Shared.Map` namespace. * Misc code cleanup and filling out doc comments for Map classes. * Added Union and Intersect methods to Box2. * Any touched component was converted from static IoC calls to field injection. Sibling PR to https://github.com/space-wizards/RobustToolbox/pull/796.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
50f42d71a2
commit
d3daa83b82
@@ -43,13 +43,13 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
var grid = _mapManager.GetGrid(senderEnt.Transform.GridID);
|
var grid = _mapManager.GetGrid(senderEnt.Transform.GridID);
|
||||||
var position = senderEnt.Transform.GridPosition;
|
var position = senderEnt.Transform.GridPosition;
|
||||||
var tileRef = grid.GetTile(position);
|
var tileRef = grid.GetTile(position);
|
||||||
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tileRef.Tile.TileId];
|
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tileRef.Tile.TypeId];
|
||||||
sprite.Visible = tileDef.IsSubFloor;
|
sprite.Visible = tileDef.IsSubFloor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapManagerOnTileChanged(object sender, TileChangedEventArgs e)
|
private void MapManagerOnTileChanged(object sender, TileChangedEventArgs e)
|
||||||
{
|
{
|
||||||
UpdateTile(_mapManager.GetGrid(e.NewTile.GridIndex), e.NewTile.GridTile);
|
UpdateTile(_mapManager.GetGrid(e.NewTile.GridIndex), e.NewTile.GridIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapManagerOnGridChanged(object sender, GridChangedEventArgs e)
|
private void MapManagerOnGridChanged(object sender, GridChangedEventArgs e)
|
||||||
@@ -63,7 +63,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
private void UpdateTile(IMapGrid grid, MapIndices position)
|
private void UpdateTile(IMapGrid grid, MapIndices position)
|
||||||
{
|
{
|
||||||
var tile = grid.GetTile(position);
|
var tile = grid.GetTile(position);
|
||||||
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TileId];
|
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
|
||||||
foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center))
|
foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center))
|
||||||
{
|
{
|
||||||
var entity = snapGridComponent.Owner;
|
var entity = snapGridComponent.Owner;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Robust.Client.Graphics.Overlays;
|
|||||||
using Robust.Client.Graphics.Shaders;
|
using Robust.Client.Graphics.Shaders;
|
||||||
using Robust.Client.Interfaces.Graphics.ClientEye;
|
using Robust.Client.Interfaces.Graphics.ClientEye;
|
||||||
using Robust.Client.Interfaces.Graphics.Overlays;
|
using Robust.Client.Interfaces.Graphics.Overlays;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -17,6 +18,7 @@ namespace Content.Client.Parallax
|
|||||||
[Dependency] private readonly IParallaxManager _parallaxManager;
|
[Dependency] private readonly IParallaxManager _parallaxManager;
|
||||||
[Dependency] private readonly IEyeManager _eyeManager;
|
[Dependency] private readonly IEyeManager _eyeManager;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
public override bool AlwaysDirty => true;
|
public override bool AlwaysDirty => true;
|
||||||
@@ -49,7 +51,7 @@ namespace Content.Client.Parallax
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (sizeX, sizeY) = _parallaxTexture.Size;
|
var (sizeX, sizeY) = _parallaxTexture.Size;
|
||||||
var (posX, posY) = _eyeManager.ScreenToWorld(Vector2.Zero).ToWorld().Position;
|
var (posX, posY) = _eyeManager.ScreenToWorld(Vector2.Zero).ToWorld(_mapManager).Position;
|
||||||
var (ox, oy) = (Vector2i) new Vector2(-posX / Slowness, posY / Slowness);
|
var (ox, oy) = (Vector2i) new Vector2(-posX / Slowness, posY / Slowness);
|
||||||
ox = MathHelper.Mod(ox, sizeX);
|
ox = MathHelper.Mod(ox, sizeX);
|
||||||
oy = MathHelper.Mod(oy, sizeY);
|
oy = MathHelper.Mod(oy, sizeY);
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Content.Server.GameObjects.Components.Materials;
|
|
||||||
using Content.Server.GameObjects.Components.Sound;
|
|
||||||
using Content.Server.GameObjects.Components.Stack;
|
using Content.Server.GameObjects.Components.Stack;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Construction;
|
using Content.Shared.Construction;
|
||||||
@@ -10,6 +7,7 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
@@ -22,6 +20,13 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
{
|
{
|
||||||
public class ConstructorComponent : SharedConstructorComponent
|
public class ConstructorComponent : SharedConstructorComponent
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
|
[Dependency] private readonly IServerEntityManager _serverEntityManager;
|
||||||
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
|
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
|
||||||
{
|
{
|
||||||
base.HandleMessage(message, netChannel, component);
|
base.HandleMessage(message, netChannel, component);
|
||||||
@@ -36,11 +41,10 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
|
|
||||||
void TryStartStructureConstruction(GridCoordinates loc, string prototypeName, Angle angle, int ack)
|
void TryStartStructureConstruction(GridCoordinates loc, string prototypeName, Angle angle, int ack)
|
||||||
{
|
{
|
||||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
var prototype = _prototypeManager.Index<ConstructionPrototype>(prototypeName);
|
||||||
var prototype = protoMan.Index<ConstructionPrototype>(prototypeName);
|
|
||||||
|
|
||||||
var transform = Owner.GetComponent<ITransformComponent>();
|
var transform = Owner.Transform;
|
||||||
if (!loc.InRange(transform.GridPosition, InteractionSystem.INTERACTION_RANGE))
|
if (!loc.InRange(_mapManager, transform.GridPosition, InteractionSystem.INTERACTION_RANGE))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -75,20 +79,19 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OK WE'RE GOOD CONSTRUCTION STARTED.
|
// OK WE'RE GOOD CONSTRUCTION STARTED.
|
||||||
var entMgr = IoCManager.Resolve<IServerEntityManager>();
|
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/deconstruct.ogg", loc);
|
||||||
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>().Play("/Audio/items/deconstruct.ogg", loc);
|
|
||||||
if (prototype.Stages.Count == 2)
|
if (prototype.Stages.Count == 2)
|
||||||
{
|
{
|
||||||
// Exactly 2 stages, so don't make an intermediate frame.
|
// Exactly 2 stages, so don't make an intermediate frame.
|
||||||
var ent = entMgr.ForceSpawnEntityAt(prototype.Result, loc);
|
var ent = _serverEntityManager.ForceSpawnEntityAt(prototype.Result, loc);
|
||||||
ent.GetComponent<ITransformComponent>().LocalRotation = angle;
|
ent.Transform.LocalRotation = angle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var frame = entMgr.ForceSpawnEntityAt("structureconstructionframe", loc);
|
var frame = _serverEntityManager.ForceSpawnEntityAt("structureconstructionframe", loc);
|
||||||
var construction = frame.GetComponent<ConstructionComponent>();
|
var construction = frame.GetComponent<ConstructionComponent>();
|
||||||
construction.Init(prototype);
|
construction.Init(prototype);
|
||||||
frame.GetComponent<ITransformComponent>().LocalRotation = angle;
|
frame.Transform.LocalRotation = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = new AckStructureConstructionMessage(ack);
|
var msg = new AckStructureConstructionMessage(ack);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
|||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -20,19 +21,15 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override string Name => "Crowbar";
|
public override string Name => "Crowbar";
|
||||||
|
|
||||||
public CrowbarComponent()
|
|
||||||
{
|
|
||||||
IoCManager.InjectDependencies(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
var tile = eventArgs.ClickLocation.Grid.GetTile(eventArgs.ClickLocation);
|
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID);
|
||||||
var tileDef = (ContentTileDefinition) tile.TileDef;
|
var tile = mapGrid.GetTile(eventArgs.ClickLocation);
|
||||||
|
var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
|
||||||
if (tileDef.CanCrowbar)
|
if (tileDef.CanCrowbar)
|
||||||
{
|
{
|
||||||
var underplating = _tileDefinitionManager["underplating"];
|
var underplating = _tileDefinitionManager["underplating"];
|
||||||
eventArgs.ClickLocation.Grid.SetTile(eventArgs.ClickLocation, underplating.TileId);
|
mapGrid.SetTile(eventArgs.ClickLocation, underplating.TileId);
|
||||||
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/crowbar.ogg", Owner);
|
_entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/crowbar.ogg", Owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
|
||||||
using Content.Shared.GameObjects.Components.Storage;
|
using Content.Shared.GameObjects.Components.Storage;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.Container;
|
using Robust.Server.GameObjects.Components.Container;
|
||||||
@@ -16,6 +15,7 @@ using Robust.Shared.Serialization;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Robust.Shared.GameObjects.EntitySystemMessages;
|
using Robust.Shared.GameObjects.EntitySystemMessages;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Content.Server.GameObjects.Components;
|
using Content.Server.GameObjects.Components;
|
||||||
|
|
||||||
@@ -26,6 +26,12 @@ namespace Content.Server.GameObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ServerStorageComponent : SharedStorageComponent, IAttackBy, IUse, IActivate
|
public class ServerStorageComponent : SharedStorageComponent, IAttackBy, IUse, IActivate
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
private Container storage;
|
private Container storage;
|
||||||
|
|
||||||
private bool _storageInitialCalculated = false;
|
private bool _storageInitialCalculated = false;
|
||||||
@@ -269,18 +275,17 @@ namespace Content.Server.GameObjects
|
|||||||
case RemoveEntityMessage _:
|
case RemoveEntityMessage _:
|
||||||
{
|
{
|
||||||
_ensureInitialCalculated();
|
_ensureInitialCalculated();
|
||||||
var playerMan = IoCManager.Resolve<IPlayerManager>();
|
var session = _playerManager.GetSessionByChannel(netChannel);
|
||||||
var session = playerMan.GetSessionByChannel(netChannel);
|
|
||||||
var playerentity = session.AttachedEntity;
|
var playerentity = session.AttachedEntity;
|
||||||
|
|
||||||
var ourtransform = Owner.GetComponent<ITransformComponent>();
|
var ourtransform = Owner.GetComponent<ITransformComponent>();
|
||||||
var playertransform = playerentity.GetComponent<ITransformComponent>();
|
var playertransform = playerentity.GetComponent<ITransformComponent>();
|
||||||
|
|
||||||
if (playertransform.GridPosition.InRange(ourtransform.GridPosition, 2)
|
if (playertransform.GridPosition.InRange(_mapManager, ourtransform.GridPosition, 2)
|
||||||
&& (ourtransform.IsMapTransform || playertransform.ContainsEntity(ourtransform)))
|
&& (ourtransform.IsMapTransform || playertransform.ContainsEntity(ourtransform)))
|
||||||
{
|
{
|
||||||
var remove = (RemoveEntityMessage)message;
|
var remove = (RemoveEntityMessage)message;
|
||||||
var entity = IoCManager.Resolve<IEntityManager>().GetEntity(remove.EntityUid);
|
var entity = _entityManager.GetEntity(remove.EntityUid);
|
||||||
if (entity != null && storage.Contains(entity))
|
if (entity != null && storage.Contains(entity))
|
||||||
{
|
{
|
||||||
Remove(entity);
|
Remove(entity);
|
||||||
@@ -300,8 +305,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
case CloseStorageUIMessage _:
|
case CloseStorageUIMessage _:
|
||||||
{
|
{
|
||||||
var playerMan = IoCManager.Resolve<IPlayerManager>();
|
var session = _playerManager.GetSessionByChannel(netChannel);
|
||||||
var session = playerMan.GetSessionByChannel(netChannel);
|
|
||||||
|
|
||||||
UnsubscribeSession(session);
|
UnsubscribeSession(session);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
using System;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.Map;
|
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
|
||||||
using Robust.Shared.GameObjects.EntitySystemMessages;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||||
{
|
{
|
||||||
public class MeleeWeaponComponent : Component, IAfterAttack
|
public class MeleeWeaponComponent : Component, IAfterAttack
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
|
[Dependency] private readonly IServerEntityManager _serverEntityManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
public override string Name => "MeleeWeapon";
|
public override string Name => "MeleeWeapon";
|
||||||
|
|
||||||
public int Damage = 1;
|
public int Damage = 1;
|
||||||
@@ -34,13 +33,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
|
|
||||||
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
|
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
var location = eventArgs.User.GetComponent<ITransformComponent>().GridPosition;
|
var location = eventArgs.User.Transform.GridPosition;
|
||||||
var angle = new Angle(eventArgs.ClickLocation.ToWorld().Position - location.ToWorld().Position);
|
var angle = new Angle(eventArgs.ClickLocation.ToWorld(_mapManager).Position - location.ToWorld(_mapManager).Position);
|
||||||
var entities = IoCManager.Resolve<IServerEntityManager>().GetEntitiesInArc(eventArgs.User.GetComponent<ITransformComponent>().GridPosition, Range, angle, ArcWidth);
|
var entities = _serverEntityManager.GetEntitiesInArc(eventArgs.User.Transform.GridPosition, Range, angle, ArcWidth);
|
||||||
|
|
||||||
foreach (var entity in entities)
|
foreach (var entity in entities)
|
||||||
{
|
{
|
||||||
if (!entity.GetComponent<ITransformComponent>().IsMapTransform || entity == eventArgs.User)
|
if (!entity.Transform.IsMapTransform || entity == eventArgs.User)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (entity.TryGetComponent(out DamageableComponent damagecomponent))
|
if (entity.TryGetComponent(out DamageableComponent damagecomponent))
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ using Robust.Shared.Map;
|
|||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
@@ -138,6 +140,10 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class InteractionSystem : EntitySystem
|
public class InteractionSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
public const float INTERACTION_RANGE = 2;
|
public const float INTERACTION_RANGE = 2;
|
||||||
public const float INTERACTION_RANGE_SQUARED = INTERACTION_RANGE * INTERACTION_RANGE;
|
public const float INTERACTION_RANGE_SQUARED = INTERACTION_RANGE * INTERACTION_RANGE;
|
||||||
|
|
||||||
@@ -158,7 +164,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
if(playerEnt == null || !playerEnt.IsValid())
|
if(playerEnt == null || !playerEnt.IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!playerEnt.Transform.GridPosition.InRange(used.Transform.GridPosition, INTERACTION_RANGE))
|
if (!playerEnt.Transform.GridPosition.InRange(_mapManager, used.Transform.GridPosition, INTERACTION_RANGE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var activateMsg = new ActivateInWorldMessage(playerEnt, used);
|
var activateMsg = new ActivateInWorldMessage(playerEnt, used);
|
||||||
@@ -175,7 +181,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
private void HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
private void HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
// client sanitization
|
// client sanitization
|
||||||
if(!coords.IsValidLocation())
|
if(!_mapManager.GridExists(coords.GridID))
|
||||||
{
|
{
|
||||||
Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
|
Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
|
||||||
return;
|
return;
|
||||||
@@ -202,7 +208,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Verify player is on the same map as the entity he clicked on
|
//Verify player is on the same map as the entity he clicked on
|
||||||
else if (coordinates.MapID != playerTransform.MapID)
|
else if (_mapManager.GetGrid(coordinates.GridID).ParentMap.Index != playerTransform.MapID)
|
||||||
{
|
{
|
||||||
Logger.Warning(string.Format("Player named {0} clicked on a map he isn't located on", player.Name));
|
Logger.Warning(string.Format("Player named {0} clicked on a map he isn't located on", player.Name));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Robust.Shared.GameObjects.EntitySystemMessages;
|
|||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
@@ -22,6 +23,10 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
internal class HandsSystem : EntitySystem
|
internal class HandsSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
|
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -105,7 +110,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
handsComp.SwapHands();
|
handsComp.SwapHands();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleDrop(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
private void HandleDrop(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
var ent = ((IPlayerSession) session).AttachedEntity;
|
var ent = ((IPlayerSession) session).AttachedEntity;
|
||||||
|
|
||||||
@@ -129,7 +134,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
handsComp.ActivateItem();
|
handsComp.ActivateItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleThrowItem(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
private void HandleThrowItem(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
var plyEnt = ((IPlayerSession)session).AttachedEntity;
|
var plyEnt = ((IPlayerSession)session).AttachedEntity;
|
||||||
|
|
||||||
@@ -173,7 +178,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
projComp.IgnoreEntity(plyEnt);
|
projComp.IgnoreEntity(plyEnt);
|
||||||
|
|
||||||
var transform = plyEnt.Transform;
|
var transform = plyEnt.Transform;
|
||||||
var dirVec = (coords.ToWorld().Position - transform.WorldPosition).Normalized;
|
var dirVec = (coords.ToWorld(_mapManager).Position - transform.WorldPosition).Normalized;
|
||||||
|
|
||||||
if (!throwEnt.TryGetComponent(out PhysicsComponent physComp))
|
if (!throwEnt.TryGetComponent(out PhysicsComponent physComp))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Robust.Shared.GameObjects.Components.Transform;
|
|||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
@@ -27,10 +28,10 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
internal class MoverSystem : EntitySystem
|
internal class MoverSystem : EntitySystem
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency]
|
[Dependency] private readonly IPauseManager _pauseManager;
|
||||||
private IPauseManager _pauseManager;
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
[Dependency]
|
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
|
||||||
private IPrototypeManager _prototypeManager;
|
[Dependency] private readonly IMapManager _mapManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private AudioSystem _audioSystem;
|
private AudioSystem _audioSystem;
|
||||||
@@ -42,8 +43,6 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
|
||||||
|
|
||||||
EntityQuery = new TypeEntityQuery(typeof(PlayerInputMoverComponent));
|
EntityQuery = new TypeEntityQuery(typeof(PlayerInputMoverComponent));
|
||||||
|
|
||||||
var moveUpCmdHandler = InputCmdHandler.FromDelegate(
|
var moveUpCmdHandler = InputCmdHandler.FromDelegate(
|
||||||
@@ -135,7 +134,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
transform.LocalRotation = mover.VelocityDir.GetDir().ToAngle();
|
transform.LocalRotation = mover.VelocityDir.GetDir().ToAngle();
|
||||||
|
|
||||||
// Handle footsteps.
|
// Handle footsteps.
|
||||||
var distance = transform.GridPosition.Distance(mover.LastPosition);
|
var distance = transform.GridPosition.Distance(_mapManager, mover.LastPosition);
|
||||||
mover.StepSoundDistance += distance;
|
mover.StepSoundDistance += distance;
|
||||||
mover.LastPosition = transform.GridPosition;
|
mover.LastPosition = transform.GridPosition;
|
||||||
float distanceNeeded;
|
float distanceNeeded;
|
||||||
@@ -191,13 +190,13 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
private void PlayFootstepSound(GridCoordinates coordinates)
|
private void PlayFootstepSound(GridCoordinates coordinates)
|
||||||
{
|
{
|
||||||
// Step one: figure out sound collection prototype.
|
// Step one: figure out sound collection prototype.
|
||||||
var grid = coordinates.Grid;
|
var grid = _mapManager.GetGrid(coordinates.GridID);
|
||||||
var tile = grid.GetTile(coordinates);
|
var tile = grid.GetTile(coordinates);
|
||||||
|
|
||||||
// If the coordinates have a catwalk, it's always catwalk.
|
// If the coordinates have a catwalk, it's always catwalk.
|
||||||
string soundCollectionName;
|
string soundCollectionName;
|
||||||
var catwalk = false;
|
var catwalk = false;
|
||||||
foreach (var maybeCatwalk in grid.GetSnapGridCell(tile.GridTile, SnapGridOffset.Center))
|
foreach (var maybeCatwalk in grid.GetSnapGridCell(tile.GridIndices, SnapGridOffset.Center))
|
||||||
{
|
{
|
||||||
if (maybeCatwalk.Owner.HasComponent<CatwalkComponent>())
|
if (maybeCatwalk.Owner.HasComponent<CatwalkComponent>())
|
||||||
{
|
{
|
||||||
@@ -214,7 +213,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Walking on a tile.
|
// Walking on a tile.
|
||||||
var def = (ContentTileDefinition)tile.TileDef;
|
var def = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];
|
||||||
if (def.FootstepSounds == null)
|
if (def.FootstepSounds == null)
|
||||||
{
|
{
|
||||||
// Nothing to play, oh well.
|
// Nothing to play, oh well.
|
||||||
|
|||||||
@@ -43,4 +43,6 @@
|
|||||||
- toggleready
|
- toggleready
|
||||||
- spawn
|
- spawn
|
||||||
- delete
|
- delete
|
||||||
|
- tp
|
||||||
|
- tpgrid
|
||||||
CanViewVar: true
|
CanViewVar: true
|
||||||
|
|||||||
Reference in New Issue
Block a user