Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
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 > pluginbase.Objects.Syncable.ValidatedSyncableBase< T, TBase > pluginbase.Objects.Syncable.SyncableBase< T > pluginbase.Objects.Syncable.IValidatedNetSyncable pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.INetWatcher

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)
 Load the instance from a persist object More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.Watchers.SyncBase< T >
override void EncodeTo (BinaryWriter writer, EncodeContext context)
 Encode changes to binary data More...
 
override void DecodeFrom (BinaryReader reader, DecodeContext context)
 Decode changes from binary data More...
 
override void Persist (IPersistObject obj)
 Persist the instance to a persist object More...
 
override void Load (IReadPersistObject obj)
 Load the instance from a persist object More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.ValidatedSyncableBase< T, TBase >
bool Validate (T current, T proposed, DecodeContext context)
 Validate the specified current, proposed and context. More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableBase< T >
void Touch ()
 Touch the instance, notifying something has changed More...
 
virtual void TouchRecurse ()
 Touch the instance More...
 
virtual void ResetWatch ()
 Reset the touched state More...
 
virtual void OnChanged ()
 Raises the changed event. More...
 

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...
 
- Properties inherited from pluginbase.Objects.Syncable.INetSyncable
INetWatcher Watcher [get, set]
 Who is watching (who to inform of a change) More...
 
bool Modified [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.INetSyncable is modified. 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
 
- Events inherited from pluginbase.Objects.Syncable.SyncableBase< T >
Action< T > Changed
 Event triggered when any change occurs on this object, either locally or over the network More...
 
Action< T > NetUpdate
 Event triggered when a change occurs resulting from a change over the network More...
 
Action< T > Touched
 Event occurs only when an object is first touched. Usually the first instance of a local-change More...
 

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.

Type Constraints
T :struct 

Constructor & Destructor Documentation

pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.SmoothSync ( )
99  {
100  }
pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.SmoothSync ( val)
103  :base(val)
104  {
105  _previous = val;
106  }
pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.SmoothSync ( val,
TimeSpan  period 
)
109  :this(val)
110  {
111  this.Period = period;
112  }
TimeSpan Period
The length of time over which interpolative smoothing occurs
Definition: SmoothSync.cs:136

Member Function Documentation

void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.ClearFactor ( )

Clear the interpolative factor

157  {
158  _factor = null;
159  }
override void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.DecodeFrom ( System.IO.BinaryReader  reader,
DecodeContext  context 
)
protected
228  {
229  T preDecodeVal = this.Value;
230 
231  bool jumped = reader.ReadBoolean();
232  base.DecodeFrom(reader, context);
233 
234  if (!context.Failed)
235  {
236  if (_jump && !context.Declarative)
237  {
238  //Don't listen to network if we're about to jump
239  this.InternalValue = preDecodeVal;
240  }
241  else
242  {
243  if (context.Declarative || jumped)
244  {
245  _previous = this.InternalValue;
246  }
247  else
248  {
249  _previous = preDecodeVal;
250  }
251 
252  if (context.TimeState != null)
253  {
254  _lastUpdate = context.TimeState.CurrentTime;
255  }
256  }
257  }
258  }
T Value
The smoothed value over time
Definition: SmoothSync.cs:196
override void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.EncodeTo ( System.IO.BinaryWriter  writer,
EncodeContext  context 
)
protected
220  {
221  writer.Write(_jump);
222  base.EncodeTo(writer, context);
223 
224  _jump = false;
225  }
void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.Jump ( val)

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

Parameters
valValue.
166  {
167  _jump = true;
168  this.Value = val;
169  }
T Value
The smoothed value over time
Definition: SmoothSync.cs:196
override void pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.Load ( pluginbase.Objects.Libs.Persist.IReadPersistObject  obj)
protectedvirtual

Load the instance from a persist object

Parameters
objObject.

Implements pluginbase.Objects.Syncable.SyncableBase< T >.

261  {
262  base.Load(obj);
263  _lastUpdate = DateTime.MinValue;
264  _previous = this.InternalValue;
265  }
static implicit pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.operator T ( SmoothSync< T >  sync)
static
211  {
212  return sync.Value;
213  }

Property Documentation

float pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.Factor
getset

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

The factor.

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

Has the interpolation finished

true if finished interpolating; otherwise, false.

TimeSpan pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.Period
getset

The length of time over which interpolative smoothing occurs

The period.

T pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.RawValue
getset

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

The raw value.

T pluginbase.Objects.Syncable.Watchers.SmoothSync< T >.Value
getset

The smoothed value over time

The value.


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