mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fix some compiler warnings and remove dead code.
This commit is contained in:
@@ -169,12 +169,6 @@ namespace Robust.Client.GameObjects
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public uint RenderOrder { get => _renderOrder; set => _renderOrder = value; }
|
||||
|
||||
int NextMirrorKey;
|
||||
|
||||
// Do not directly store mirror instances, so that they can be picked up by the GC is not disposed correctly.
|
||||
// Don't need em anyways.
|
||||
readonly Dictionary<int, MirrorData> Mirrors = new Dictionary<int, MirrorData>();
|
||||
|
||||
private static Shader _defaultShader;
|
||||
|
||||
[ViewVariables]
|
||||
@@ -1032,24 +1026,6 @@ namespace Robust.Client.GameObjects
|
||||
return LayerGetActualRSI(layer);
|
||||
}
|
||||
|
||||
public ISpriteProxy CreateProxy()
|
||||
{
|
||||
var key = NextMirrorKey++;
|
||||
var mirror = new SpriteMirror(key, this);
|
||||
Mirrors.Add(key, new MirrorData());
|
||||
return mirror;
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
base.OnRemove();
|
||||
|
||||
foreach (var key in Mirrors.Keys.ToList())
|
||||
{
|
||||
DisposeMirror(key);
|
||||
}
|
||||
}
|
||||
|
||||
internal void OpenGLRender(DrawingHandleWorld drawingHandle, bool useWorldTransform=true)
|
||||
{
|
||||
Matrix3 transform;
|
||||
@@ -1534,29 +1510,6 @@ namespace Robust.Client.GameObjects
|
||||
return OffsetRsiDir(GetDir(), layer.DirOffset);
|
||||
}
|
||||
|
||||
private void DisposeMirror(int key)
|
||||
{
|
||||
if (!Mirrors.TryGetValue(key, out var val))
|
||||
{
|
||||
// Maybe possible if the sprite gets disposed before the mirror handle?
|
||||
return;
|
||||
}
|
||||
|
||||
Mirrors.Remove(key);
|
||||
}
|
||||
|
||||
private bool IsMirrorDisposed(int key)
|
||||
{
|
||||
return Mirrors.ContainsKey(key);
|
||||
}
|
||||
|
||||
void MirrorSetVisible(int key, bool visible)
|
||||
{
|
||||
var mirror = Mirrors[key];
|
||||
mirror.Visible = visible;
|
||||
Mirrors[key] = mirror;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum to "offset" a cardinal direction.
|
||||
/// </summary>
|
||||
@@ -1611,83 +1564,5 @@ namespace Robust.Client.GameObjects
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sealed class SpriteMirror : ISpriteProxy
|
||||
{
|
||||
readonly int Key;
|
||||
readonly SpriteComponent Master;
|
||||
private Vector2 _offset;
|
||||
|
||||
public Vector2 Offset
|
||||
{
|
||||
get => _offset;
|
||||
set
|
||||
{
|
||||
CheckDisposed();
|
||||
_offset = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _visible = true;
|
||||
|
||||
public bool Visible
|
||||
{
|
||||
get => _visible;
|
||||
set
|
||||
{
|
||||
_visible = value;
|
||||
Master.MirrorSetVisible(Key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public SpriteMirror(int key, SpriteComponent master)
|
||||
{
|
||||
Master = master;
|
||||
Key = key;
|
||||
}
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
private void CheckDisposed()
|
||||
{
|
||||
if (Disposed)
|
||||
{
|
||||
throw new ObjectDisposedException(nameof(SpriteMirror));
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~SpriteMirror()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
Master.DisposeMirror(Key);
|
||||
|
||||
Disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private struct MirrorData
|
||||
{
|
||||
public bool Visible;
|
||||
|
||||
// Don't free the canvas item if it's the scene node item.
|
||||
// That causes problems.
|
||||
// Seriously.
|
||||
public bool DontFree;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,15 +188,5 @@ namespace Robust.Client.Interfaces.GameObjects.Components
|
||||
/// Get the RSI used by a layer.
|
||||
/// </summary>
|
||||
RSI LayerGetActualRSI(object layerKey);
|
||||
|
||||
ISpriteProxy CreateProxy();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A handle to allow a <see cref="ISpriteComponent"/> to draw in multiple locations, such as a UI slot.
|
||||
/// </summary>
|
||||
public interface ISpriteProxy : IDisposable
|
||||
{
|
||||
Vector2 Offset { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
<PackageReference Include="YamlDotNet" Version="5.0.1" />
|
||||
<PackageReference Include="OpenTK" Version="3.0.1" />
|
||||
<PackageReference Include="SharpFont" Version="4.0.1" />
|
||||
<!-- Including SharpFont.Dependencies to silence a warning -->
|
||||
<PackageReference Include="SharpFont.Dependencies" Version="2.5.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Robust.Client.Interfaces;
|
||||
using Robust.Client.Interfaces.Graphics;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -33,7 +32,6 @@ namespace Robust.Client.State.States
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager;
|
||||
[Dependency] private readonly IGameController _controllerProxy;
|
||||
[Dependency] private readonly IResourceCache _resourceCache;
|
||||
[Dependency] private readonly IDisplayManager _displayManager;
|
||||
#pragma warning restore 649
|
||||
|
||||
private MainMenuControl _mainMenuControl;
|
||||
|
||||
@@ -12,30 +12,9 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
public class SpriteView : Control
|
||||
{
|
||||
ISpriteProxy Mirror;
|
||||
ISpriteComponent _sprite;
|
||||
public ISpriteComponent Sprite { get; set; }
|
||||
|
||||
public ISpriteComponent Sprite
|
||||
{
|
||||
get => _sprite;
|
||||
set
|
||||
{
|
||||
_sprite = value;
|
||||
if (Mirror != null)
|
||||
{
|
||||
Mirror.Dispose();
|
||||
Mirror = null;
|
||||
}
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
Mirror = value.CreateProxy();
|
||||
UpdateMirrorPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SpriteView() : base()
|
||||
public SpriteView()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -50,44 +29,21 @@ namespace Robust.Client.UserInterface.Controls
|
||||
RectClipContent = true;
|
||||
}
|
||||
|
||||
protected override void Resized()
|
||||
{
|
||||
base.Resized();
|
||||
UpdateMirrorPosition();
|
||||
}
|
||||
|
||||
void UpdateMirrorPosition()
|
||||
{
|
||||
if (Mirror == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Mirror.Offset = Size / 2;
|
||||
}
|
||||
|
||||
protected override Vector2 CalculateMinimumSize()
|
||||
{
|
||||
// TODO: make this not hardcoded.
|
||||
// It'll break on larger things.
|
||||
return new Vector2(32, 32);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
Mirror?.Dispose();
|
||||
return (32, 32);
|
||||
}
|
||||
|
||||
protected internal override void Draw(DrawingHandleScreen handle)
|
||||
{
|
||||
if (_sprite == null)
|
||||
if (Sprite == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
handle.DrawEntity(_sprite.Owner, GlobalPixelPosition + PixelSize / 2);
|
||||
handle.DrawEntity(Sprite.Owner, GlobalPixelPosition + PixelSize / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// A version of component with built-in network syncing.
|
||||
/// </summary>
|
||||
public abstract class NetComponent : Component
|
||||
{
|
||||
//C# does not have friend classes :(
|
||||
/// <summary>
|
||||
/// Contains a primitive type that is synced over networking to connected clients.
|
||||
/// </summary>
|
||||
protected class NetVar<T>
|
||||
{
|
||||
private NetComponent _owner;
|
||||
private int _index;
|
||||
|
||||
/// <summary>
|
||||
/// Only use this for serialization. Setting this does not keep
|
||||
/// the value synced over the network. DO NOT USE THIS FOR NORMAL
|
||||
/// CODE.
|
||||
/// </summary>
|
||||
internal T Field;
|
||||
|
||||
/// <summary>
|
||||
/// The value that the NetVar holds. For normal operations use this property.
|
||||
/// </summary>
|
||||
public T Value
|
||||
{
|
||||
get => Field;
|
||||
set
|
||||
{
|
||||
// string has to be such a special little snowflake...
|
||||
if(value == null && Field == null)
|
||||
return;
|
||||
|
||||
if(value != null && value.Equals(Field))
|
||||
return;
|
||||
|
||||
Field = value;
|
||||
_owner.NetVarChanged(_index, Field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NetVarChanged(int index, object newValue)
|
||||
{
|
||||
//TODO: NetSync
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user