From 736d79d15f06bcc9cf94085687ce83249e2d094a Mon Sep 17 00:00:00 2001 From: oryxoik Date: Sat, 19 Oct 2024 08:54:43 +0500 Subject: [PATCH 1/5] TitanTarget should be Networked --- Assets/Resources/Data/Info/MapPrefabList.json | 2 +- Assets/Resources/Data/Modes/BaseLogic.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Resources/Data/Info/MapPrefabList.json b/Assets/Resources/Data/Info/MapPrefabList.json index 62b407389..0592f6a4f 100644 --- a/Assets/Resources/Data/Info/MapPrefabList.json +++ b/Assets/Resources/Data/Info/MapPrefabList.json @@ -843,7 +843,7 @@ {"Name": "Horse1", "Asset": "Interact/Horse1", "CollideWith": "All", "Static": false, "Components": ["Animal|WalkAnimation:horse_WALK|IdleAnimations:horse_idle0|ActionAnimations:horse_idle1/horse_idle2/horse_idle3/horse_crazy|ActionSounds:None/Idle2Sound/Idle3Sound/CrazySound,Rigidbody|Mass:5.0|Gravity:0.0/-20.0/0.0|FreezeRotation:true"]}, {"Name": "Dog1", "Asset": "Interact/Dog1", "CollideWith": "All", "Static": false, "Components": ["Animal|WalkAnimation:Walk|IdleAnimations:Idle0/Lie1/Lie2/Lie3/Sit1/Sit2/Sleep/Stand|ActionAnimations:Itch/Stretch/Shake,Rigidbody|Mass:5.0|Gravity:0.0/-20.0/0.0|FreezeRotation:true"]}, {"Name":"Destructible Trigger", "Asset":"Geometry/Cube1", "Visible": false, "Static": false, "Networked": true, "CollideMode": "Region", "CollideWith": "Hitboxes", "Components": ["DestructibleTrigger|"]}, - {"Name":"Titan Target", "Components": ["TitanTarget|"]} + {"Name":"Titan Target", "Static": false, "Networked": true, "Components": ["TitanTarget|"]} ] }, "Legacy": { diff --git a/Assets/Resources/Data/Modes/BaseLogic.txt b/Assets/Resources/Data/Modes/BaseLogic.txt index c23efaf1f..de56a8382 100644 --- a/Assets/Resources/Data/Modes/BaseLogic.txt +++ b/Assets/Resources/Data/Modes/BaseLogic.txt @@ -748,7 +748,7 @@ component TitanTarget function Init() { - self._targetable = self.MapObject.AddSphereTarget("Human", Vector3(0), 10.1); + self._targetable = self.MapObject.AddSphereTarget("Human", Vector3(0), 0.1); self._targetable.Enabled = self.EnabledByDefault; self.MapObject.AddSphereCollider("Region", "Characters", Vector3(0), self.PlayerPriorityRange); From 500e5800c623db56ce5b593ec03e59295474f521 Mon Sep 17 00:00:00 2001 From: oryxoik Date: Sat, 19 Oct 2024 09:02:17 +0500 Subject: [PATCH 2/5] Fixed "else" bug in coroutine --- Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs index 377f9814a..810a51c1c 100644 --- a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs +++ b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs @@ -653,8 +653,7 @@ private IEnumerator EvaluateBlockCoroutine(CustomLogicClassInstance classInstanc } else if ((int)conditional.Token.Value == (int)CustomLogicSymbol.Else) { - if ((conditionalState == ConditionalEvalState.FailedIf || conditionalState == ConditionalEvalState.FailedElseIf) && - (bool)EvaluateExpression(classInstance, localVariables, conditional.Condition)) + if (conditionalState == ConditionalEvalState.FailedIf || conditionalState == ConditionalEvalState.FailedElseIf) { yield return CustomLogicManager._instance.StartCoroutine(EvaluateBlockCoroutine(classInstance, localVariables, conditional.Statements)); } From 4fd19731d03fbe58b8c99d25eb4a4ee7f6550074 Mon Sep 17 00:00:00 2001 From: oryxoik Date: Sat, 19 Oct 2024 09:39:30 +0500 Subject: [PATCH 3/5] Waitable methods --- .../CustomLogic/CustomLogicEvaluator.cs | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs index 810a51c1c..4093d43c2 100644 --- a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs +++ b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs @@ -614,21 +614,34 @@ private IEnumerator EvaluateBlockCoroutine(CustomLogicClassInstance classInstanc { yield break; } - else if (statement is CustomLogicWaitExpressionAst) + else if (statement is CustomLogicWaitExpressionAst waitExpressionAst) { - object value = EvaluateExpression(classInstance, localVariables, ((CustomLogicWaitExpressionAst)statement).WaitTime); - string className = classInstance.ClassName; - if ((int)_start.Classes[className].Token.Value == (int)CustomLogicSymbol.Cutscene) + object value = EvaluateExpression(classInstance, localVariables, waitExpressionAst.WaitTime); + + if (value is null) + yield return null; + else if (waitExpressionAst.WaitTime is CustomLogicMethodCallExpressionAst methodCallExpressionAst) { - float time = value.UnboxToFloat(); - while (time > 0f && !CustomLogicManager.SkipCutscene) + if (value is Coroutine coroutine) + yield return value; + else + yield return null; + } + else + { + string className = classInstance.ClassName; + if ((int)_start.Classes[className].Token.Value == (int)CustomLogicSymbol.Cutscene) { - yield return new WaitForSeconds(0.1f); - time -= 0.1f; + float time = value.UnboxToFloat(); + while (time > 0f && !CustomLogicManager.SkipCutscene) + { + yield return new WaitForSeconds(0.1f); + time -= 0.1f; + } } + else + yield return new WaitForSeconds(value.UnboxToFloat()); } - else - yield return new WaitForSeconds(value.UnboxToFloat()); } else if (statement is CustomLogicConditionalBlockAst) { From 2e869bbaa0e6f915040f13ef7bbae11ac74b1fd5 Mon Sep 17 00:00:00 2001 From: oryxoik Date: Sat, 19 Oct 2024 12:02:54 +0500 Subject: [PATCH 4/5] Cutscene case --- Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs index 4093d43c2..833c7b9a8 100644 --- a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs +++ b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs @@ -617,11 +617,15 @@ private IEnumerator EvaluateBlockCoroutine(CustomLogicClassInstance classInstanc else if (statement is CustomLogicWaitExpressionAst waitExpressionAst) { object value = EvaluateExpression(classInstance, localVariables, waitExpressionAst.WaitTime); + bool isCutscene = (int)_start.Classes[classInstance.ClassName].Token.Value == (int)CustomLogicSymbol.Cutscene; if (value is null) yield return null; else if (waitExpressionAst.WaitTime is CustomLogicMethodCallExpressionAst methodCallExpressionAst) { + if (isCutscene) + value = null; + if (value is Coroutine coroutine) yield return value; else @@ -629,8 +633,7 @@ private IEnumerator EvaluateBlockCoroutine(CustomLogicClassInstance classInstanc } else { - string className = classInstance.ClassName; - if ((int)_start.Classes[className].Token.Value == (int)CustomLogicSymbol.Cutscene) + if (isCutscene) { float time = value.UnboxToFloat(); while (time > 0f && !CustomLogicManager.SkipCutscene) From 5a90c7d3b1d2a4032e2bcbf562e996efe4dd1200 Mon Sep 17 00:00:00 2001 From: oryxoik Date: Sun, 20 Oct 2024 17:49:50 +0500 Subject: [PATCH 5/5] break/continue func only --- .../CustomLogic/CustomLogicEvaluator.cs | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs index 833c7b9a8..cbb0df02b 100644 --- a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs +++ b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs @@ -789,6 +789,18 @@ private object[] EvaluateBlock(CustomLogicClassInstance classInstance, Dictionar result[1] = EvaluateExpression(classInstance, localVariables, ((CustomLogicReturnExpressionAst)statement).ReturnValue); return result; } + else if (statement is CustomLogicBreakExpressionAst breakExpressionAst) + { + result[0] = true; + result[1] = breakExpressionAst; + return result; + } + else if (statement is CustomLogicContinueExpressionAst continueExpressionAst) + { + result[0] = true; + result[1] = continueExpressionAst; + return result; + } else if (statement is CustomLogicConditionalBlockAst) { CustomLogicConditionalBlockAst conditional = (CustomLogicConditionalBlockAst)statement; @@ -806,10 +818,28 @@ private object[] EvaluateBlock(CustomLogicClassInstance classInstance, Dictionar } else if ((int)conditional.Token.Value == (int)CustomLogicSymbol.While) { + var skipNext = false; while ((bool)EvaluateExpression(classInstance, localVariables, conditional.Condition)) { + if (skipNext) + { + skipNext = false; + continue; + } + object[] nextResult = EvaluateBlock(classInstance, localVariables, conditional.Statements); - if ((bool)nextResult[0]) + bool shouldBreak = (bool)nextResult[0]; + + if (shouldBreak && nextResult[1] is CustomLogicContinueExpressionAst) + { + skipNext = true; + continue; + } + + if (shouldBreak && nextResult[1] is CustomLogicBreakExpressionAst) + break; + + if (shouldBreak) return nextResult; } conditionalState = ConditionalEvalState.None; @@ -852,7 +882,15 @@ private object[] EvaluateBlock(CustomLogicClassInstance classInstance, Dictionar else localVariables.Add(variableName, variable); object[] nextResult = EvaluateBlock(classInstance, localVariables, forBlock.Statements); - if ((bool)nextResult[0]) + bool shouldBreak = (bool)nextResult[0]; + + if (shouldBreak && nextResult[1] is CustomLogicContinueExpressionAst) + continue; + + if (shouldBreak && nextResult[1] is CustomLogicBreakExpressionAst) + break; + + if (shouldBreak) return nextResult; } }