InRangeUnobstructed check for construction start and step progre… (#773)
This commit is contained in:
@@ -31,9 +31,10 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
|
|
||||||
SpriteComponent Sprite;
|
SpriteComponent Sprite;
|
||||||
ITransformComponent Transform;
|
ITransformComponent Transform;
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private IRobustRandom _random;
|
[Dependency] private IRobustRandom _random;
|
||||||
#pragma warning restore 649
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -46,6 +47,13 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
|
|
||||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
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: true))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var stage = Prototype.Stages[Stage];
|
var stage = Prototype.Stages[Stage];
|
||||||
|
|
||||||
if (TryProcessStep(stage.Forward, eventArgs.AttackWith))
|
if (TryProcessStep(stage.Forward, eventArgs.AttackWith))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
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;
|
||||||
@@ -29,7 +29,6 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
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);
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case TryStartStructureConstructionMessage tryStart:
|
case TryStartStructureConstructionMessage tryStart:
|
||||||
@@ -43,7 +42,9 @@ namespace Content.Server.GameObjects.Components.Construction
|
|||||||
var prototype = _prototypeManager.Index<ConstructionPrototype>(prototypeName);
|
var prototype = _prototypeManager.Index<ConstructionPrototype>(prototypeName);
|
||||||
|
|
||||||
var transform = Owner.Transform;
|
var transform = Owner.Transform;
|
||||||
if (!loc.InRange(_mapManager, transform.GridPosition, InteractionSystem.InteractionRange))
|
|
||||||
|
var interactionSystem = _entitySystemManager.GetEntitySystem<InteractionSystem>();
|
||||||
|
if (!interactionSystem.InRangeUnobstructed(loc.ToMap(_mapManager), Owner.Transform.WorldPosition, ignoredEnt: Owner, insideBlockerValid: true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user