Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CL more bug fixes & features #171

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Resources/Data/Info/MapPrefabList.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion Assets/Resources/Data/Modes/BaseLogic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
81 changes: 67 additions & 14 deletions Assets/Scripts/CustomLogic/CustomLogicEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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));
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need skipNext? Isn't it enough to just call continue?


if (shouldBreak && nextResult[1] is CustomLogicBreakExpressionAst)
break;

if (shouldBreak)
return nextResult;
}
conditionalState = ConditionalEvalState.None;
Expand Down Expand Up @@ -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;
}
}
Expand Down