- ConfigService.cs alpha testing.
This commit is contained in:
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using Barotrauma.LuaCs.Services;
|
||||
using Barotrauma.Networking;
|
||||
using OneOf;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public class ConfigEntry<T> : IConfigEntry<T> where T : IEquatable<T>
|
||||
{
|
||||
|
||||
private readonly Action<ConfigEntry<T>, INetReadMessage> _readMessageHandler;
|
||||
private readonly Action<ConfigEntry<T>, INetWriteMessage> _writeMessageHandler;
|
||||
|
||||
public ConfigEntry(IConfigInfo configInfo, Action<ConfigEntry<T>, INetReadMessage> readMessageHandler,
|
||||
Action<ConfigEntry<T>, INetWriteMessage> writeMessageHandler)
|
||||
{
|
||||
_readMessageHandler = readMessageHandler;
|
||||
_writeMessageHandler = writeMessageHandler;
|
||||
}
|
||||
|
||||
public string InternalName { get; init; }
|
||||
public ContentPackage OwnerPackage { get; init; }
|
||||
|
||||
public bool Equals(IConfigBase other)
|
||||
{
|
||||
if (ReferenceEquals(this, other))
|
||||
return true;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Type GetValueType()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetValue(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private event Action<IConfigEntry<T>> _onValueChanged;
|
||||
public event Action<IConfigEntry<T>> OnValueChanged
|
||||
{
|
||||
add => _onValueChanged += value;
|
||||
remove => _onValueChanged -= value;
|
||||
}
|
||||
|
||||
event Action<IConfigBase> IConfigBase.OnValueChanged
|
||||
{
|
||||
add => _onValueChanged += value;
|
||||
remove => _onValueChanged -= value;
|
||||
}
|
||||
|
||||
public OneOf<string, XElement> GetSerializableValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Guid InstanceId => throw new NotImplementedException();
|
||||
|
||||
public NetSync SyncType => throw new NotImplementedException();
|
||||
|
||||
public ClientPermissions WritePermissions => throw new NotImplementedException();
|
||||
|
||||
public void ReadNetMessage(INetReadMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void WriteNetMessage(INetWriteMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public T Value => throw new NotImplementedException();
|
||||
|
||||
public bool TrySetValue(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using Barotrauma.LuaCs.Services;
|
||||
using Barotrauma.Networking;
|
||||
using OneOf;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public class ConfigList<T> : IConfigList<T> where T : IEquatable<T>
|
||||
{
|
||||
private readonly Action<ConfigList<T>, INetReadMessage> _readMessageHandler;
|
||||
private readonly Action<ConfigList<T>, INetWriteMessage> _writeMessageHandler;
|
||||
|
||||
public ConfigList(IConfigInfo configInfo, Action<ConfigList<T>, INetReadMessage> readMessageHandler,
|
||||
Action<ConfigList<T>, INetWriteMessage> writeMessageHandler)
|
||||
{
|
||||
_readMessageHandler = readMessageHandler;
|
||||
_writeMessageHandler = writeMessageHandler;
|
||||
}
|
||||
|
||||
public string InternalName => throw new NotImplementedException();
|
||||
|
||||
public ContentPackage OwnerPackage => throw new NotImplementedException();
|
||||
|
||||
public bool Equals(IConfigBase other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Type GetValueType()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetValue(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private event Action<IConfigList<T>> _onValueChanged;
|
||||
|
||||
public event Action<IConfigList<T>> OnValueChanged
|
||||
{
|
||||
add => _onValueChanged += value;
|
||||
remove => _onValueChanged -= value;
|
||||
}
|
||||
|
||||
event Action<IConfigEntry<T>> IConfigEntry<T>.OnValueChanged
|
||||
{
|
||||
add => _onValueChanged += value;
|
||||
remove => _onValueChanged -= value;
|
||||
}
|
||||
|
||||
event Action<IConfigBase> IConfigBase.OnValueChanged
|
||||
{
|
||||
add => _onValueChanged += value;
|
||||
remove => _onValueChanged -= value;
|
||||
}
|
||||
|
||||
public T Value => throw new NotImplementedException();
|
||||
|
||||
public bool TrySetValue(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public OneOf<string, XElement> GetSerializableValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Guid InstanceId => throw new NotImplementedException();
|
||||
|
||||
public NetSync SyncType => throw new NotImplementedException();
|
||||
|
||||
public ClientPermissions WritePermissions => throw new NotImplementedException();
|
||||
|
||||
public void ReadNetMessage(INetReadMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void WriteNetMessage(INetWriteMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IReadOnlyList<T> Options => throw new NotImplementedException();
|
||||
}
|
||||
+4
-3
@@ -6,12 +6,13 @@ using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public partial interface IConfigBase : IDataInfo, IEquatable<IConfigBase>, IDisposable
|
||||
public partial interface ISettingBase : IDataInfo, IEquatable<ISettingBase>, IDisposable
|
||||
{
|
||||
Type GetValueType();
|
||||
string GetValue();
|
||||
string GetStringValue();
|
||||
bool TrySetValue(OneOf.OneOf<string, XElement> value);
|
||||
bool IsAssignable(OneOf.OneOf<string, XElement> value);
|
||||
event Action<IConfigBase> OnValueChanged;
|
||||
event Func<OneOf.OneOf<string, XElement>, bool> IsNewValueValid;
|
||||
event Action<ISettingBase> OnValueChanged;
|
||||
OneOf.OneOf<string, XElement> GetSerializableValue();
|
||||
}
|
||||
+2
-2
@@ -3,10 +3,10 @@ using Barotrauma.LuaCs.Services;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public interface IConfigEntry<T> : IConfigBase, INetworkSyncEntity where T : IEquatable<T>
|
||||
public interface ISettingEntry<T> : ISettingBase, INetworkSyncEntity where T : IEquatable<T>
|
||||
{
|
||||
T Value { get; }
|
||||
bool TrySetValue(T value);
|
||||
bool IsAssignable(T value);
|
||||
new event Action<IConfigEntry<T>> OnValueChanged;
|
||||
new event Action<ISettingEntry<T>> OnValueChanged;
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ using Barotrauma.LuaCs.Services;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public interface IConfigEnum : IConfigBase, INetworkSyncEntity
|
||||
public interface ISettingEnum : ISettingBase, INetworkSyncEntity
|
||||
{
|
||||
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ using Barotrauma.LuaCs.Services;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public interface IConfigList<T> : IConfigEntry<T>, INetworkSyncEntity where T : IEquatable<T>
|
||||
public interface ISettingList<T> : ISettingEntry<T>, INetworkSyncEntity where T : IEquatable<T>
|
||||
{
|
||||
IReadOnlyList<T> Options { get; }
|
||||
new event Action<IConfigList<T>> OnValueChanged;
|
||||
new event Action<ISettingList<T>> OnValueChanged;
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public interface IConfigRangeEntry<T> : IConfigEntry<T> where T : IConvertible, IEquatable<T>
|
||||
public interface ISettingRangeEntry<T> : ISettingEntry<T> where T : IConvertible, IEquatable<T>
|
||||
{
|
||||
T MinValue { get; }
|
||||
T MaxValue { get; }
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using Barotrauma.LuaCs.Services;
|
||||
using Barotrauma.Networking;
|
||||
using OneOf;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public class SettingEntry<T> : ISettingEntry<T> where T : IEquatable<T>
|
||||
{
|
||||
public string InternalName { get; }
|
||||
public ContentPackage OwnerPackage { get; }
|
||||
public bool Equals(ISettingBase other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Type GetValueType()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetStringValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetValue(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public event Func<OneOf<string, XElement>, bool> IsNewValueValid;
|
||||
public T Value { get; }
|
||||
public bool TrySetValue(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
event Action<ISettingEntry<T>> ISettingEntry<T>.OnValueChanged
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
event Action<ISettingBase> ISettingBase.OnValueChanged
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public OneOf<string, XElement> GetSerializableValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Guid InstanceId { get; }
|
||||
public NetSync SyncType { get; }
|
||||
public ClientPermissions WritePermissions { get; }
|
||||
public void ReadNetMessage(INetReadMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void WriteNetMessage(INetWriteMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.LuaCs.Data;
|
||||
using Barotrauma.LuaCs.Services;
|
||||
using Barotrauma.Networking;
|
||||
using OneOf;
|
||||
|
||||
namespace Barotrauma.LuaCs.Configuration;
|
||||
|
||||
public class SettingList<T> : ISettingList<T> where T : IEquatable<T>
|
||||
{
|
||||
public string InternalName { get; }
|
||||
public ContentPackage OwnerPackage { get; }
|
||||
public bool Equals(ISettingBase other)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Type GetValueType()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public string GetStringValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetValue(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(OneOf<string, XElement> value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public event Func<OneOf<string, XElement>, bool> IsNewValueValid;
|
||||
public T Value { get; }
|
||||
public bool TrySetValue(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsAssignable(T value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
event Action<ISettingList<T>> ISettingList<T>.OnValueChanged
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IReadOnlyList<T> Options { get; }
|
||||
|
||||
event Action<ISettingEntry<T>> ISettingEntry<T>.OnValueChanged
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
event Action<ISettingBase> ISettingBase.OnValueChanged
|
||||
{
|
||||
add => throw new NotImplementedException();
|
||||
remove => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public OneOf<string, XElement> GetSerializableValue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Guid InstanceId { get; }
|
||||
public NetSync SyncType { get; }
|
||||
public ClientPermissions WritePermissions { get; }
|
||||
public void ReadNetMessage(INetReadMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void WriteNetMessage(INetWriteMessage message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user