清理各个 Component 里的判断以及调用规范
This commit is contained in:
@@ -57,6 +57,7 @@ namespace SepCore.Timer
|
||||
|
||||
if (timerTask.RepeatCount == 0)
|
||||
{
|
||||
Log.Error("Timer task repeat count is zero.");
|
||||
return TimerHandle.Invalid;
|
||||
}
|
||||
|
||||
@@ -139,6 +140,7 @@ namespace SepCore.Timer
|
||||
{
|
||||
if (owner == null)
|
||||
{
|
||||
Log.Error("Timer task owner is invalid.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -248,6 +250,12 @@ namespace SepCore.Timer
|
||||
}
|
||||
|
||||
float safeInterval = Mathf.Max(0f, newInterval);
|
||||
if (taskInfo.IsRepeating && safeInterval <= 0f)
|
||||
{
|
||||
Log.Error("Timer task interval must be greater than zero for repeated tasks.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (adjustRemainingTime && taskInfo.Interval > 0f && safeInterval > 0f)
|
||||
{
|
||||
float ratio = safeInterval / taskInfo.Interval;
|
||||
@@ -443,11 +451,6 @@ namespace SepCore.Timer
|
||||
_isUpdating = true;
|
||||
for (int i = taskCount - 1; i >= 0; i--)
|
||||
{
|
||||
if (i >= _timerTasks.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TimerTaskInfo taskInfo = _timerTasks[i];
|
||||
if (taskInfo.IsCancelled || taskInfo.IsPaused)
|
||||
{
|
||||
@@ -539,6 +542,7 @@ namespace SepCore.Timer
|
||||
RemainingTime = delay;
|
||||
Interval = interval;
|
||||
RemainingRepeatCount = repeatCount;
|
||||
IsRepeating = repeatCount != 1;
|
||||
TimeMode = timeMode;
|
||||
Owner = owner;
|
||||
Callback = callback;
|
||||
@@ -569,6 +573,11 @@ namespace SepCore.Timer
|
||||
set;
|
||||
}
|
||||
|
||||
public bool IsRepeating
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public TimerTimeMode TimeMode
|
||||
{
|
||||
get;
|
||||
|
||||
Reference in New Issue
Block a user