Skip to content

Commit

Permalink
Release 11.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Release Automat committed Dec 19, 2024
1 parent 062674c commit c951fc9
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 20 deletions.
14 changes: 14 additions & 0 deletions Packages/tlp.udonutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [11.0.2] - 2024-12-19

#### 🐛 Bug Fixes

- *(Pool)* Fix exception when pool object has no UdonSharpBehaviour
- *(Model)* NotifyIfDirty fails if Model not yet initialized
- *(Task)* New tasks are in "Finished" state with result "Unknown"
- *(StateMachine)* Fix null error on invalid state in AllStates
- *(Model)* Ignore NotifyIfDirty errors if not dirty

#### 🚜 Refactor

- *(Task)* Magic strings to const variables

### [11.0.1] - 2024-12-13

#### 🐛 Bug Fixes
Expand Down
11 changes: 8 additions & 3 deletions Packages/tlp.udonutils/Runtime/DesignPatterns/MVC/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,18 @@ public bool NotifyIfDirty(int delayFrames = 0) {
#endif
#endregion

if (!HasStartedOk) {
if (!Dirty) {
return true;
}

if (!IsReceivingStart && !HasStartedOk) {
Error($"{nameof(NotifyIfDirty)}: Not initialized");
return false;
}

if (!Dirty) {
return true;
if (!IsModelInitialized) {
Error($"{nameof(NotifyIfDirty)}: Model not initialized");
return false;
}

if (!Utilities.IsValid(ChangeEvent)) {
Expand Down
25 changes: 15 additions & 10 deletions Packages/tlp.udonutils/Runtime/Experimental/Tasks/Task.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System;
using JetBrains.Annotations;
using TLP.UdonUtils.Runtime.Common;
using TLP.UdonUtils.Runtime.Player;
using JetBrains.Annotations;
using UnityEngine;
using VRC.SDKBase;

namespace TLP.UdonUtils.Runtime.Experimental.Tasks
{
public enum TaskState
{
Finished,
Pending,
Running,
Finished
Running
}

public enum TaskResult
Expand All @@ -30,15 +27,16 @@ public abstract class Task : TlpBaseBehaviour
public override int ExecutionOrderReadOnly => ExecutionOrder;

[PublicAPI]
public new const int ExecutionOrder = TLP.UdonUtils.Runtime.Pool.Pool.ExecutionOrder + 50;
public new const int ExecutionOrder = Runtime.Pool.Pool.ExecutionOrder + 50;
#endregion

public TaskState State { get; private set; }
public TaskResult Result { get; private set; }
public TaskState State { get; private set; } = TaskState.Finished;
public TaskResult Result { get; private set; } = TaskResult.Unknown;

internal TaskScheduler DefaultScheduler;
internal TaskScheduler ActiveScheduler;
internal TlpBaseBehaviour TaskInstigator;

/// <summary>
/// In range 0 - 1 (inclusive)
/// </summary>
Expand All @@ -61,7 +59,6 @@ internal bool PrepareForRun() {
Result = TaskResult.Failed;
State = TaskState.Finished;
return false;

}

public bool Abort() {
Expand All @@ -83,6 +80,7 @@ public bool Abort() {
ActiveScheduler.CancelTask(this);
return true;
}

Error($"{nameof(Abort)}: was not scheduled");
return false;
}
Expand Down Expand Up @@ -122,6 +120,13 @@ public TaskState Run() {

#region Internal
protected void SetProgress(float progress) {
#region TLP_DEBUG
#if TLP_DEBUG
DebugLog($"{nameof(SetProgress)}: {nameof(progress)}={progress}");
#endif
#endregion


Progress = Mathf.Clamp01(progress);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class TaskScheduler : TlpSingleton
public new const int ExecutionOrder = TlpExecutionOrder.RecordingEnd - 2;
#endregion

public const string FinishedTaskVariableName = "FinishedTask";
public const string FinishedTaskCallbackName = "OnTaskFinished";
public const string GameObjectName = "TLP_TaskScheduler";
internal readonly DataList PendingTasks = new DataList();
internal readonly DataDictionary UniqueTasks = new DataDictionary();
Expand Down Expand Up @@ -194,8 +196,10 @@ private void RemoveTask(Task task, int index) {
var instigator = (TlpBaseBehaviour)instigatorToken.Reference;
if (Utilities.IsValid(instigator)) {
instigator.EventInstigator = this;
instigator.OnEvent("OnTaskFinished");
instigator.SetProgramVariable(FinishedTaskVariableName, task);
instigator.OnEvent(FinishedTaskCallbackName);
instigator.EventInstigator = null;
instigator.SetProgramVariable(FinishedTaskVariableName, null);
} else {
Error(
$"{nameof(RemoveTask)}: {nameof(instigator)} invalid, {task.GetScriptPathInScene()} has no owner");
Expand Down
15 changes: 11 additions & 4 deletions Packages/tlp.udonutils/Runtime/Pool/Pool.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using System;
using JetBrains.Annotations;
using JetBrains.Annotations;
using TLP.UdonUtils.Runtime.Common;
using TLP.UdonUtils.Runtime.Events;
using TLP.UdonUtils.Runtime.Experimental.Tasks;
using UdonSharp;
using UnityEngine;
using UnityEngine.Serialization;
using VRC.SDKBase;

#if !COMPILER_UDONSHARP && UNITY_EDITOR
#else
using VRC.Udon;
#endif

namespace TLP.UdonUtils.Runtime.Pool
{
Expand Down Expand Up @@ -159,7 +163,8 @@ public void Return(GameObject toReturn) {
#endif

if (!Utilities.IsValid(instance)) {
Warn($"{toReturn.name} has no UdonSharpBehaviour attached and will thus not be de-initialized");
Warn(
$"{toReturn.transform.GetPathInScene()} has no UdonSharpBehaviour attached and will thus not be de-initialized");
} else {
instance.SendCustomEvent(nameof(OnPrepareForReturnToPool));
}
Expand All @@ -170,7 +175,9 @@ public void Return(GameObject toReturn) {
toReturn.transform.parent = transform;
}

instance.SetProgramVariable(nameof(PoolableInUse), false);
if (Utilities.IsValid(instance)) {
instance.SetProgramVariable(nameof(PoolableInUse), false);
}

Pooled++;
}
Expand Down
7 changes: 6 additions & 1 deletion Packages/tlp.udonutils/Runtime/StateMachine/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ public bool OwnerSetNewState(int newStateIndex) {
StateMachineState.enabled = false;
}

var newState = AllStates[newStateIndex];
if (!Utilities.IsValid(newState)) {
Error($"{nameof(OwnerSetNewState)}: {nameof(AllStates)} is null at index {newStateIndex}");
return false;
}

LocalStateIndex = newStateIndex;
WorkingStateIndex = newStateIndex;
var newState = AllStates[newStateIndex];
StateMachineState = newState;
newState.enabled = true;
return true;
Expand Down
2 changes: 1 addition & 1 deletion Packages/tlp.udonutils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tlp.udonutils",
"displayName": "TLP UdonUtils",
"version": "11.0.1",
"version": "11.0.2",
"description": "Contains the base scripts/tools for TLP packages as well as prefabs and potentially helpful scripts for VRChat worlds.",
"gitDependencies": {},
"legacyFolders": {
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [11.0.2] - 2024-12-19

#### 🐛 Bug Fixes

- *(Pool)* Fix exception when pool object has no UdonSharpBehaviour
- *(Model)* NotifyIfDirty fails if Model not yet initialized
- *(Task)* New tasks are in "Finished" state with result "Unknown"
- *(StateMachine)* Fix null error on invalid state in AllStates
- *(Model)* Ignore NotifyIfDirty errors if not dirty

#### 🚜 Refactor

- *(Task)* Magic strings to const variables

### [11.0.1] - 2024-12-13

#### 🐛 Bug Fixes
Expand Down

0 comments on commit c951fc9

Please sign in to comment.