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); diff --git a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs index 377f9814a..cbb0df02b 100644 --- a/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs +++ b/Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs @@ -614,21 +614,37 @@ 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); + 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) { - float time = value.UnboxToFloat(); - while (time > 0f && !CustomLogicManager.SkipCutscene) + if (isCutscene) + value = null; + + if (value is Coroutine coroutine) + yield return value; + else + yield return null; + } + else + { + if (isCutscene) { - 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) { @@ -653,8 +669,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)); } @@ -774,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; @@ -791,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; @@ -837,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; } }