using System; using System.Collections; using System.Collections.Generic; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Serialization; namespace Robust.Shared.ViewVariables { /// /// Data blob that gets sent from server to client to display a VV window for a remote object. /// These blobs should be requested with a specific . /// [Serializable, NetSerializable] public abstract class ViewVariablesBlob { } /// /// Contains the fundamental metadata for an object, such as type, output, and the list of "traits". /// [Serializable, NetSerializable] public class ViewVariablesBlobMetadata : ViewVariablesBlob { /// /// A list of traits for this remote object. /// A trait is basically saying "this object can be viewed in a specific way". /// There's a trait for "this object has members that are directly accessible to VV (the usual), /// A trait for objects that are , etc... /// For flexibility, these traits can be any object that the server/client need to understand each other. /// At the moment though the only thing they're used with is . /// /// public List Traits { get; set; } /// /// The pretty type name of the remote object. /// public string ObjectTypePretty { get; set; } /// /// The assembly qualified type name of the remote object. /// public string ObjectType { get; set; } /// /// The output of the remote object. /// public string Stringified { get; set; } } /// /// Contains the VV-accessible members (fields or properties) of a remote object. /// Requested by . /// [Serializable, NetSerializable] public class ViewVariablesBlobMembers : ViewVariablesBlob { /// /// A list of VV-accessible the remote object has. /// public List Members { get; set; } = new List(); /// /// Token used to indicate "this is a reference, but I can't send the actual reference over". /// [Serializable, NetSerializable] public class ReferenceToken { /// /// The output of the referenced object. /// public string Stringified { get; set; } // ToString override so EditorDummy displays it correctly. public override string ToString() { return Stringified; } } /// /// Sent if the value is a server-side only value type. /// [Serializable, NetSerializable] public class ServerValueTypeToken { /// /// The output of the remote object. /// public string Stringified { get; set; } // ToString override so EditorDummy displays it correctly. public override string ToString() { return Stringified; } } /// /// Data for a specific property. /// [Serializable, NetSerializable] public class MemberData { /// /// Whether the property can be edited by this client. /// public bool Editable { get; set; } /// /// Assembly qualified type name of the property. /// public string Type { get; set; } /// /// Pretty type name of the property. /// public string TypePretty { get; set; } /// /// Name of the property. /// public string Name { get; set; } /// /// Index of the property to be referenced when modifying it. /// public int PropertyIndex { get; set; } /// /// Value of the property. /// If it's a value type that can be serialized it's literally sent over, /// otherwise it's a meta token like or . /// public object Value { get; set; } } } /// /// Contains the type names of the components of a remote . /// Requested by . /// [Serializable, NetSerializable] public class ViewVariablesBlobEntityComponents : ViewVariablesBlob { public List ComponentTypes { get; set; } = new List(); // This might as well be a ValueTuple but I couldn't get that to work. [Serializable, NetSerializable] public class Entry : IComparable { public int CompareTo(Entry other) { if (ReferenceEquals(this, other)) return 0; if (ReferenceEquals(null, other)) return 1; return string.Compare(Stringified, other.Stringified, StringComparison.Ordinal); } public string FullName { get; set; } public string Stringified { get; set; } } } /// /// Contains a range of a remote 's results. /// Requested by /// [Serializable, NetSerializable] public class ViewVariablesBlobEnumerable : ViewVariablesBlob { /// /// The list of objects inside the range specified by the /// used to request this blob. /// public List Objects { get; set; } } /// /// Base class for a "request" that can be sent to get information about the remote object of a session. /// You should pass these requests to IViewVariablesManagerInternal.RequestData, which will return the corresponding blob over the wire. /// [Serializable, NetSerializable] public abstract class ViewVariablesRequest { } /// /// Requests the server to send us a . /// [Serializable, NetSerializable] public class ViewVariablesRequestMetadata : ViewVariablesRequest { } /// /// Requests the server to send us a . /// [Serializable, NetSerializable] public class ViewVariablesRequestMembers : ViewVariablesRequest { } /// /// Requests the server to send us a . /// [Serializable, NetSerializable] public class ViewVariablesRequestEntityComponents : ViewVariablesRequest { } /// /// Requests the server to send us a containing data in the specified range. /// [Serializable, NetSerializable] public class ViewVariablesRequestEnumerable : ViewVariablesRequest { public ViewVariablesRequestEnumerable(int fromIndex, int toIndex, bool refresh) { FromIndex = fromIndex; ToIndex = toIndex; Refresh = refresh; } /// /// The first index to be included. /// public int FromIndex { get; } /// /// The last index to be included. /// public int ToIndex { get; } /// /// If true, wipe the enumerator used and clear the cached values. /// This is used for the refresh button in the VV window. /// We need to wipe the server side cache or else it wouldn't be a refresh. /// public bool Refresh { get; } } }