Skip to content

Commit

Permalink
Merge branch 'master' into improve_gliding
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit authored Jan 1, 2024
2 parents 3970033 + a9bf040 commit ba0aa92
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 93 deletions.
13 changes: 7 additions & 6 deletions OpenDreamClient/Rendering/AtomGlideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ private sealed class Glide(TransformComponent transform) {
public override void Initialize() {
_spriteQuery = _entityManager.GetEntityQuery<DMISpriteComponent>();

SubscribeLocalEvent<TransformComponent, MoveEvent>(OnTransformMove);

_transformSystem.OnGlobalMoveEvent += OnTransformMove;
}

public override void Shutdown() {
Expand Down Expand Up @@ -77,18 +78,18 @@ public override void FrameUpdate(float frameTime) {
/// <summary>
/// Disables RT lerping and sets up the entity's glide
/// </summary>
private void OnTransformMove(EntityUid entity, TransformComponent transform, ref MoveEvent e) {
private void OnTransformMove(ref MoveEvent e) {
if (_ignoreMoveEvent || e.ParentChanged)
return;
if (!_spriteQuery.TryGetComponent(entity, out var sprite) || sprite.Icon?.Appearance is null)
if (!_spriteQuery.TryGetComponent(e.Sender, out var sprite) || sprite.Icon?.Appearance is null)
return;

_ignoreMoveEvent = true;

// Look for any in-progress glides on this transform
Glide? glide = null;
foreach (var potentiallyThisTransform in _currentGlides) {
if (potentiallyThisTransform.Transform != transform)
if (potentiallyThisTransform.Transform != e.Component)
continue;

glide = potentiallyThisTransform;
Expand All @@ -110,13 +111,13 @@ private void OnTransformMove(EntityUid entity, TransformComponent transform, ref
}

if (glide == null) {
glide = new(transform);
glide = new(e.Component);
_currentGlides.Add(glide);
}

// Move the transform to our starting point
// Also serves the function of disabling RT's lerp
_transformSystem.SetLocalPositionNoLerp(entity, startingFrom);
_transformSystem.SetLocalPositionNoLerp(e.Sender, startingFrom, e.Component);

glide.EndPos = glidingTo;
glide.MovementSpeed = CalculateMovementSpeed(sprite.Icon.Appearance.GlideSize);
Expand Down
38 changes: 19 additions & 19 deletions OpenDreamClient/Rendering/ClientScreenOverlaySystem.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
using OpenDreamShared.Rendering;

namespace OpenDreamClient.Rendering {
sealed class ClientScreenOverlaySystem : SharedScreenOverlaySystem {
public HashSet<EntityUid> ScreenObjects = new();
namespace OpenDreamClient.Rendering;

[Dependency] private IEntityManager _entityManager = default!;
internal sealed class ClientScreenOverlaySystem : SharedScreenOverlaySystem {
public HashSet<EntityUid> ScreenObjects = new();

public override void Initialize() {
SubscribeNetworkEvent<AddScreenObjectEvent>(OnAddScreenObject);
SubscribeNetworkEvent<RemoveScreenObjectEvent>(OnRemoveScreenObject);
}
[Dependency] private readonly IEntityManager _entityManager = default!;

public override void Shutdown() {
ScreenObjects.Clear();
}
public override void Initialize() {
SubscribeNetworkEvent<AddScreenObjectEvent>(OnAddScreenObject);
SubscribeNetworkEvent<RemoveScreenObjectEvent>(OnRemoveScreenObject);
}

public override void Shutdown() {
ScreenObjects.Clear();
}

private void OnAddScreenObject(AddScreenObjectEvent e) {
EntityUid ent = _entityManager.GetEntity(e.ScreenObject);
ScreenObjects.Add(ent);
}
private void OnAddScreenObject(AddScreenObjectEvent e) {
EntityUid ent = _entityManager.GetEntity(e.ScreenObject);
ScreenObjects.Add(ent);
}

private void OnRemoveScreenObject(RemoveScreenObjectEvent e) {
EntityUid ent = _entityManager.GetEntity(e.ScreenObject);
ScreenObjects.Remove(ent);
}
private void OnRemoveScreenObject(RemoveScreenObjectEvent e) {
EntityUid ent = _entityManager.GetEntity(e.ScreenObject);
ScreenObjects.Remove(ent);
}
}
17 changes: 12 additions & 5 deletions OpenDreamPackaging/DreamPackaging.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Robust.Packaging;
using Robust.Packaging.AssetProcessing;
using Robust.Packaging.AssetProcessing.Passes;

namespace OpenDreamPackaging;

Expand All @@ -19,13 +20,21 @@ public static async Task WriteResources(

var inputPass = graph.Input;

await RobustClientPackaging.WriteClientResources(
contentDir,
await RobustSharedPackaging.WriteContentAssemblies(
inputPass,
cancel);
contentDir,
"Content.Client",
new[] { "OpenDreamClient", "OpenDreamShared" },
cancel: cancel);

await RobustClientPackaging.WriteClientResources(contentDir, inputPass, cancel);

WriteRscResources(dreamRootDir, resources, inputPass);

inputPass.InjectFinished();
}

public static void WriteRscResources(string dreamRootDir, string[] resources, AssetPassPipe inputPass) {
for (var i = 0; i < resources.Length; i++) {
var resource = resources[i].Replace('\\', Path.DirectorySeparatorChar);
// The game client only knows a resource ID, so that's what we name the files.
Expand All @@ -35,7 +44,5 @@ await RobustClientPackaging.WriteClientResources(

inputPass.InjectFileFromDisk(path, diskPath);
}

inputPass.InjectFinished();
}
}
43 changes: 43 additions & 0 deletions OpenDreamRuntime/DreamAczProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using OpenDreamPackaging;
using Robust.Packaging;
using Robust.Packaging.AssetProcessing;
using Robust.Server.ServerStatus;

namespace OpenDreamRuntime;

public sealed class DreamAczProvider : IMagicAczProvider, IFullHybridAczProvider {
private readonly IDependencyCollection _dependencies;
private readonly string _rootPath;
private readonly string[] _resources;

public DreamAczProvider(IDependencyCollection dependencies, string rootPath, string[] resources) {
_dependencies = dependencies;
_rootPath = rootPath;
_resources = resources;
}

public async Task Package(AssetPass pass, IPackageLogger logger, CancellationToken cancel) {
var contentDir = DefaultMagicAczProvider.FindContentRootPath(_dependencies);

await DreamPackaging.WriteResources(contentDir, _rootPath, _resources, pass, logger, cancel);
}

public Task Package(AssetPass hybridPackageInput, AssetPass output, IPackageLogger logger, CancellationToken cancel) {
var clientAssetGraph = new RobustClientAssetGraph();
var resourceInput = clientAssetGraph.Input;
output.AddDependency(clientAssetGraph.Output);
output.AddDependency(hybridPackageInput);

AssetGraph.CalculateGraph(
clientAssetGraph.AllPasses.Concat(new[] { hybridPackageInput, output }).ToArray(),
logger);

DreamPackaging.WriteRscResources(_rootPath, _resources, resourceInput);
resourceInput.InjectFinished();

return Task.CompletedTask;
}
}
26 changes: 0 additions & 26 deletions OpenDreamRuntime/DreamMagicAczProvider.cs

This file was deleted.

8 changes: 4 additions & 4 deletions OpenDreamRuntime/DreamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public bool LoadJson(string? jsonPath) {
}

_compiledJson = json;
var rootPath = Path.GetDirectoryName(jsonPath)!;
var rootPath = Path.GetFullPath(Path.GetDirectoryName(jsonPath)!);
var resources = _compiledJson.Resources ?? Array.Empty<string>();
_dreamResourceManager.Initialize(rootPath, resources);
if(!string.IsNullOrEmpty(_compiledJson.Interface) && !_dreamResourceManager.DoesFileExist(_compiledJson.Interface))
Expand Down Expand Up @@ -146,9 +146,9 @@ public bool LoadJson(string? jsonPath) {

_dreamMapManager.LoadMaps(_compiledJson.Maps);

_statusHost.SetMagicAczProvider(new DreamMagicAczProvider(
_dependencyCollection, rootPath, resources
));
var aczProvider = new DreamAczProvider(_dependencyCollection, rootPath, resources);
_statusHost.SetMagicAczProvider(aczProvider);
_statusHost.SetFullHybridAczProvider(aczProvider);

return true;
}
Expand Down
7 changes: 3 additions & 4 deletions OpenDreamRuntime/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ public sealed class EntryPoint : GameServer {
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IDreamDebugManager _debugManager = default!;
[Dependency] private readonly ServerInfoManager _serverInfoManager = default!;

private DreamCommandSystem? _commandSystem;

public override void Init() {
IoCManager.Resolve<IStatusHost>().SetMagicAczProvider(new DefaultMagicAczProvider(
new DefaultMagicAczInfo("Content.Client", new[] {"OpenDreamClient", "OpenDreamShared"}),
IoCManager.Resolve<IDependencyCollection>()));

IComponentFactory componentFactory = IoCManager.Resolve<IComponentFactory>();
componentFactory.DoAutoRegistrations();

Expand All @@ -55,6 +52,8 @@ public override void Init() {
}

_prototypeManager.LoadDirectory(new ResPath("/Resources/Prototypes"));

_serverInfoManager.Initialize();
}

public override void PostInit() {
Expand Down
41 changes: 13 additions & 28 deletions OpenDreamRuntime/Rendering/ServerScreenOverlaySystem.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
using OpenDreamRuntime.Objects.Types;
using OpenDreamShared.Rendering;
using Robust.Server.GameStates;
using Robust.Shared.Player;

namespace OpenDreamRuntime.Rendering {
public sealed class ServerScreenOverlaySystem : SharedScreenOverlaySystem {
private readonly Dictionary<ICommonSession, HashSet<EntityUid>> _sessionToScreenObjects = new();
[Dependency] private readonly IEntityManager _entityManager = default!;
namespace OpenDreamRuntime.Rendering;

public override void Initialize() {
SubscribeLocalEvent<ExpandPvsEvent>(HandleExpandPvsEvent);
}
public sealed class ServerScreenOverlaySystem : SharedScreenOverlaySystem {
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly PvsOverrideSystem _pvsOverride = default!;

public void AddScreenObject(DreamConnection connection, DreamObjectMovable screenObject) {
if (!_sessionToScreenObjects.TryGetValue(connection.Session, out var objects)) {
objects = new HashSet<EntityUid>();
_sessionToScreenObjects.Add(connection.Session, objects);
}
public void AddScreenObject(DreamConnection connection, DreamObjectMovable screenObject) {
_pvsOverride.AddForceSend(screenObject.Entity, connection.Session);

objects.Add(screenObject.Entity);
NetEntity ent = _entityManager.GetNetEntity(screenObject.Entity);
RaiseNetworkEvent(new AddScreenObjectEvent(ent), connection.Session.ConnectedClient);
}
NetEntity ent = _entityManager.GetNetEntity(screenObject.Entity);
RaiseNetworkEvent(new AddScreenObjectEvent(ent), connection.Session.ConnectedClient);
}

public void RemoveScreenObject(DreamConnection connection, DreamObjectMovable screenObject) {
_sessionToScreenObjects[connection.Session].Remove(screenObject.Entity);
NetEntity ent = _entityManager.GetNetEntity(screenObject.Entity);
RaiseNetworkEvent(new RemoveScreenObjectEvent(ent), connection.Session.ConnectedClient);
}
public void RemoveScreenObject(DreamConnection connection, DreamObjectMovable screenObject) {
_pvsOverride.RemoveForceSend(screenObject.Entity, connection.Session);

private void HandleExpandPvsEvent(ref ExpandPvsEvent e) {
if (_sessionToScreenObjects.TryGetValue(e.Session, out var objects)) {
e.Entities ??= new(objects.Count);
e.Entities.AddRange(objects);
}
}
NetEntity ent = _entityManager.GetNetEntity(screenObject.Entity);
RaiseNetworkEvent(new RemoveScreenObjectEvent(ent), connection.Session.ConnectedClient);
}
}
1 change: 1 addition & 0 deletions OpenDreamRuntime/ServerContentIoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void Register(bool unitTests = false) {
IoCManager.Register<DreamResourceManager>();
IoCManager.Register<WalkManager, WalkManager>();
IoCManager.Register<IDreamDebugManager, DreamDebugManager>();
IoCManager.Register<ServerInfoManager>();

#if DEBUG
IoCManager.Register<LocalHostConGroup>();
Expand Down
38 changes: 38 additions & 0 deletions OpenDreamRuntime/ServerInfoManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Text.Json.Nodes;
using OpenDreamShared;
using Robust.Server.ServerStatus;
using Robust.Shared.Configuration;

namespace OpenDreamRuntime;

/// <summary>
/// Adds additional data like info links to the server info endpoint
/// </summary>
public sealed class ServerInfoManager {
private static readonly (CVarDef<string> cVar, string icon, string name)[] Vars = {
// @formatter:off
(OpenDreamCVars.InfoLinksDiscord, "discord", "Discord"),
(OpenDreamCVars.InfoLinksForum, "forum", "Forum"),
(OpenDreamCVars.InfoLinksGithub, "github", "GitHub"),
(OpenDreamCVars.InfoLinksWebsite, "web", "Website"),
(OpenDreamCVars.InfoLinksWiki, "wiki", "Wiki")
// @formatter:on
};

[Dependency] private readonly IStatusHost _statusHost = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

public void Initialize() {
_statusHost.OnInfoRequest += OnInfoRequest;
}

private void OnInfoRequest(JsonNode json) {
foreach (var (cVar, icon, name) in Vars) {
var url = _cfg.GetCVar(cVar);
if (string.IsNullOrEmpty(url))
continue;

StatusHostHelpers.AddLink(json, name, url, icon);
}
}
}
34 changes: 34 additions & 0 deletions OpenDreamShared/OpenDreamCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,39 @@ public abstract class OpenDreamCVars {

public static readonly CVarDef<ushort> TopicPort =
CVarDef.Create<ushort>("opendream.topic_port", 25567, CVar.SERVERONLY);

/*
* INFOLINKS
*/

/// <summary>
/// Link to Discord server to show in the launcher.
/// </summary>
public static readonly CVarDef<string> InfoLinksDiscord =
CVarDef.Create("infolinks.discord", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Link to forum to show in the launcher.
/// </summary>
public static readonly CVarDef<string> InfoLinksForum =
CVarDef.Create("infolinks.forum", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Link to GitHub page to show in the launcher.
/// </summary>
public static readonly CVarDef<string> InfoLinksGithub =
CVarDef.Create("infolinks.github", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Link to website to show in the launcher.
/// </summary>
public static readonly CVarDef<string> InfoLinksWebsite =
CVarDef.Create("infolinks.website", "", CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Link to wiki to show in the launcher.
/// </summary>
public static readonly CVarDef<string> InfoLinksWiki =
CVarDef.Create("infolinks.wiki", "", CVar.SERVER | CVar.REPLICATED);
}
}
2 changes: 1 addition & 1 deletion RobustToolbox
Submodule RobustToolbox updated 122 files

0 comments on commit ba0aa92

Please sign in to comment.