/// <summary> /// Disposes of the tween and resets all variables. /// </summary> public void Dispose() { if (m_TweenData != null) { if (m_State == State.Run && m_Cancel != CancelMode.Nothing) { m_Reversed = false; float curvedPercent = 0; switch (m_Cancel) { case CancelMode.Revert: curvedPercent = Evaluate(0); break; case CancelMode.RevertNoWave: curvedPercent = EvaluateNoWave(0); break; case CancelMode.ForceEnd: curvedPercent = Evaluate(m_Mode == LoopMode.Yoyo || m_Mode == LoopMode.YoyoLoop ? 0 : 1); break; case CancelMode.ForceEndNoWave: curvedPercent = EvaluateNoWave(m_Mode == LoopMode.Yoyo || m_Mode == LoopMode.YoyoLoop ? 0 : 1); break; } m_TweenData.ApplyTween(curvedPercent); if (m_OnUpdate != null) { m_OnUpdate(m_FromMode ? 1 - curvedPercent : curvedPercent); } } m_TweenData.OnTweenEnd(); m_TweenData = null; TweenPool.Free(this); } m_Cancel = CancelMode.Nothing; m_Mode = LoopMode.Single; m_Curve = Curve.Linear; m_AnimCurve = null; m_WaveFunc = default(Wave); m_NumLoops = 0; m_OnStart = null; m_OnUpdate = null; m_OnComplete = null; m_Reversed = false; m_MirrorCurve = false; m_FromMode = false; m_Instant = false; m_StartMode = StartMode.Restart; m_StartTime = 0; m_CurrentPercent = 0; m_PercentIncrement = 0; m_State = State.Begin; }
/// <summary> /// Deactivates the timer and cancels a currently running job. /// <para> /// Be careful to not have a timeout handler executing in parallel with a /// timer, because this will just cancel the timer. If you for example /// <seealso cref="reset()"/> in the timeout handler, but keep executing the handler, /// then a subsequent cancel will not ensure that the first execution of the /// handler was cancelled. /// /// </para> /// </summary> /// <param name="cancelMode"> The mode of cancelling. </param> public virtual void Cancel(CancelMode cancelMode) { JobHandle job; lock (this) { _activeJobId++; job = this._job; } if (job != null) { try { if (cancelMode == CancelMode.SyncWait) { job.WaitTermination(); } else if (cancelMode == CancelMode.AsyncInterrupt) { job.Cancel(true); } } catch (Exception e) { _log.warn(format("[%s] Cancelling timer threw exception", CanonicalName()), e); } } }
public static MeMultiLimitOrderModel Create( string id, string clientId, string assetId, MeMultiOrderItemModel[] orders, bool cancelAllPreviousLimitOrders = false, CancelMode cancelMode = default) { return(new MeMultiLimitOrderModel { Id = id, DateTime = (long)System.DateTime.UtcNow.ToUnixTime(), ClientId = clientId, AssetId = assetId, Orders = orders ?? new MeMultiOrderItemModel[0], CancelAllPreviousLimitOrders = cancelAllPreviousLimitOrders, CancelMode = (int)cancelMode }); }
public static MeCancelMode ToMeCancelModel(this CancelMode cancelMode) { switch (cancelMode) { case CancelMode.NotEmptySide: return(MeCancelMode.NotEmptySide); case CancelMode.BothSides: return(MeCancelMode.BothSides); case CancelMode.SellSide: return(MeCancelMode.SellSide); case CancelMode.BuySide: return(MeCancelMode.BuySide); default: throw new ArgumentException($"Unknown cancel model: {cancelMode}"); } }
/// <summary> /// Will keep the value where it ended up /// if the tween is cancelled mid-animation. /// Default behavior. /// </summary> public Tween KeepOnCancel() { m_Cancel = CancelMode.Nothing; return(this); }
/// <summary> /// Will force to the ending value if the tween /// is cancelled mid-animation. /// </summary> public Tween ForceOnCancel(bool inbApplyWave = true) { m_Cancel = inbApplyWave ? CancelMode.ForceEnd : CancelMode.ForceEndNoWave; return(this); }
/// <summary> /// Will revert back to the starting value if the tween /// is cancelled mid-animation. /// </summary> public Tween RevertOnCancel(bool inbApplyWave = true) { m_Cancel = inbApplyWave ? CancelMode.Revert : CancelMode.RevertNoWave; return(this); }
private static MultiLimitOrderModel CreateMultiOrder(string clientId, string assetPairId, double[] buyPrices = null, double[] sellPrices = null, string[] oldBuyId = null, string[] oldSellId = null, bool cancelPreviousOrders = true, CancelMode cancelMode = CancelMode.NotEmptySide) { if (string.IsNullOrEmpty(clientId)) { throw new ArgumentNullException(nameof(clientId), "ClientId must be specified"); } const int volume = 10; var orderItemsBuy = buyPrices?.Select((buyPrice, index) => new MultiOrderItemModel { Id = GenerateUid(), OrderAction = OrderAction.Buy, Price = buyPrice, Volume = volume, OldId = oldBuyId != null && oldBuyId.Length > index ? oldBuyId[index] : null }) ?? Enumerable.Empty <MultiOrderItemModel>(); var orderItemsSell = sellPrices?.Select((sellPrice, index) => new MultiOrderItemModel { Id = GenerateUid(), OrderAction = OrderAction.Sell, Price = sellPrice, Volume = volume, OldId = oldSellId != null && oldSellId.Length > index ? oldSellId[index] : null }) ?? Enumerable.Empty <MultiOrderItemModel>(); return(new MultiLimitOrderModel { AssetPairId = assetPairId, CancelPreviousOrders = cancelPreviousOrders, ClientId = clientId, Id = GenerateUid(), CancelMode = cancelMode, Orders = orderItemsBuy.Concat(orderItemsSell).ToList() }); }