public SPTime(ITimeSupplier ts) { if (ts == null) throw new System.ArgumentNullException("ts"); _timeSupplierType = SPTime.GetDeltaType(ts); if (ts is CustomTimeSupplier) _timeSupplierName = (ts as CustomTimeSupplier).Id; else _timeSupplierName = null; }
public SPTime(DeltaTimeType etp, string timeSupplierName) { if(etp == DeltaTimeType.Custom) { _timeSupplierType = etp; _timeSupplierName = timeSupplierName; } else { _timeSupplierType = etp; _timeSupplierName = null; } }
public static ITimeSupplier GetTime(DeltaTimeType etp) { switch(etp) { case DeltaTimeType.Normal: return _normalTime; case DeltaTimeType.Real: return _realTime; case DeltaTimeType.Smooth: return _smoothTime; default: return _customTimes.Values.FirstOrDefault(); } }
//[System.NonSerialized()] //private CustomTimeSupplier _customTime; #endregion #region CONSTRUCTOR public SPTimePeriod(float seconds) { _seconds = seconds; _timeSupplierType = DeltaTimeType.Normal; _timeSupplierName = null; }
//public SPTime() //{ // //exists only for unity serialization //} public SPTime(DeltaTimeType etp) { if (etp == DeltaTimeType.Custom) throw new System.ArgumentException("For custom time suppliers, you must specify it directly."); _timeSupplierType = etp; _timeSupplierName = null; }
public static ITimeSupplier GetTime(DeltaTimeType etp, string id) { switch (etp) { case DeltaTimeType.Normal: return _normalTime; case DeltaTimeType.Real: return _realTime; case DeltaTimeType.Smooth: return _smoothTime; default: { if (id == null) return null; CustomTimeSupplier ct; if (_customTimes.TryGetValue(id, out ct)) { return ct; } return null; } } }