Construction System. (#87)

* Construction WiP

* Construction kinda works!

* Lots more construction work.

* It mostly works!
This commit is contained in:
Pieter-Jan Briers
2018-08-02 08:29:55 +02:00
committed by GitHub
parent f051078c79
commit d7074bf74f
72 changed files with 1925 additions and 245 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.GameObjects.Components.Power;
using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.Map;
namespace Content.Server.GameObjects.Components.Power
@@ -49,7 +50,7 @@ namespace Content.Server.GameObjects.Components.Power
builder.Append(" Providers:\n");
foreach (var provider in device.AvailableProviders)
{
var providerTransform = provider.Owner.GetComponent<IServerTransformComponent>();
var providerTransform = provider.Owner.GetComponent<ITransformComponent>();
builder.AppendFormat(" {0} ({1}) @ {2}", provider.Owner.Name, provider.Owner.Uid, providerTransform.LocalPosition);
if (device.Provider == provider)
{

View File

@@ -2,6 +2,7 @@
using SS14.Server.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.IoC;
using SS14.Shared.Serialization;
using SS14.Shared.Utility;
@@ -240,18 +241,18 @@ namespace Content.Server.GameObjects.Components.Power
return;
//Get the starting value for our loop
var position = Owner.GetComponent<TransformComponent>().WorldPosition;
var position = Owner.GetComponent<ITransformComponent>().WorldPosition;
var bestprovider = AvailableProviders[0];
//If we are already connected to a power provider we need to do a loop to find the nearest one, otherwise skip it and use first entry
if (Connected == DrawTypes.Provider)
{
var bestdistance = (bestprovider.Owner.GetComponent<TransformComponent>().WorldPosition - position).LengthSquared;
var bestdistance = (bestprovider.Owner.GetComponent<ITransformComponent>().WorldPosition - position).LengthSquared;
foreach (var availprovider in AvailableProviders)
{
//Find distance to new provider
var distance = (availprovider.Owner.GetComponent<TransformComponent>().WorldPosition - position).LengthSquared;
var distance = (availprovider.Owner.GetComponent<ITransformComponent>().WorldPosition - position).LengthSquared;
//If new provider distance is shorter it becomes new best possible provider
if (distance < bestdistance)

View File

@@ -1,6 +1,7 @@
using SS14.Server.GameObjects;
using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.IoC;
using System;
using System.Linq;
@@ -56,10 +57,10 @@ namespace Content.Server.GameObjects.Components.Power
return;
}
var _emanager = IoCManager.Resolve<IServerEntityManager>();
var position = Owner.GetComponent<TransformComponent>().WorldPosition;
var position = Owner.GetComponent<ITransformComponent>().WorldPosition;
var wires = _emanager.GetEntitiesIntersecting(Owner)
.Where(x => x.HasComponent<PowerTransferComponent>())
.OrderByDescending(x => (x.GetComponent<TransformComponent>().WorldPosition - position).Length);
.OrderByDescending(x => (x.GetComponent<ITransformComponent>().WorldPosition - position).Length);
var choose = wires.FirstOrDefault();
if (choose != null)
{

View File

@@ -1,6 +1,7 @@
using SS14.Server.GameObjects;
using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using SS14.Shared.Serialization;
@@ -139,7 +140,7 @@ namespace Content.Server.GameObjects.Components.Power
//Find devices within range to take under our control
var _emanager = IoCManager.Resolve<IServerEntityManager>();
var position = Owner.GetComponent<TransformComponent>().WorldPosition;
var position = Owner.GetComponent<ITransformComponent>().WorldPosition;
var entities = _emanager.GetEntitiesInRange(Owner, PowerRange)
.Where(x => x.HasComponent<PowerDeviceComponent>());

View File

@@ -6,6 +6,7 @@ using SS14.Shared.IoC;
using System.Linq;
using SS14.Shared.Interfaces.GameObjects;
using Content.Server.GameObjects.Components.Interactable.Tools;
using SS14.Shared.Interfaces.GameObjects.Components;
namespace Content.Server.GameObjects.Components.Power
{
@@ -44,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Power
public void SpreadPowernet()
{
var _emanager = IoCManager.Resolve<IServerEntityManager>();
var position = Owner.GetComponent<TransformComponent>().WorldPosition;
var position = Owner.GetComponent<ITransformComponent>().WorldPosition;
var wires = _emanager.GetEntitiesInRange(Owner, 1.1f) //arbitrarily low, just scrape things //wip
.Where(x => x.HasComponent<PowerTransferComponent>());