1
This commit is contained in:
@@ -36,9 +36,9 @@ namespace BITKit
|
||||
}
|
||||
public static class Time
|
||||
{
|
||||
public static float ElapsedTime { get; internal set; }
|
||||
public static float DeltaTime { get; internal set; }
|
||||
public static double TimeAsDouble { get; internal set; }
|
||||
public static float ElapsedTime { get; set; }
|
||||
public static float DeltaTime { get; set; }
|
||||
public static double TimeAsDouble { get; set; }
|
||||
|
||||
}
|
||||
[System.Serializable]
|
||||
|
@@ -8,12 +8,20 @@
|
||||
{
|
||||
if (info.CanWrite is false) continue;
|
||||
var targetInfo = target.GetType().GetProperty(info.Name, ReflectionHelper.Flags);
|
||||
targetInfo?.SetValue(target, info.GetValue(source));
|
||||
var value = info.GetValue(source);
|
||||
if (value is not null)
|
||||
{
|
||||
targetInfo?.SetValue(target,value );
|
||||
}
|
||||
}
|
||||
foreach (var info in source.GetType().GetFields(ReflectionHelper.Flags))
|
||||
{
|
||||
var targetInfo = target.GetType().GetField(info.Name, ReflectionHelper.Flags);
|
||||
targetInfo?.SetValue(target, info.GetValue(source));
|
||||
var value = info.GetValue(source);
|
||||
if (value is not null)
|
||||
{
|
||||
targetInfo?.SetValue(target, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -94,7 +94,6 @@ namespace BITKit
|
||||
try
|
||||
{
|
||||
await currentElement.ExitAsync();
|
||||
currentElement.Exited();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -104,6 +103,7 @@ namespace BITKit
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
}
|
||||
currentElement.Exited();
|
||||
currentElement.IsEntered = false;
|
||||
OnExit?.Invoke(currentElement);
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ namespace BITKit.Net
|
||||
public event Action OnStopServer;
|
||||
private readonly KcpServer server;
|
||||
private readonly GenericEvent _events = new();
|
||||
private bool _isStarted;
|
||||
private readonly Timer _timer = new(100)
|
||||
{
|
||||
AutoReset = true
|
||||
@@ -85,6 +86,11 @@ namespace BITKit.Net
|
||||
_now = DateTime.UtcNow;
|
||||
try
|
||||
{
|
||||
if (_isStarted && IsRunningServer is false)
|
||||
{
|
||||
StartServer(_port);
|
||||
}
|
||||
|
||||
foreach (var id in Connections.Keys.ToArray())
|
||||
{
|
||||
server.Send(id,_heartBeat , KcpChannel.Unreliable);
|
||||
@@ -133,9 +139,10 @@ namespace BITKit.Net
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ushort _port;
|
||||
public void StartServer(ushort port = 27014)
|
||||
{
|
||||
_port = port;
|
||||
if (IsRunningServer is false)
|
||||
{
|
||||
if (TickRate > 0)
|
||||
@@ -146,6 +153,7 @@ namespace BITKit.Net
|
||||
OnStartServer?.Invoke();
|
||||
server.Start(port);
|
||||
_timer.Start();
|
||||
_isStarted = true;
|
||||
BIT4Log.Log<KCPNetServer>($"已启动KCP服务器:{port}");
|
||||
}
|
||||
else
|
||||
@@ -158,6 +166,7 @@ namespace BITKit.Net
|
||||
{
|
||||
if (IsRunningServer)
|
||||
{
|
||||
_isStarted = false;
|
||||
server.Stop();
|
||||
OnStopServer?.Invoke();
|
||||
_timer.Stop();
|
||||
|
Reference in New Issue
Block a user