Merge branch '20-11-27-merge'

This commit is contained in:
Pieter-Jan Briers
2020-11-27 00:54:29 +01:00
24 changed files with 177 additions and 144 deletions

View File

@@ -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

View File

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

View File

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