From 9b251d70e25d9b350299d41cdc3098dfbc6a61bf Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sat, 9 Jun 2018 15:48:54 +0200 Subject: [PATCH 1/4] Readme & submodule update. --- README.md | 31 ++++++++++++++++++++++++++++++- engine | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 32a9cb153a..5fb122c496 100644 --- a/README.md +++ b/README.md @@ -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. + +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) diff --git a/engine b/engine index 0563a5beb3..170e1ad5af 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit 0563a5beb3a850a09ffd6bb6f85f0721d9f3646f +Subproject commit 170e1ad5afe018339b3936550260dc91fb296505 From 10999dc9059e9824ba034dc502be41b7342724c7 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sun, 10 Jun 2018 01:03:49 +0200 Subject: [PATCH 2/4] Grid map detaching: content edition. --- Content.Server/EntryPoint.cs | 16 +++++----------- .../Components/Power/PowerDebugTool.cs | 2 +- .../Weapon/Melee/MeleeWeaponComponent.cs | 2 +- .../Ranged/Hitscan/HitscanWeaponComponent.cs | 2 +- .../Weapon/Ranged/Projectile/ProjectileWeapon.cs | 2 +- .../Components/Weapon/Ranged/RangedWeapon.cs | 4 ++-- .../EntitySystems/Click/InteractionSystem.cs | 10 +++++----- Content.Server/Placement/SpawnHelpers.cs | 4 ++-- engine | 2 +- 9 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs index 2f3abf50d0..85d14bff3a 100644 --- a/Content.Server/EntryPoint.cs +++ b/Content.Server/EntryPoint.cs @@ -111,21 +111,15 @@ namespace Content.Server { case ServerRunLevel.PreGame: var timing = IoCManager.Resolve(); - - var mainMap = new MapId(1); - var mainGrid = new GridId(1); - - IoCManager.Resolve().FallbackSpawnPoint = new LocalCoordinates(0, 0, mainGrid, mainMap); - var mapLoader = IoCManager.Resolve(); var mapMan = IoCManager.Resolve(); - var startTime = timing.RealTime; - { - var newMap = mapMan.CreateMap(mainMap); + var newMap = mapMan.CreateMap(); + var grid = mapLoader.LoadBlueprint(newMap, "Maps/stationstation.yml"); - mapLoader.LoadBlueprint(newMap, mainGrid, "Maps/stationstation.yml"); - } + IoCManager.Resolve().FallbackSpawnPoint = new GridLocalCoordinates(Vector2.Zero, grid); + + var startTime = timing.RealTime; var timeSpan = timing.RealTime - startTime; Logger.Info($"Loaded map in {timeSpan.TotalMilliseconds:N2}ms."); diff --git a/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs b/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs index 37946e2511..56ad6ae66c 100644 --- a/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs +++ b/Content.Server/GameObjects/Components/Power/PowerDebugTool.cs @@ -10,7 +10,7 @@ namespace Content.Server.GameObjects.Components.Power { 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) { diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs index cf9cfb1abf..c84073a629 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs @@ -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().LocalPosition; var angle = new Angle(clicklocation.ToWorld().Position - location.ToWorld().Position); diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs index 0a78c59c7b..6df584f59a 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Hitscan/HitscanWeaponComponent.cs @@ -20,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Hitscan 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().WorldPosition; //Remember world positions are ephemeral and can only be used instantaneously var angle = new Angle(clicklocation.Position - userposition); diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs index 84e758b31c..7f0157a48b 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Projectile/ProjectileWeapon.cs @@ -17,7 +17,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Projectile private float _velocity = 20f; - protected override void Fire(IEntity user, LocalCoordinates clicklocation) + protected override void Fire(IEntity user, GridLocalCoordinates clicklocation) { var userposition = user.GetComponent().LocalPosition; //Remember world positions are ephemeral and can only be used instantaneously var angle = new Angle(clicklocation.Position - userposition.Position); diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs index 3edad9c967..869b3faf8c 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs @@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged { 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()) { @@ -27,7 +27,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged return true; } - protected virtual void Fire(IEntity user, LocalCoordinates clicklocation) + protected virtual void Fire(IEntity user, GridLocalCoordinates clicklocation) { return; } diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 7b6dce0985..62f34eba08 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -51,7 +51,7 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - bool RangedAttackby(IEntity user, IEntity attackwith, LocalCoordinates clicklocation); + bool RangedAttackby(IEntity user, IEntity attackwith, GridLocalCoordinates clicklocation); } /// @@ -66,7 +66,7 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// The entity that was clicked on out of range. May be null if no entity was clicked on.true - void Afterattack(IEntity user, LocalCoordinates clicklocation, IEntity attacked); + void Afterattack(IEntity user, GridLocalCoordinates clicklocation, IEntity attacked); } /// @@ -193,7 +193,7 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - public static void InteractAfterattack(IEntity user, IEntity weapon, LocalCoordinates clicklocation) + public static void InteractAfterattack(IEntity user, IEntity weapon, GridLocalCoordinates clicklocation) { List afterattacks = weapon.GetAllComponents().ToList(); @@ -210,7 +210,7 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - 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 interactables = attacked.GetAllComponents().ToList(); @@ -296,7 +296,7 @@ namespace Content.Server.GameObjects.EntitySystems /// /// /// - 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 rangedusables = attacked.GetAllComponents().ToList(); diff --git a/Content.Server/Placement/SpawnHelpers.cs b/Content.Server/Placement/SpawnHelpers.cs index cbcba32a5c..51f7b6d28c 100644 --- a/Content.Server/Placement/SpawnHelpers.cs +++ b/Content.Server/Placement/SpawnHelpers.cs @@ -20,10 +20,10 @@ namespace Content.Server.Placement { var entMan = IoCManager.Resolve(); var tBase = entMan.SpawnEntity("TurretBase"); - tBase.GetComponent().LocalPosition = new LocalCoordinates(localPosition, grid); + tBase.GetComponent().LocalPosition = new GridLocalCoordinates(localPosition, grid); var tTop = entMan.SpawnEntity("TurretTopLight"); - tTop.GetComponent().LocalPosition = new LocalCoordinates(localPosition, grid); + tTop.GetComponent().LocalPosition = new GridLocalCoordinates(localPosition, grid); tTop.GetComponent().AttachParent(tBase); } } diff --git a/engine b/engine index 170e1ad5af..653d1c9c44 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit 170e1ad5afe018339b3936550260dc91fb296505 +Subproject commit 653d1c9c440df0a27823df6b280b0bcfb9668e3f From e4c378cb8faa576d8cd064c22a3911e4abbaaf77 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 11 Jun 2018 20:30:52 +0200 Subject: [PATCH 3/4] Update submodule & clean up code with Timer.Spawn(). --- Content.Server/EntryPoint.cs | 10 ++++------ engine | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs index 2f3abf50d0..cdea59e06a 100644 --- a/Content.Server/EntryPoint.cs +++ b/Content.Server/EntryPoint.cs @@ -148,10 +148,8 @@ namespace Content.Server case SessionStatus.Connected: { // timer time must be > tick length - IoCManager.Resolve().AddTimer(new Timer(250, false, () => - { - args.Session.JoinLobby(); - })); + Timer.Spawn(250, args.Session.JoinLobby); + IoCManager.Resolve().DispatchMessage(ChatChannel.Server, "Gamemode: Player joined server!", args.Session.Index); } break; @@ -162,11 +160,11 @@ namespace Content.Server if (_server.RunLevel == ServerRunLevel.PreGame && !_countdownStarted) { _countdownStarted = true; - IoCManager.Resolve().AddTimer(new Timer(2000, false, () => + Timer.Spawn(2000, () => { _server.RunLevel = ServerRunLevel.Game; _countdownStarted = false; - })); + }); } IoCManager.Resolve().DispatchMessage(ChatChannel.Server, "Gamemode: Player joined Lobby!", args.Session.Index); diff --git a/engine b/engine index 170e1ad5af..f1d3d2c5ce 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit 170e1ad5afe018339b3936550260dc91fb296505 +Subproject commit f1d3d2c5ce73f063053fe27a09f09bd4deb541f0 From 2d23c6a45ea73092b16fe173834f8e320a163407 Mon Sep 17 00:00:00 2001 From: indeano <38874984+indeano@users.noreply.github.com> Date: Wed, 20 Jun 2018 16:49:13 -0400 Subject: [PATCH 4/4] Some work on directing storage component's client updates (#75) * adds storage system, primitive client-unsubscribing of storage updates * strips out currently unneeded system * channel to actor * closestorageui todo added * thorough logging, actor to session, validates session before sending packets * offloads session status check to an event handler --- .../Storage/ClientStorageComponent.cs | 4 +- .../Items/Storage/ServerStorageComponent.cs | 75 +++++++++++++++++-- .../Storage/SharedStorageComponent.cs | 13 ++++ 3 files changed, 83 insertions(+), 9 deletions(-) diff --git a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs index f20cc4d31c..bfe0082186 100644 --- a/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs +++ b/Content.Client/GameObjects/Components/Storage/ClientStorageComponent.cs @@ -37,7 +37,6 @@ namespace Content.Client.GameObjects.Components.Storage public override void OnRemove() { Window.Dispose(); - base.OnRemove(); } @@ -53,6 +52,9 @@ namespace Content.Client.GameObjects.Components.Storage case OpenStorageUIMessage msg: OpenUI(); break; + case CloseStorageUIMessage msg: + // todo: close window/grey it out + break; } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index d0f8982502..617d7d1770 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -4,6 +4,8 @@ using Content.Shared.GameObjects.Components.Storage; using SS14.Server.GameObjects; using SS14.Server.GameObjects.Components.Container; using SS14.Server.Interfaces.Player; +using SS14.Server.Player; +using SS14.Shared.Enums; using SS14.Shared.GameObjects; using SS14.Shared.GameObjects.Serialization; using SS14.Shared.Interfaces.GameObjects; @@ -23,6 +25,7 @@ namespace Content.Server.GameObjects private int StorageUsed = 0; private int StorageCapacityMax = 10000; + public HashSet SubscribedSessions = new HashSet(); public override void OnAdd() { @@ -47,8 +50,9 @@ namespace Content.Server.GameObjects { if (storage.Remove(toremove)) { + Logger.InfoS("Storage", "Storage (UID {0}) had entity (UID {1}) removed from it.", Owner.Uid, toremove.Uid); StorageUsed -= toremove.GetComponent().ObjectSize; - UpdateClientInventory(); + UpdateClientInventories(); return true; } return false; @@ -63,8 +67,9 @@ namespace Content.Server.GameObjects { 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().ObjectSize; - UpdateClientInventory(); + UpdateClientInventories(); return true; } return false; @@ -93,6 +98,7 @@ namespace Content.Server.GameObjects /// 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(); //Check that we can drop the item from our hands first otherwise we obviously cant put it inside if (hands.Drop(hands.ActiveIndex)) @@ -118,21 +124,76 @@ namespace Content.Server.GameObjects /// bool IUse.UseEntity(IEntity user) { - SendNetworkMessage(new OpenStorageUIMessage()); + var user_session = user.GetComponent().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; } /// - /// 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. /// - private void UpdateClientInventory() + private void UpdateClientInventories() { + foreach (IPlayerSession session in SubscribedSessions) + { + UpdateClientInventory(session); + } + } + + /// + /// Adds actor to the update list. + /// + /// + 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); + } + } + + /// + /// Removes actor from the update list. + /// + /// + 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); + } + } + + /// + /// Updates storage UI on a client, informing them of the state of the container. + /// + 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 storedentities = new Dictionary(); foreach (var entities in storage.ContainedEntities) { storedentities.Add(entities.Uid, entities.GetComponent().ObjectSize); } - SendNetworkMessage(new StorageHeldItemsMessage(storedentities, StorageUsed, StorageCapacityMax)); + SendNetworkMessage(new StorageHeldItemsMessage(storedentities, StorageUsed, StorageCapacityMax), session.ConnectedClient); } /// @@ -148,7 +209,6 @@ namespace Content.Server.GameObjects switch (message) { - case RemoveEntityMessage msg: var playerMan = IoCManager.Resolve(); var session = playerMan.GetSessionByChannel(netChannel); @@ -165,7 +225,6 @@ namespace Content.Server.GameObjects if (entity != null && storage.Contains(entity)) { Remove(entity); - UpdateClientInventory(); var item = entity.GetComponent(); if (item != null && playerentity.TryGetComponent(out HandsComponent hands)) diff --git a/Content.Shared/GameObjects/Components/Storage/SharedStorageComponent.cs b/Content.Shared/GameObjects/Components/Storage/SharedStorageComponent.cs index 385e778825..c0f1749cd2 100644 --- a/Content.Shared/GameObjects/Components/Storage/SharedStorageComponent.cs +++ b/Content.Shared/GameObjects/Components/Storage/SharedStorageComponent.cs @@ -56,4 +56,17 @@ namespace Content.Shared.GameObjects.Components.Storage Directed = true; } } + + /// + /// Component message for closing the storage UI. + /// E.g when the player moves too far away from the container. + /// + [Serializable, NetSerializable] + public class CloseStorageUIMessage : ComponentMessage + { + public CloseStorageUIMessage() + { + Directed = true; + } + } }