mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 18:35:34 +00:00
Merge branch 'dev' into steamworks
This commit is contained in:
commit
d55b029ce8
@ -22,7 +22,11 @@ namespace Mirror.Weaver
|
||||
|
||||
public static bool IsDerivedFrom(this TypeReference tr, Type baseClass)
|
||||
{
|
||||
if (tr == null)
|
||||
return false;
|
||||
TypeDefinition td = tr.Resolve();
|
||||
if (td == null)
|
||||
return false;
|
||||
if (!td.IsClass)
|
||||
return false;
|
||||
|
||||
|
@ -1,7 +1,20 @@
|
||||
namespace QSB.Utility.VariableSync
|
||||
using Mirror;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QSB.Utility.VariableSync
|
||||
{
|
||||
public abstract class BaseVariableSyncer : QSBNetworkBehaviour
|
||||
public abstract class BaseVariableSyncer<T> : QSBNetworkBehaviour
|
||||
{
|
||||
protected override float SendInterval => 0.1f;
|
||||
|
||||
private T _prevValue;
|
||||
[NonSerialized]
|
||||
public T Value;
|
||||
|
||||
protected override bool HasChanged() => !EqualityComparer<T>.Default.Equals(_prevValue, Value);
|
||||
protected override void UpdatePrevData() => _prevValue = Value;
|
||||
protected override void Serialize(NetworkWriter writer, bool initialState) => writer.Write(Value);
|
||||
protected override void Deserialize(NetworkReader reader, bool initialState) => Value = reader.Read<T>();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,6 @@
|
||||
using Mirror;
|
||||
using System;
|
||||
|
||||
namespace QSB.Utility.VariableSync
|
||||
namespace QSB.Utility.VariableSync
|
||||
{
|
||||
public class BoolVariableSyncer : BaseVariableSyncer
|
||||
public class BoolVariableSyncer : BaseVariableSyncer<bool>
|
||||
{
|
||||
private bool _prevValue;
|
||||
[NonSerialized]
|
||||
public bool Value;
|
||||
|
||||
protected override bool HasChanged() => Value != _prevValue;
|
||||
protected override void UpdatePrevData() => _prevValue = Value;
|
||||
protected override void Serialize(NetworkWriter writer, bool initialState) => writer.Write(Value);
|
||||
protected override void Deserialize(NetworkReader reader, bool initialState) => Value = reader.Read<bool>();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,6 @@
|
||||
using Mirror;
|
||||
using System;
|
||||
|
||||
namespace QSB.Utility.VariableSync
|
||||
namespace QSB.Utility.VariableSync
|
||||
{
|
||||
public class FloatVariableSyncer : BaseVariableSyncer
|
||||
public class FloatVariableSyncer : BaseVariableSyncer<float>
|
||||
{
|
||||
private float _prevValue;
|
||||
[NonSerialized]
|
||||
public float Value;
|
||||
|
||||
protected override bool HasChanged() => Value != _prevValue;
|
||||
protected override void UpdatePrevData() => _prevValue = Value;
|
||||
protected override void Serialize(NetworkWriter writer, bool initialState) => writer.Write(Value);
|
||||
protected override void Deserialize(NetworkReader reader, bool initialState) => Value = reader.Read<float>();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,8 @@
|
||||
using Mirror;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Utility.VariableSync
|
||||
{
|
||||
public class Vector3VariableSyncer : BaseVariableSyncer
|
||||
public class Vector3VariableSyncer : BaseVariableSyncer<Vector3>
|
||||
{
|
||||
private Vector3 _prevValue;
|
||||
[NonSerialized]
|
||||
public Vector3 Value;
|
||||
|
||||
protected override bool HasChanged() => Value != _prevValue;
|
||||
protected override void UpdatePrevData() => _prevValue = Value;
|
||||
protected override void Serialize(NetworkWriter writer, bool initialState) => writer.Write(Value);
|
||||
protected override void Deserialize(NetworkReader reader, bool initialState) => Value = reader.Read<Vector3>();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user