Merge branch '20-11-27-merge'
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#nullable enable
|
||||
using System.Drawing;
|
||||
using Content.Client.GameObjects.Components.Mobs;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
@@ -13,6 +12,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Actor
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace Content.Client.GameObjects.Components.Instruments
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(this, x => Handheld, "handheld", false);
|
||||
serializer.DataField(this, x => x.Handheld, "handheld", false);
|
||||
serializer.DataField(ref _instrumentProgram, "program", (byte) 1);
|
||||
serializer.DataField(ref _instrumentBank, "bank", (byte) 0);
|
||||
serializer.DataField(ref _allowPercussion, "allowPercussion", false);
|
||||
@@ -349,12 +349,11 @@ namespace Content.Client.GameObjects.Components.Instruments
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MidiRenderer.OpenMidi(string)"/>
|
||||
public bool OpenMidi(string filename)
|
||||
public bool OpenMidi(ReadOnlySpan<byte> data)
|
||||
{
|
||||
SetupRenderer();
|
||||
|
||||
if (_renderer == null || !_renderer.OpenMidi(filename))
|
||||
if (_renderer == null || !_renderer.OpenMidi(data))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -141,23 +141,11 @@ namespace Content.Client.GameObjects.Components.Mobs
|
||||
|
||||
private void UpdateOverlayConfiguration(OverlayContainer container, Overlay overlay)
|
||||
{
|
||||
var configurableTypes = overlay.GetType()
|
||||
.GetInterfaces()
|
||||
.Where(type =>
|
||||
type.IsGenericType
|
||||
&& type.GetGenericTypeDefinition() == typeof(IConfigurable<>)
|
||||
&& container.Parameters.Exists(p => p.GetType() == type.GenericTypeArguments.First()))
|
||||
.ToList();
|
||||
|
||||
if (configurableTypes.Count > 0)
|
||||
if (overlay is IConfigurableOverlay configurable)
|
||||
{
|
||||
foreach (var type in configurableTypes)
|
||||
foreach (var param in container.Parameters)
|
||||
{
|
||||
var method = type.GetMethod(nameof(IConfigurable<object>.Configure));
|
||||
var parameter = container.Parameters
|
||||
.First(p => p.GetType() == type.GenericTypeArguments.First());
|
||||
|
||||
method!.Invoke(overlay, new []{ parameter });
|
||||
configurable.Configure(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +157,7 @@ namespace Content.Client.GameObjects.Components.Mobs
|
||||
|
||||
if (overlayType != null)
|
||||
{
|
||||
overlay = Activator.CreateInstance(overlayType) as Overlay;
|
||||
overlay = IoCManager.Resolve<IDynamicTypeFactory>().CreateInstance<Overlay>(overlayType);
|
||||
UpdateOverlayConfiguration(container, overlay);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace Content.Client.Graphics.Overlays
|
||||
{
|
||||
public class FlashOverlay : Overlay, IConfigurable<TimedOverlayParameter>
|
||||
public class FlashOverlay : Overlay, IConfigurableOverlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IClyde _displayManager = default!;
|
||||
@@ -61,9 +61,12 @@ namespace Content.Client.Graphics.Overlays
|
||||
_screenshotTexture = null;
|
||||
}
|
||||
|
||||
public void Configure(TimedOverlayParameter parameters)
|
||||
public void Configure(OverlayParameter parameters)
|
||||
{
|
||||
_lastsFor = parameters.Length;
|
||||
if (parameters is TimedOverlayParameter timedParams)
|
||||
{
|
||||
_lastsFor = timedParams.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.GameObjects.Components.Instruments;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Content.Client.Utility;
|
||||
@@ -174,25 +177,31 @@ namespace Content.Client.Instruments
|
||||
private async void MidiFileButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
var filters = new FileDialogFilters(new FileDialogFilters.Group("mid", "midi"));
|
||||
var filename = await _fileDialogManager.OpenFile(filters);
|
||||
var file = await _fileDialogManager.OpenFile(filters);
|
||||
|
||||
// The following checks are only in place to prevent players from playing MIDI songs locally.
|
||||
// There are equivalents for these checks on the server.
|
||||
|
||||
if (string.IsNullOrEmpty(filename)) return;
|
||||
if (file == null) return;
|
||||
|
||||
if (!_midiManager.IsMidiFile(filename))
|
||||
/*if (!_midiManager.IsMidiFile(filename))
|
||||
{
|
||||
Logger.Warning($"Not a midi file! Chosen file: {filename}");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!PlayCheck())
|
||||
return;
|
||||
|
||||
MidiStopButtonOnPressed(null);
|
||||
await Timer.Delay(100);
|
||||
if (!_owner.Instrument.OpenMidi(filename)) return;
|
||||
var memStream = new MemoryStream((int) file.Length);
|
||||
// 100ms delay is due to a race condition or something idk.
|
||||
// While we're waiting, load it into memory.
|
||||
await Task.WhenAll(Timer.Delay(100), file.CopyToAsync(memStream));
|
||||
|
||||
if (!_owner.Instrument.OpenMidi(memStream.GetBuffer().AsSpan(0, (int) memStream.Length)))
|
||||
return;
|
||||
|
||||
MidiPlaybackSetButtonsDisabled(false);
|
||||
if (_midiInputButton.Pressed)
|
||||
_midiInputButton.Pressed = false;
|
||||
@@ -222,14 +231,15 @@ namespace Content.Client.Instruments
|
||||
var localPlayer = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
|
||||
|
||||
// If we don't have a player or controlled entity, we return.
|
||||
if(localPlayer?.ControlledEntity == null) return false;
|
||||
if (localPlayer?.ControlledEntity == null) return false;
|
||||
|
||||
// If the instrument is handheld and we're not holding it, we return.
|
||||
if((instrument.Handheld && (conMan == null
|
||||
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
||||
if ((instrument.Handheld && (conMan == null
|
||||
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
||||
|
||||
// We check that we're in range unobstructed just in case.
|
||||
return localPlayer.InRangeUnobstructed(instrumentEnt, predicate:(e) => e == instrumentEnt || e == localPlayer.ControlledEntity);
|
||||
return localPlayer.InRangeUnobstructed(instrumentEnt,
|
||||
predicate: (e) => e == instrumentEnt || e == localPlayer.ControlledEntity);
|
||||
}
|
||||
|
||||
private void MidiStopButtonOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
|
||||
@@ -44,18 +44,17 @@ namespace Content.Client.Parallax
|
||||
|
||||
private void _loadConfig(TomlTable config)
|
||||
{
|
||||
foreach (var layerArray in config.Get<TomlTableArray>("layers").Items)
|
||||
foreach (var layerArray in ((TomlTableArray)config.Get("layers")).Items)
|
||||
{
|
||||
var layer = layerArray.Get<TomlTable>();
|
||||
switch (layer.Get<string>("type"))
|
||||
switch (((TomlValue<string>) layerArray.Get("type")).Value)
|
||||
{
|
||||
case "noise":
|
||||
var layerNoise = new LayerNoise(layer);
|
||||
var layerNoise = new LayerNoise(layerArray);
|
||||
Layers.Add(layerNoise);
|
||||
break;
|
||||
|
||||
case "points":
|
||||
var layerPoint = new LayerPoints(layer);
|
||||
var layerPoint = new LayerPoints(layerArray);
|
||||
Layers.Add(layerPoint);
|
||||
break;
|
||||
|
||||
@@ -89,62 +88,62 @@ namespace Content.Client.Parallax
|
||||
{
|
||||
if (table.TryGetValue("innercolor", out var tomlObject))
|
||||
{
|
||||
InnerColor = Color.FromHex(tomlObject.Get<string>());
|
||||
InnerColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("outercolor", out tomlObject))
|
||||
{
|
||||
OuterColor = Color.FromHex(tomlObject.Get<string>());
|
||||
OuterColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("seed", out tomlObject))
|
||||
{
|
||||
Seed = (uint) tomlObject.Get<int>();
|
||||
Seed = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("persistence", out tomlObject))
|
||||
{
|
||||
Persistence = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Persistence = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("lacunarity", out tomlObject))
|
||||
{
|
||||
Lacunarity = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Lacunarity = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("frequency", out tomlObject))
|
||||
{
|
||||
Frequency = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Frequency = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("octaves", out tomlObject))
|
||||
{
|
||||
Octaves = (uint) tomlObject.Get<int>();
|
||||
Octaves = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("threshold", out tomlObject))
|
||||
{
|
||||
Threshold = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Threshold = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("sourcefactor", out tomlObject))
|
||||
{
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("destfactor", out tomlObject))
|
||||
{
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("power", out tomlObject))
|
||||
{
|
||||
Power = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
Power = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("noise_type", out tomlObject))
|
||||
{
|
||||
switch (tomlObject.Get<string>())
|
||||
switch (((TomlValue<string>) tomlObject).Value)
|
||||
{
|
||||
case "fbm":
|
||||
NoiseType = NoiseGenerator.NoiseType.Fbm;
|
||||
@@ -226,78 +225,78 @@ namespace Content.Client.Parallax
|
||||
{
|
||||
if (table.TryGetValue("seed", out var tomlObject))
|
||||
{
|
||||
Seed = tomlObject.Get<int>();
|
||||
Seed = ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("count", out tomlObject))
|
||||
{
|
||||
PointCount = tomlObject.Get<int>();
|
||||
PointCount = ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("sourcefactor", out tomlObject))
|
||||
{
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
SrcFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("destfactor", out tomlObject))
|
||||
{
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), tomlObject.Get<string>());
|
||||
DstFactor = (Color.BlendFactor) Enum.Parse(typeof(Color.BlendFactor), ((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("farcolor", out tomlObject))
|
||||
{
|
||||
FarColor = Color.FromHex(tomlObject.Get<string>());
|
||||
FarColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("closecolor", out tomlObject))
|
||||
{
|
||||
CloseColor = Color.FromHex(tomlObject.Get<string>());
|
||||
CloseColor = Color.FromHex(((TomlValue<string>) tomlObject).Value);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("pointsize", out tomlObject))
|
||||
{
|
||||
PointSize = tomlObject.Get<int>();
|
||||
PointSize = ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
// Noise mask stuff.
|
||||
if (table.TryGetValue("mask", out tomlObject))
|
||||
{
|
||||
Masked = tomlObject.Get<bool>();
|
||||
Masked = ((TomlValue<bool>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskseed", out tomlObject))
|
||||
{
|
||||
MaskSeed = (uint) tomlObject.Get<int>();
|
||||
MaskSeed = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskpersistence", out tomlObject))
|
||||
{
|
||||
MaskPersistence = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskPersistence = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("masklacunarity", out tomlObject))
|
||||
{
|
||||
MaskLacunarity = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskLacunarity = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskfrequency", out tomlObject))
|
||||
{
|
||||
MaskFrequency = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskFrequency = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskoctaves", out tomlObject))
|
||||
{
|
||||
MaskOctaves = (uint) tomlObject.Get<int>();
|
||||
MaskOctaves = (uint) ((TomlValue<int>) tomlObject).Value;
|
||||
}
|
||||
|
||||
if (table.TryGetValue("maskthreshold", out tomlObject))
|
||||
{
|
||||
MaskThreshold = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskThreshold = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if (table.TryGetValue("masknoise_type", out tomlObject))
|
||||
{
|
||||
switch (tomlObject.Get<string>())
|
||||
switch (((TomlValue<string>) tomlObject).Value)
|
||||
{
|
||||
case "fbm":
|
||||
MaskNoiseType = NoiseGenerator.NoiseType.Fbm;
|
||||
@@ -312,7 +311,7 @@ namespace Content.Client.Parallax
|
||||
|
||||
if (table.TryGetValue("maskpower", out tomlObject))
|
||||
{
|
||||
MaskPower = float.Parse(tomlObject.Get<string>(), CultureInfo.InvariantCulture);
|
||||
MaskPower = float.Parse(((TomlValue<string>) tomlObject).Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Content.Client.UserInterface.Stylesheets;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Client.Credits;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -13,6 +12,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace Content.Client.UserInterface
|
||||
var margin = new MarginContainer {MarginLeftOverride = 2, MarginTopOverride = 2};
|
||||
var vBox = new VBoxContainer();
|
||||
margin.AddChild(vBox);
|
||||
var patrons = ReadJson<PatronEntry[]>("/Credits/Patrons.json");
|
||||
var patrons = LoadPatrons();
|
||||
|
||||
Button patronButton;
|
||||
vBox.AddChild(patronButton = new Button
|
||||
@@ -117,6 +117,16 @@ namespace Content.Client.UserInterface
|
||||
patronsList.AddChild(margin);
|
||||
}
|
||||
|
||||
private IEnumerable<PatronEntry> LoadPatrons()
|
||||
{
|
||||
var yamlStream = _resourceManager.ContentFileReadYaml(new ResourcePath("/Credits/Patrons.json"));
|
||||
var sequence = (YamlSequenceNode) yamlStream.Documents[0].RootNode;
|
||||
|
||||
return sequence
|
||||
.Cast<YamlMappingNode>()
|
||||
.Select(m => new PatronEntry(m["Name"].AsString(), m["Tier"].AsString()));
|
||||
}
|
||||
|
||||
private void PopulateCredits(Control contributorsList)
|
||||
{
|
||||
Button contributeButton;
|
||||
@@ -141,6 +151,7 @@ namespace Content.Client.UserInterface
|
||||
});
|
||||
|
||||
var first = true;
|
||||
|
||||
void AddSection(string title, string path, bool markup = false)
|
||||
{
|
||||
if (!first)
|
||||
@@ -190,29 +201,16 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private T ReadJson<T>(string path)
|
||||
{
|
||||
var serializer = new JsonSerializer();
|
||||
|
||||
using var stream = _resourceManager.ContentFileRead(path);
|
||||
using var streamReader = new StreamReader(stream);
|
||||
using var jsonTextReader = new JsonTextReader(streamReader);
|
||||
|
||||
return serializer.Deserialize<T>(jsonTextReader)!;
|
||||
}
|
||||
|
||||
[JsonObject(ItemRequired = Required.Always)]
|
||||
private sealed class PatronEntry
|
||||
{
|
||||
public string Name { get; set; } = default!;
|
||||
public string Tier { get; set; } = default!;
|
||||
}
|
||||
public string Name { get; }
|
||||
public string Tier { get; }
|
||||
|
||||
[JsonObject(ItemRequired = Required.Always)]
|
||||
private sealed class OpenSourceLicense
|
||||
{
|
||||
public string Name { get; set; } = default!;
|
||||
public string License { get; set; } = default!;
|
||||
public PatronEntry(string name, string tier)
|
||||
{
|
||||
Name = name;
|
||||
Tier = tier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.UnitTesting;
|
||||
using EntryPoint = Content.Client.EntryPoint;
|
||||
|
||||
namespace Content.IntegrationTests
|
||||
{
|
||||
@@ -23,10 +22,14 @@ namespace Content.IntegrationTests
|
||||
protected sealed override ClientIntegrationInstance StartClient(ClientIntegrationOptions options = null)
|
||||
{
|
||||
options ??= new ClientIntegrationOptions();
|
||||
|
||||
// ReSharper disable once RedundantNameQualifier
|
||||
options.ClientContentAssembly = typeof(EntryPoint).Assembly;
|
||||
options.SharedContentAssembly = typeof(Shared.EntryPoint).Assembly;
|
||||
options.ContentAssemblies = new[]
|
||||
{
|
||||
typeof(Shared.EntryPoint).Assembly,
|
||||
typeof(Client.EntryPoint).Assembly,
|
||||
typeof(ContentIntegrationTest).Assembly
|
||||
};
|
||||
|
||||
options.BeforeStart += () =>
|
||||
{
|
||||
IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ClientModuleTestingCallbacks
|
||||
@@ -53,8 +56,12 @@ namespace Content.IntegrationTests
|
||||
protected override ServerIntegrationInstance StartServer(ServerIntegrationOptions options = null)
|
||||
{
|
||||
options ??= new ServerIntegrationOptions();
|
||||
options.ServerContentAssembly = typeof(Server.EntryPoint).Assembly;
|
||||
options.SharedContentAssembly = typeof(Shared.EntryPoint).Assembly;
|
||||
options.ContentAssemblies = new[]
|
||||
{
|
||||
typeof(Shared.EntryPoint).Assembly,
|
||||
typeof(Server.EntryPoint).Assembly,
|
||||
typeof(ContentIntegrationTest).Assembly
|
||||
};
|
||||
options.BeforeStart += () =>
|
||||
{
|
||||
IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ServerModuleTestingCallbacks
|
||||
@@ -89,7 +96,9 @@ namespace Content.IntegrationTests
|
||||
return StartServer(options);
|
||||
}
|
||||
|
||||
protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)> StartConnectedServerClientPair(ClientIntegrationOptions clientOptions = null, ServerIntegrationOptions serverOptions = null)
|
||||
protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)>
|
||||
StartConnectedServerClientPair(ClientIntegrationOptions clientOptions = null,
|
||||
ServerIntegrationOptions serverOptions = null)
|
||||
{
|
||||
var client = StartClient(clientOptions);
|
||||
var server = StartServer(serverOptions);
|
||||
@@ -100,7 +109,9 @@ namespace Content.IntegrationTests
|
||||
}
|
||||
|
||||
|
||||
protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)> StartConnectedServerDummyTickerClientPair(ClientIntegrationOptions clientOptions = null, ServerIntegrationOptions serverOptions = null)
|
||||
protected async Task<(ClientIntegrationInstance client, ServerIntegrationInstance server)>
|
||||
StartConnectedServerDummyTickerClientPair(ClientIntegrationOptions clientOptions = null,
|
||||
ServerIntegrationOptions serverOptions = null)
|
||||
{
|
||||
var client = StartClient(clientOptions);
|
||||
var server = StartServerDummyTicker(serverOptions);
|
||||
@@ -136,7 +147,8 @@ namespace Content.IntegrationTests
|
||||
return grid;
|
||||
}
|
||||
|
||||
protected async Task WaitUntil(IntegrationInstance instance, Func<bool> func, int maxTicks = 600, int tickStep = 1)
|
||||
protected async Task WaitUntil(IntegrationInstance instance, Func<bool> func, int maxTicks = 600,
|
||||
int tickStep = 1)
|
||||
{
|
||||
var ticksAwaited = 0;
|
||||
bool passed;
|
||||
@@ -160,7 +172,8 @@ namespace Content.IntegrationTests
|
||||
Assert.That(passed);
|
||||
}
|
||||
|
||||
private static async Task StartConnectedPairShared(ClientIntegrationInstance client, ServerIntegrationInstance server)
|
||||
private static async Task StartConnectedPairShared(ClientIntegrationInstance client,
|
||||
ServerIntegrationInstance server)
|
||||
{
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
@@ -174,7 +187,8 @@ namespace Content.IntegrationTests
|
||||
/// <summary>
|
||||
/// Runs <paramref name="ticks"/> ticks on both server and client while keeping their main loop in sync.
|
||||
/// </summary>
|
||||
protected static async Task RunTicksSync(ClientIntegrationInstance client, ServerIntegrationInstance server, int ticks)
|
||||
protected static async Task RunTicksSync(ClientIntegrationInstance client, ServerIntegrationInstance server,
|
||||
int ticks)
|
||||
{
|
||||
for (var i = 0; i < ticks; i++)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Networking
|
||||
@@ -425,6 +426,7 @@ namespace Content.IntegrationTests.Tests.Networking
|
||||
}
|
||||
}
|
||||
|
||||
[Reflect(false)]
|
||||
private sealed class PredictionTestEntitySystem : EntitySystem
|
||||
{
|
||||
public bool Allow { get; set; } = true;
|
||||
|
||||
@@ -6,6 +6,7 @@ using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Reflection;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
@@ -13,6 +14,7 @@ namespace Content.IntegrationTests.Tests
|
||||
[TestOf(typeof(IResettingEntitySystem))]
|
||||
public class ResettingEntitySystemTests : ContentIntegrationTest
|
||||
{
|
||||
[Reflect(false)]
|
||||
private class TestResettingEntitySystem : EntitySystem, IResettingEntitySystem
|
||||
{
|
||||
public bool HasBeenReset { get; set; }
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
</PropertyGroup>
|
||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.Chat;
|
||||
using Content.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Server.Interfaces.ServerStatus;
|
||||
using Robust.Server.ServerStatus;
|
||||
@@ -74,9 +73,9 @@ namespace Content.Server
|
||||
}
|
||||
}
|
||||
|
||||
private bool _handleChatPost(HttpMethod method, HttpRequest request, HttpResponse response)
|
||||
private bool _handleChatPost(HttpMethod method, HttpListenerRequest request, HttpListenerResponse response)
|
||||
{
|
||||
if (method != HttpMethod.Post || request.Path != "/ooc")
|
||||
if (method != HttpMethod.Post || request.Url!.AbsolutePath != "/ooc")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,17 +67,17 @@ namespace Content.Shared.Atmos
|
||||
{
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(this, x => ID, "id", string.Empty);
|
||||
serializer.DataField(this, x => Name, "name", string.Empty);
|
||||
serializer.DataField(this, x => OverlayPath, "overlayPath", string.Empty);
|
||||
serializer.DataField(this, x => SpecificHeat, "specificHeat", 0f);
|
||||
serializer.DataField(this, x => HeatCapacityRatio, "heatCapacityRatio", 1.4f);
|
||||
serializer.DataField(this, x => MolarMass, "molarMass", 1f);
|
||||
serializer.DataField(this, x => GasMolesVisible, "gasMolesVisible", 0.25f);
|
||||
serializer.DataField(this, x => GasOverlayTexture, "gasOverlayTexture", string.Empty);
|
||||
serializer.DataField(this, x => GasOverlaySprite, "gasOverlaySprite", string.Empty);
|
||||
serializer.DataField(this, x => GasOverlayState, "gasOverlayState", string.Empty);
|
||||
serializer.DataField(this, x => Color, "color", string.Empty);
|
||||
serializer.DataField(this, x => x.ID, "id", string.Empty);
|
||||
serializer.DataField(this, x => x.Name, "name", string.Empty);
|
||||
serializer.DataField(this, x => x.OverlayPath, "overlayPath", string.Empty);
|
||||
serializer.DataField(this, x => x.SpecificHeat, "specificHeat", 0f);
|
||||
serializer.DataField(this, x => x.HeatCapacityRatio, "heatCapacityRatio", 1.4f);
|
||||
serializer.DataField(this, x => x.MolarMass, "molarMass", 1f);
|
||||
serializer.DataField(this, x => x.GasMolesVisible, "gasMolesVisible", 0.25f);
|
||||
serializer.DataField(this, x => x.GasOverlayTexture, "gasOverlayTexture", string.Empty);
|
||||
serializer.DataField(this, x => x.GasOverlaySprite, "gasOverlaySprite", string.Empty);
|
||||
serializer.DataField(this, x => x.GasOverlayState, "gasOverlayState", string.Empty);
|
||||
serializer.DataField(this, x => x.Color, "color", string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +158,7 @@ namespace Content.Shared.GameObjects.Components.Body.Mechanism
|
||||
return true;
|
||||
}
|
||||
|
||||
behavior = new T();
|
||||
IoCManager.InjectDependencies(behavior);
|
||||
behavior = IoCManager.Resolve<IDynamicTypeFactory>().CreateInstance<T>();
|
||||
_behaviors.Add(typeof(T), behavior);
|
||||
behavior.Initialize(this);
|
||||
behavior.Startup();
|
||||
|
||||
@@ -64,17 +64,17 @@ namespace Content.Shared.GameObjects.Components
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, x => TurnOnBehaviourID, "turnOnBehaviourID", string.Empty);
|
||||
serializer.DataField(this, x => FadeOutBehaviourID, "fadeOutBehaviourID", string.Empty);
|
||||
serializer.DataField(this, x => GlowDuration, "glowDuration", 60 * 15f);
|
||||
serializer.DataField(this, x => FadeOutDuration, "fadeOutDuration", 60 * 5f);
|
||||
serializer.DataField(this, x => SpentName, "spentName", string.Empty);
|
||||
serializer.DataField(this, x => SpentDesc, "spentDesc", string.Empty);
|
||||
serializer.DataField(this, x => IconStateLit, "iconStateOn", string.Empty);
|
||||
serializer.DataField(this, x => IconStateSpent, "iconStateSpent", string.Empty);
|
||||
serializer.DataField(this, x => LitSound, "litSound", string.Empty);
|
||||
serializer.DataField(this, x => LoopedSound, "loopedSound", string.Empty);
|
||||
serializer.DataField(this, x => DieSound, "dieSound", string.Empty);
|
||||
serializer.DataField(this, x => x.TurnOnBehaviourID, "turnOnBehaviourID", string.Empty);
|
||||
serializer.DataField(this, x => x.FadeOutBehaviourID, "fadeOutBehaviourID", string.Empty);
|
||||
serializer.DataField(this, x => x.GlowDuration, "glowDuration", 60 * 15f);
|
||||
serializer.DataField(this, x => x.FadeOutDuration, "fadeOutDuration", 60 * 5f);
|
||||
serializer.DataField(this, x => x.SpentName, "spentName", string.Empty);
|
||||
serializer.DataField(this, x => x.SpentDesc, "spentDesc", string.Empty);
|
||||
serializer.DataField(this, x => x.IconStateLit, "iconStateOn", string.Empty);
|
||||
serializer.DataField(this, x => x.IconStateSpent, "iconStateSpent", string.Empty);
|
||||
serializer.DataField(this, x => x.LitSound, "litSound", string.Empty);
|
||||
serializer.DataField(this, x => x.LoopedSound, "loopedSound", string.Empty);
|
||||
serializer.DataField(this, x => x.DieSound, "dieSound", string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Content.Shared.Interfaces
|
||||
{
|
||||
public interface IConfigurable<in T>
|
||||
{
|
||||
public void Configure(T parameters);
|
||||
}
|
||||
}
|
||||
9
Content.Shared/Interfaces/IConfigurableOverlay.cs
Normal file
9
Content.Shared/Interfaces/IConfigurableOverlay.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
|
||||
namespace Content.Shared.Interfaces
|
||||
{
|
||||
public interface IConfigurableOverlay
|
||||
{
|
||||
void Configure(OverlayParameter parameter);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Content.Client;
|
||||
using Content.Server;
|
||||
using Robust.UnitTesting;
|
||||
@@ -19,5 +21,26 @@ namespace Content.Tests
|
||||
ClientContentIoC.Register();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Assembly[] GetContentAssemblies()
|
||||
{
|
||||
var l = new List<Assembly>
|
||||
{
|
||||
typeof(Content.Shared.EntryPoint).Assembly
|
||||
};
|
||||
|
||||
if (Project == UnitTestProject.Server)
|
||||
{
|
||||
l.Add(typeof(Content.Server.EntryPoint).Assembly);
|
||||
}
|
||||
else if (Project == UnitTestProject.Client)
|
||||
{
|
||||
l.Add(typeof(Content.Client.EntryPoint).Assembly);
|
||||
}
|
||||
|
||||
l.Add(typeof(ContentUnitTest).Assembly);
|
||||
|
||||
return l.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace Content.Tests.Server.GameObjects.Components.Mobs
|
||||
// in a unit test
|
||||
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
prototypeManager.RegisterType(typeof(AlertPrototype));
|
||||
var factory = IoCManager.Resolve<IComponentFactory>();
|
||||
factory.Register<ServerAlertsComponent>();
|
||||
prototypeManager.LoadFromStream(new StringReader(PROTOTYPES));
|
||||
|
||||
@@ -12,7 +12,7 @@ using YamlDotNet.RepresentationModel;
|
||||
namespace Content.Tests.Shared.Alert
|
||||
{
|
||||
[TestFixture, TestOf(typeof(AlertManager))]
|
||||
public class AlertManagerTests : RobustUnitTest
|
||||
public class AlertManagerTests : ContentUnitTest
|
||||
{
|
||||
const string PROTOTYPES = @"
|
||||
- type: alert
|
||||
@@ -28,9 +28,7 @@ namespace Content.Tests.Shared.Alert
|
||||
public void TestAlertManager()
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
prototypeManager.RegisterType(typeof(AlertPrototype));
|
||||
prototypeManager.LoadFromStream(new StringReader(PROTOTYPES));
|
||||
IoCManager.RegisterInstance<AlertManager>(new AlertManager());
|
||||
var alertManager = IoCManager.Resolve<AlertManager>();
|
||||
alertManager.Initialize();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ using Robust.UnitTesting;
|
||||
namespace Content.Tests.Shared.Alert
|
||||
{
|
||||
[TestFixture, TestOf(typeof(AlertOrderPrototype))]
|
||||
public class AlertOrderPrototypeTests : RobustUnitTest
|
||||
public class AlertOrderPrototypeTests : ContentUnitTest
|
||||
{
|
||||
const string PROTOTYPES = @"
|
||||
- type: alertOrder
|
||||
@@ -64,8 +64,6 @@ namespace Content.Tests.Shared.Alert
|
||||
public void TestAlertOrderPrototype()
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
prototypeManager.RegisterType(typeof(AlertPrototype));
|
||||
prototypeManager.RegisterType(typeof(AlertOrderPrototype));
|
||||
prototypeManager.LoadFromStream(new StringReader(PROTOTYPES));
|
||||
|
||||
var alertOrder = prototypeManager.EnumeratePrototypes<AlertOrderPrototype>().FirstOrDefault();
|
||||
|
||||
@@ -11,7 +11,7 @@ using YamlDotNet.RepresentationModel;
|
||||
namespace Content.Tests.Shared.Alert
|
||||
{
|
||||
[TestFixture, TestOf(typeof(AlertPrototype))]
|
||||
public class AlertPrototypeTests : RobustUnitTest
|
||||
public class AlertPrototypeTests : ContentUnitTest
|
||||
{
|
||||
private const string PROTOTYPE = @"- type: alert
|
||||
alertType: HumanHealth
|
||||
|
||||
Submodule RobustToolbox updated: 124b447428...2b39c05472
@@ -133,6 +133,7 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pullable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Reparenting/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ruinable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=sandboxing/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=singulo/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
Reference in New Issue
Block a user