Merge remote-tracking branch 'origin/18-06-09-gridentities'

This commit is contained in:
PJB3005
2018-06-13 04:26:04 +02:00
8 changed files with 18 additions and 24 deletions

View File

@@ -111,21 +111,15 @@ namespace Content.Server
{ {
case ServerRunLevel.PreGame: case ServerRunLevel.PreGame:
var timing = IoCManager.Resolve<IGameTiming>(); var timing = IoCManager.Resolve<IGameTiming>();
var mainMap = new MapId(1);
var mainGrid = new GridId(1);
IoCManager.Resolve<IPlayerManager>().FallbackSpawnPoint = new LocalCoordinates(0, 0, mainGrid, mainMap);
var mapLoader = IoCManager.Resolve<IMapLoader>(); var mapLoader = IoCManager.Resolve<IMapLoader>();
var mapMan = IoCManager.Resolve<IMapManager>(); var mapMan = IoCManager.Resolve<IMapManager>();
var startTime = timing.RealTime; var newMap = mapMan.CreateMap();
{ var grid = mapLoader.LoadBlueprint(newMap, "Maps/stationstation.yml");
var newMap = mapMan.CreateMap(mainMap);
mapLoader.LoadBlueprint(newMap, mainGrid, "Maps/stationstation.yml"); IoCManager.Resolve<IPlayerManager>().FallbackSpawnPoint = new GridLocalCoordinates(Vector2.Zero, grid);
}
var startTime = timing.RealTime;
var timeSpan = timing.RealTime - startTime; var timeSpan = timing.RealTime - startTime;
Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms."); Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms.");

View File

@@ -10,7 +10,7 @@ namespace Content.Server.GameObjects.Components.Power
{ {
public class PowerDebugTool : SharedPowerDebugTool, IAfterAttack public class PowerDebugTool : SharedPowerDebugTool, IAfterAttack
{ {
void IAfterAttack.Afterattack(IEntity user, LocalCoordinates clicklocation, IEntity attacked) void IAfterAttack.Afterattack(IEntity user, GridLocalCoordinates clicklocation, IEntity attacked)
{ {
if (attacked == null) if (attacked == null)
{ {

View File

@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
} }
void IAfterAttack.Afterattack(IEntity user, LocalCoordinates clicklocation, IEntity attacked) void IAfterAttack.Afterattack(IEntity user, GridLocalCoordinates clicklocation, IEntity attacked)
{ {
var location = user.GetComponent<TransformComponent>().LocalPosition; var location = user.GetComponent<TransformComponent>().LocalPosition;
var angle = new Angle(clicklocation.ToWorld().Position - location.ToWorld().Position); var angle = new Angle(clicklocation.ToWorld().Position - location.ToWorld().Position);

View File

@@ -20,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan
string spritename = "Objects/laser.png"; string spritename = "Objects/laser.png";
protected override void Fire(IEntity user, LocalCoordinates clicklocation) protected override void Fire(IEntity user, GridLocalCoordinates clicklocation)
{ {
var userposition = user.GetComponent<TransformComponent>().WorldPosition; //Remember world positions are ephemeral and can only be used instantaneously var userposition = user.GetComponent<TransformComponent>().WorldPosition; //Remember world positions are ephemeral and can only be used instantaneously
var angle = new Angle(clicklocation.Position - userposition); var angle = new Angle(clicklocation.Position - userposition);

View File

@@ -17,7 +17,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile
private float _velocity = 20f; private float _velocity = 20f;
protected override void Fire(IEntity user, LocalCoordinates clicklocation) protected override void Fire(IEntity user, GridLocalCoordinates clicklocation)
{ {
var userposition = user.GetComponent<TransformComponent>().LocalPosition; //Remember world positions are ephemeral and can only be used instantaneously var userposition = user.GetComponent<TransformComponent>().LocalPosition; //Remember world positions are ephemeral and can only be used instantaneously
var angle = new Angle(clicklocation.Position - userposition.Position); var angle = new Angle(clicklocation.Position - userposition.Position);

View File

@@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
{ {
public override string Name => "RangedWeapon"; public override string Name => "RangedWeapon";
void IAfterAttack.Afterattack(IEntity user, LocalCoordinates clicklocation, IEntity attacked) void IAfterAttack.Afterattack(IEntity user, GridLocalCoordinates clicklocation, IEntity attacked)
{ {
if (UserCanFire(user) && WeaponCanFire()) if (UserCanFire(user) && WeaponCanFire())
{ {
@@ -27,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
return true; return true;
} }
protected virtual void Fire(IEntity user, LocalCoordinates clicklocation) protected virtual void Fire(IEntity user, GridLocalCoordinates clicklocation)
{ {
return; return;
} }

View File

@@ -51,7 +51,7 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="attackwith"></param> /// <param name="attackwith"></param>
/// <param name="clicklocation"></param> /// <param name="clicklocation"></param>
/// <returns></returns> /// <returns></returns>
bool RangedAttackby(IEntity user, IEntity attackwith, LocalCoordinates clicklocation); bool RangedAttackby(IEntity user, IEntity attackwith, GridLocalCoordinates clicklocation);
} }
/// <summary> /// <summary>
@@ -66,7 +66,7 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="clicklocation"></param> /// <param name="clicklocation"></param>
/// <param name="attacked">The entity that was clicked on out of range. May be null if no entity was clicked on.true</param> /// <param name="attacked">The entity that was clicked on out of range. May be null if no entity was clicked on.true</param>
void Afterattack(IEntity user, LocalCoordinates clicklocation, IEntity attacked); void Afterattack(IEntity user, GridLocalCoordinates clicklocation, IEntity attacked);
} }
/// <summary> /// <summary>
@@ -193,7 +193,7 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="weapon"></param> /// <param name="weapon"></param>
/// <param name="clicklocation"></param> /// <param name="clicklocation"></param>
public static void InteractAfterattack(IEntity user, IEntity weapon, LocalCoordinates clicklocation) public static void InteractAfterattack(IEntity user, IEntity weapon, GridLocalCoordinates clicklocation)
{ {
List<IAfterAttack> afterattacks = weapon.GetAllComponents<IAfterAttack>().ToList(); List<IAfterAttack> afterattacks = weapon.GetAllComponents<IAfterAttack>().ToList();
@@ -210,7 +210,7 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="weapon"></param> /// <param name="weapon"></param>
/// <param name="attacked"></param> /// <param name="attacked"></param>
public static void Interaction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation) public static void Interaction(IEntity user, IEntity weapon, IEntity attacked, GridLocalCoordinates clicklocation)
{ {
List<IAttackby> interactables = attacked.GetAllComponents<IAttackby>().ToList(); List<IAttackby> interactables = attacked.GetAllComponents<IAttackby>().ToList();
@@ -296,7 +296,7 @@ namespace Content.Server.GameObjects.EntitySystems
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="weapon"></param> /// <param name="weapon"></param>
/// <param name="attacked"></param> /// <param name="attacked"></param>
public static void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, LocalCoordinates clicklocation) public static void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, GridLocalCoordinates clicklocation)
{ {
List<IRangedAttackby> rangedusables = attacked.GetAllComponents<IRangedAttackby>().ToList(); List<IRangedAttackby> rangedusables = attacked.GetAllComponents<IRangedAttackby>().ToList();

View File

@@ -20,10 +20,10 @@ namespace Content.Server.Placement
{ {
var entMan = IoCManager.Resolve<IServerEntityManager>(); var entMan = IoCManager.Resolve<IServerEntityManager>();
var tBase = entMan.SpawnEntity("TurretBase"); var tBase = entMan.SpawnEntity("TurretBase");
tBase.GetComponent<IServerTransformComponent>().LocalPosition = new LocalCoordinates(localPosition, grid); tBase.GetComponent<IServerTransformComponent>().LocalPosition = new GridLocalCoordinates(localPosition, grid);
var tTop = entMan.SpawnEntity("TurretTopLight"); var tTop = entMan.SpawnEntity("TurretTopLight");
tTop.GetComponent<IServerTransformComponent>().LocalPosition = new LocalCoordinates(localPosition, grid); tTop.GetComponent<IServerTransformComponent>().LocalPosition = new GridLocalCoordinates(localPosition, grid);
tTop.GetComponent<IServerTransformComponent>().AttachParent(tBase); tTop.GetComponent<IServerTransformComponent>().AttachParent(tBase);
} }
} }