Misc NetEntity fixes for VV (#4390)

This commit is contained in:
Leon Friedrich
2023-09-15 10:11:28 +10:00
committed by GitHub
parent 2abf33c9be
commit bc5107e297
6 changed files with 65 additions and 4 deletions
@@ -190,6 +190,11 @@ namespace Robust.Client.ViewVariables
return new VVPropEditorEntityUid();
}
if (type == typeof(NetEntity))
{
return new VVPropEditorNetEntity();
}
if (type == typeof(Color))
{
return new VVPropEditorColor();
@@ -4,7 +4,6 @@ using Robust.Client.UserInterface.Controls;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Robust.Client.ViewVariables.Editors
@@ -39,7 +38,8 @@ namespace Robust.Client.ViewVariables.Editors
vvButton.OnPressed += e =>
{
IoCManager.Resolve<IConsoleHost>().ExecuteCommand($"vv {uid}");
var id = IoCManager.Resolve<IEntityManager>().GetNetEntity(uid);
IoCManager.Resolve<IConsoleHost>().ExecuteCommand($"vv {id}");
};
hBox.AddChild(lineEdit);
@@ -0,0 +1,48 @@
using System.Numerics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Robust.Client.ViewVariables.Editors;
public sealed class VVPropEditorNetEntity : VVPropEditor
{
protected override Control MakeUI(object? value)
{
var hBox = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
MinSize = new Vector2(200, 0)
};
var nuid = (NetEntity)value!;
var lineEdit = new LineEdit
{
Text = nuid.ToString(),
Editable = !ReadOnly,
HorizontalExpand = true,
};
if (!ReadOnly)
{
lineEdit.OnTextEntered += e =>
ValueChanged(NetEntity.Parse(e.Text));
}
var vvButton = new Button()
{
Text = "View",
};
vvButton.OnPressed += e =>
{
IoCManager.Resolve<IConsoleHost>().ExecuteCommand($"vv {nuid}");
};
hBox.AddChild(lineEdit);
hBox.AddChild(vvButton);
return hBox;
}
}
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Robust.Server.ViewVariables.Traits;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Network.Messages;
using Robust.Shared.Prototypes;
@@ -92,6 +93,9 @@ namespace Robust.Server.ViewVariables
return null;
}
if (value is EntityUid uid)
return IoCManager.Resolve<IEntityManager>().GetNetEntity(uid);
var valType = value.GetType();
if (!valType.IsValueType)
{
+3 -1
View File
@@ -190,8 +190,10 @@ namespace Robust.Shared.GameObjects
// This might seem useless, but it allows you to retrieve remote entities that don't exist on the client.
[ViewVariables]
private EntityUid Uid => this;
private EntityUid _uid => this;
[ViewVariables]
private NetEntity _netId => IoCManager.Resolve<IEntityManager>().GetNetEntity(this);
#endregion
}
}
+3 -1
View File
@@ -214,7 +214,7 @@ public readonly struct NetEntity : IEquatable<NetEntity>, IComparable<NetEntity>
}
[ViewVariables]
private EntityUid Uid
private EntityUid _uid
{
get
{
@@ -222,5 +222,7 @@ public readonly struct NetEntity : IEquatable<NetEntity>, IComparable<NetEntity>
}
}
[ViewVariables] private NetEntity _netId => this;
#endregion
}