Empeld
Empeld plugin documentation.
pluginbase.Objects.Syncable.Watchers.SmoothSync< T > Class Template Reference

Class to synchronize primitives that support addition and multiplication Smoothing (Interpolation) the result across time. Great for linear interpolation of positions, rotation and other such variable data. More...

Inheritance diagram for pluginbase.Objects.Syncable.Watchers.SmoothSync< T >:
pluginbase.Objects.Syncable.Watchers.SyncBase< T >

Public Member Functions

 SmoothSync ()
 
 SmoothSync (T val)
 
 SmoothSync (T val, TimeSpan period)
 
void ClearFactor ()
 Clear the interpolative factor More...
 
void Jump (T val)
 Jump to a specific value, over the network, ignoring interpolation More...
 
- Public Member Functions inherited from pluginbase.Objects.Syncable.Watchers.SyncBase< T >
 SyncBase ()
 
 SyncBase (T val)
 
override string ToString ()
 
sealed override bool Equals (object obj)
 
sealed override int GetHashCode ()
 

Static Public Member Functions

static implicit operator T (SmoothSync< T > sync)
 
- Static Public Member Functions inherited from pluginbase.Objects.Syncable.Watchers.SyncBase< T >
static implicit operator T (SyncBase< T > sync)
 
static bool operator== (SyncBase< T > left, T right)
 
static bool operator!= (SyncBase< T > left, T right)
 
static bool operator== (SyncBase< T > left, SyncBase< T > right)
 
static bool operator!= (SyncBase< T > left, SyncBase< T > right)
 

Protected Member Functions

override void EncodeTo (System.IO.BinaryWriter writer, EncodeContext context)
 
override void DecodeFrom (System.IO.BinaryReader reader, DecodeContext context)
 
override void Load (pluginbase.Objects.Libs.Persist.IReadPersistObject obj)
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.Watchers.SyncBase< T >
override void EncodeTo (BinaryWriter writer, EncodeContext context)
 
override void DecodeFrom (BinaryReader reader, DecodeContext context)
 
override void Persist (IPersistObject obj)
 
override void Load (IReadPersistObject obj)
 

Properties

float Factor [get, set]
 The current factor of which the interpolative multiplcation happens. Can be overriden with a value. To clear override, use ClearFactor() More...
 
TimeSpan Period [get, set]
 The length of time over which interpolative smoothing occurs More...
 
bool FinishedInterpolating [get]
 Has the interpolation finished More...
 
RawValue [get, set]
 The raw, real-value, of the underlying syncable object, without smoothing More...
 
Value [get, set]
 The smoothed value over time More...
 

Additional Inherited Members

- Protected Attributes inherited from pluginbase.Objects.Syncable.Watchers.SyncBase< T >
InternalValue
 
- Static Protected Attributes inherited from pluginbase.Objects.Syncable.Watchers.SyncBase< T >
static readonly IEqualityComparer< T > Comparer
 
static readonly string TypeName
 

Detailed Description

Class to synchronize primitives that support addition and multiplication Smoothing (Interpolation) the result across time. Great for linear interpolation of positions, rotation and other such variable data.

Can interpolate anything with basic arithmatic expressions (Convert from float, add, subtract, multiply)

Type Constraints
T :struct 

Constructor & Destructor Documentation

◆ SmoothSync() [1/3]

◆ SmoothSync() [2/3]

105  :base(val)
106  {
107  _previous = val;
108  }

◆ SmoothSync() [3/3]

pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.SmoothSync ( val,
TimeSpan  period 
)
111  :this(val)
112  {
113  this.Period = period;
114  }
TimeSpan Period
The length of time over which interpolative smoothing occurs
Definition: SmoothSync.cs:138

Member Function Documentation

◆ ClearFactor()

Clear the interpolative factor

159  {
160  _factor = null;
161  }

◆ DecodeFrom()

override void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.DecodeFrom ( System.IO.BinaryReader  reader,
DecodeContext  context 
)
protected
230  {
231  T preDecodeVal = this.Value;
232 
233  bool jumped = reader.ReadBoolean();
234  base.DecodeFrom(reader, context);
235 
236  if (!context.Failed)
237  {
238  if (_jump && !context.Declarative)
239  {
240  //Don't listen to network if we're about to jump
241  this.InternalValue = preDecodeVal;
242  }
243  else
244  {
245  if (context.Declarative || jumped)
246  {
247  _previous = this.InternalValue;
248  }
249  else
250  {
251  _previous = preDecodeVal;
252  }
253 
254  if (context.TimeState != null)
255  {
256  _lastUpdate = context.TimeState.CurrentTime;
257  }
258  }
259  }
260  }
T InternalValue
Definition: SyncBase.cs:16
T Value
The smoothed value over time
Definition: SmoothSync.cs:198

◆ EncodeTo()

override void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.EncodeTo ( System.IO.BinaryWriter  writer,
EncodeContext  context 
)
protected
222  {
223  writer.Write(_jump);
224  base.EncodeTo(writer, context);
225 
226  _jump = false;
227  }

◆ Jump()

Jump to a specific value, over the network, ignoring interpolation

Parameters
valValue.
168  {
169  _jump = true;
170  this.Value = val;
171  }
T Value
The smoothed value over time
Definition: SmoothSync.cs:198

◆ Load()

263  {
264  base.Load(obj);
265  _lastUpdate = DateTime.MinValue;
266  _previous = this.InternalValue;
267  }
T InternalValue
Definition: SyncBase.cs:16

◆ operator T()

static implicit pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.operator T ( SmoothSync< T >  sync)
static
213  {
214  return sync.Value;
215  }

Property Documentation

◆ Factor

The current factor of which the interpolative multiplcation happens. Can be overriden with a value. To clear override, use ClearFactor()

The factor.

◆ FinishedInterpolating

bool pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.FinishedInterpolating
get

Has the interpolation finished

true if finished interpolating; otherwise, false.

◆ Period

The length of time over which interpolative smoothing occurs

The period.

◆ RawValue

The raw, real-value, of the underlying syncable object, without smoothing

The raw value.

◆ Value

The smoothed value over time

The value.


The documentation for this class was generated from the following file: