Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Perpetuum.Containers;
using Perpetuum.EntityFramework;
using Perpetuum.Host.Requests;
using Perpetuum.Modules;
using Perpetuum.Players;
Expand Down Expand Up @@ -46,17 +47,38 @@ protected static ErrorCodes CheckCombatState(Player player)

protected static ErrorCodes CheckFieldTerminalRange(Player player, Container container)
{
var fieldTerminal = container.ParentEntity as FieldTerminal;
var fieldTerminal = GetFieldTerminal(container);
if (fieldTerminal == null)
return ErrorCodes.NoError;

var inRange = player.IsInRangeOf3D(fieldTerminal, DistanceConstants.FIELD_TERMINAL_USE);
if (!inRange)
if (!InRange(player, fieldTerminal))
return ErrorCodes.ItemOutOfRange;

return ErrorCodes.NoError;
}

private static FieldTerminal GetFieldTerminal(Entity container)
{
if (container == null)
return null;

var fieldTerminal = container.ParentEntity as FieldTerminal;
while (fieldTerminal == null)
{
container = container.ParentEntity;
if(container == null)
break;

fieldTerminal = container.ParentEntity as FieldTerminal;
}
return fieldTerminal;
}

private static bool InRange(Player player, FieldTerminal fieldTerminal)
{
return player.IsInRangeOf3D(fieldTerminal, DistanceConstants.FIELD_TERMINAL_USE);
}

protected static ErrorCodes CheckActiveModules(Player player)
{
var hasNotIdleModule = player.ActiveModules.Any(m => m.State.Type != ModuleStateType.Idle);
Expand Down