Merge branch 'master' of github.com:space-wizards/space-station-14-content

This commit is contained in:
Pieter-Jan Briers
2018-06-23 21:58:48 +02:00
12 changed files with 135 additions and 40 deletions

View File

@@ -37,7 +37,6 @@ namespace Content.Client.GameObjects.Components.Storage
public override void OnRemove() public override void OnRemove()
{ {
Window.Dispose(); Window.Dispose();
base.OnRemove(); base.OnRemove();
} }
@@ -53,6 +52,9 @@ namespace Content.Client.GameObjects.Components.Storage
case OpenStorageUIMessage msg: case OpenStorageUIMessage msg:
OpenUI(); OpenUI();
break; break;
case CloseStorageUIMessage msg:
// todo: close window/grey it out
break;
} }
} }

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.");
@@ -148,10 +142,8 @@ namespace Content.Server
case SessionStatus.Connected: case SessionStatus.Connected:
{ {
// timer time must be > tick length // timer time must be > tick length
IoCManager.Resolve<ITimerManager>().AddTimer(new Timer(250, false, () => Timer.Spawn(250, args.Session.JoinLobby);
{
args.Session.JoinLobby();
}));
IoCManager.Resolve<IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Player joined server!", args.Session.Index); IoCManager.Resolve<IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Player joined server!", args.Session.Index);
} }
break; break;
@@ -162,11 +154,11 @@ namespace Content.Server
if (_server.RunLevel == ServerRunLevel.PreGame && !_countdownStarted) if (_server.RunLevel == ServerRunLevel.PreGame && !_countdownStarted)
{ {
_countdownStarted = true; _countdownStarted = true;
IoCManager.Resolve<ITimerManager>().AddTimer(new Timer(2000, false, () => Timer.Spawn(2000, () =>
{ {
_server.RunLevel = ServerRunLevel.Game; _server.RunLevel = ServerRunLevel.Game;
_countdownStarted = false; _countdownStarted = false;
})); });
} }
IoCManager.Resolve<IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Player joined Lobby!", args.Session.Index); IoCManager.Resolve<IChatManager>().DispatchMessage(ChatChannel.Server, "Gamemode: Player joined Lobby!", args.Session.Index);

View File

@@ -4,6 +4,8 @@ using Content.Shared.GameObjects.Components.Storage;
using SS14.Server.GameObjects; using SS14.Server.GameObjects;
using SS14.Server.GameObjects.Components.Container; using SS14.Server.GameObjects.Components.Container;
using SS14.Server.Interfaces.Player; using SS14.Server.Interfaces.Player;
using SS14.Server.Player;
using SS14.Shared.Enums;
using SS14.Shared.GameObjects; using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Serialization; using SS14.Shared.GameObjects.Serialization;
using SS14.Shared.Interfaces.GameObjects; using SS14.Shared.Interfaces.GameObjects;
@@ -23,6 +25,7 @@ namespace Content.Server.GameObjects
private int StorageUsed = 0; private int StorageUsed = 0;
private int StorageCapacityMax = 10000; private int StorageCapacityMax = 10000;
public HashSet<IPlayerSession> SubscribedSessions = new HashSet<IPlayerSession>();
public override void OnAdd() public override void OnAdd()
{ {
@@ -47,8 +50,9 @@ namespace Content.Server.GameObjects
{ {
if (storage.Remove(toremove)) if (storage.Remove(toremove))
{ {
Logger.InfoS("Storage", "Storage (UID {0}) had entity (UID {1}) removed from it.", Owner.Uid, toremove.Uid);
StorageUsed -= toremove.GetComponent<StoreableComponent>().ObjectSize; StorageUsed -= toremove.GetComponent<StoreableComponent>().ObjectSize;
UpdateClientInventory(); UpdateClientInventories();
return true; return true;
} }
return false; return false;
@@ -63,8 +67,9 @@ namespace Content.Server.GameObjects
{ {
if (CanInsert(toinsert) && storage.Insert(toinsert)) if (CanInsert(toinsert) && storage.Insert(toinsert))
{ {
Logger.InfoS("Storage", "Storage (UID {0}) had entity (UID {1}) inserted into it.", Owner.Uid, toinsert.Uid);
StorageUsed += toinsert.GetComponent<StoreableComponent>().ObjectSize; StorageUsed += toinsert.GetComponent<StoreableComponent>().ObjectSize;
UpdateClientInventory(); UpdateClientInventories();
return true; return true;
} }
return false; return false;
@@ -93,6 +98,7 @@ namespace Content.Server.GameObjects
/// <returns></returns> /// <returns></returns>
bool IAttackby.Attackby(IEntity user, IEntity attackwith) bool IAttackby.Attackby(IEntity user, IEntity attackwith)
{ {
Logger.DebugS("Storage", "Storage (UID {0}) attacked by user (UID {1}) with entity (UID {2}).", Owner.Uid, user.Uid, attackwith.Uid);
var hands = user.GetComponent<HandsComponent>(); var hands = user.GetComponent<HandsComponent>();
//Check that we can drop the item from our hands first otherwise we obviously cant put it inside //Check that we can drop the item from our hands first otherwise we obviously cant put it inside
if (hands.Drop(hands.ActiveIndex)) if (hands.Drop(hands.ActiveIndex))
@@ -118,21 +124,76 @@ namespace Content.Server.GameObjects
/// <returns></returns> /// <returns></returns>
bool IUse.UseEntity(IEntity user) bool IUse.UseEntity(IEntity user)
{ {
SendNetworkMessage(new OpenStorageUIMessage()); var user_session = user.GetComponent<BasicActorComponent>().playerSession;
Logger.DebugS("Storage", "Storage (UID {0}) \"used\" by player session (UID {1}).", Owner.Uid, user_session.AttachedEntityUid);
SubscribeSession(user_session);
SendNetworkMessage(new OpenStorageUIMessage(), user_session.ConnectedClient);
UpdateClientInventory(user_session);
return false; return false;
} }
/// <summary> /// <summary>
/// Updates the storage UI on all clients telling them of the entities stored in this container /// Updates the storage UI on all subscribed actors, informing them of the state of the container.
/// </summary> /// </summary>
private void UpdateClientInventory() private void UpdateClientInventories()
{ {
foreach (IPlayerSession session in SubscribedSessions)
{
UpdateClientInventory(session);
}
}
/// <summary>
/// Adds actor to the update list.
/// </summary>
/// <param name="actor"></param>
public void SubscribeSession(IPlayerSession session)
{
if (!SubscribedSessions.Contains(session))
{
Logger.DebugS("Storage", "Storage (UID {0}) subscribed player session (UID {1}).", Owner.Uid, session.AttachedEntityUid);
session.PlayerStatusChanged += HandlePlayerSessionChangeEvent;
SubscribedSessions.Add(session);
}
}
/// <summary>
/// Removes actor from the update list.
/// </summary>
/// <param name="channel"></param>
public void UnsubscribeSession(IPlayerSession session)
{
Logger.DebugS("Storage", "Storage (UID {0}) unsubscribed player session (UID {1}).", Owner.Uid, session.AttachedEntityUid);
SubscribedSessions.Remove(session);
SendNetworkMessage(new CloseStorageUIMessage(), session.ConnectedClient);
}
public void HandlePlayerSessionChangeEvent(object obj, SessionStatusEventArgs SSEA)
{
Logger.DebugS("Storage", "Storage (UID {0}) handled a status change in player session (UID {1}).", Owner.Uid, SSEA.Session.AttachedEntityUid);
if (SSEA.NewStatus != SessionStatus.InGame)
{
UnsubscribeSession(SSEA.Session);
}
}
/// <summary>
/// Updates storage UI on a client, informing them of the state of the container.
/// </summary>
private void UpdateClientInventory(IPlayerSession session)
{
if (session.AttachedEntity == null)
{
Logger.DebugS("Storage", "Storage (UID {0}) detected no attached entity in player session (UID {1}).", Owner.Uid, session.AttachedEntityUid);
UnsubscribeSession(session);
return;
}
Dictionary<EntityUid, int> storedentities = new Dictionary<EntityUid, int>(); Dictionary<EntityUid, int> storedentities = new Dictionary<EntityUid, int>();
foreach (var entities in storage.ContainedEntities) foreach (var entities in storage.ContainedEntities)
{ {
storedentities.Add(entities.Uid, entities.GetComponent<StoreableComponent>().ObjectSize); storedentities.Add(entities.Uid, entities.GetComponent<StoreableComponent>().ObjectSize);
} }
SendNetworkMessage(new StorageHeldItemsMessage(storedentities, StorageUsed, StorageCapacityMax)); SendNetworkMessage(new StorageHeldItemsMessage(storedentities, StorageUsed, StorageCapacityMax), session.ConnectedClient);
} }
/// <summary> /// <summary>
@@ -148,7 +209,6 @@ namespace Content.Server.GameObjects
switch (message) switch (message)
{ {
case RemoveEntityMessage msg: case RemoveEntityMessage msg:
var playerMan = IoCManager.Resolve<IPlayerManager>(); var playerMan = IoCManager.Resolve<IPlayerManager>();
var session = playerMan.GetSessionByChannel(netChannel); var session = playerMan.GetSessionByChannel(netChannel);
@@ -165,7 +225,6 @@ namespace Content.Server.GameObjects
if (entity != null && storage.Contains(entity)) if (entity != null && storage.Contains(entity))
{ {
Remove(entity); Remove(entity);
UpdateClientInventory();
var item = entity.GetComponent<ItemComponent>(); var item = entity.GetComponent<ItemComponent>();
if (item != null && playerentity.TryGetComponent(out HandsComponent hands)) if (item != null && playerentity.TryGetComponent(out HandsComponent hands))

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);
} }
} }

View File

@@ -56,4 +56,17 @@ namespace Content.Shared.GameObjects.Components.Storage
Directed = true; Directed = true;
} }
} }
/// <summary>
/// Component message for closing the storage UI.
/// E.g when the player moves too far away from the container.
/// </summary>
[Serializable, NetSerializable]
public class CloseStorageUIMessage : ComponentMessage
{
public CloseStorageUIMessage()
{
Directed = true;
}
}
} }

View File

@@ -1,3 +1,32 @@
# space-station-14-content # Space Station 14: Content Repo [![Build Status](https://travis-ci.org/space-wizards/space-station-14-content.svg?branch=master)](https://travis-ci.org/space-wizards/space-station-14-content)
Space Station 14 is a revived attempt at an SS13 remake.
This is the primary content repo for Space Station 14. To prevent people forking the engine, a "content" pack is loaded by the client and server. This content contains everything needed to play the game on one specific server. This is the primary content repo for Space Station 14. To prevent people forking the engine, a "content" pack is loaded by the client and server. This content contains everything needed to play the game on one specific server.
If you want to develop SS14, this is the repo you need. Both for engine and content development.
## Getting in Touch
* Website: [spacestation14.io](https://spacestation14.io/)
* Discord: [Invite Link](https://discord.gg/t2jac3p)
* IRC: `irc.rizon.net#spacebus`
* Project Management Board: [Waffle](https://waffle.io/space-wizards/space-station-14)
* Automatic Content Builds: [builds.spacestation14.io](https://builds.spacestation14.io)
The IRC is setup to relay back and forth to the Discord server so [IRC nerds](https://xkcd.com/1782/) will not be left out.
## Documentation
We have various documentation articles about various systems on the GitHub wikis of this repo and the engine.
* [Engine Wiki](https://github.com/space-wizards/space-station-14/wiki)
* [Content Wiki](https://github.com/space-wizards/space-station-14-content/wiki)
## Contributing
We are happy to accept contributions from anybody. Get in Discord or IRC if you want to help. We've got a [list of issues](https://github.com/space-wizards/space-station-14-content/issues) that need to be done and anybody can pick them up. Don't be afraid to ask for help either!
## Building
[See the relevant wiki page](https://github.com/space-wizards/space-station-14-content/wiki/Getting-Started)