Skip to content

Commit

Permalink
- Improved display of title on Change Value action
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoDeAndrade committed Mar 1, 2024
1 parent ca56935 commit 95ada44
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
65 changes: 64 additions & 1 deletion Assets/OkapiKit/Scripts/Actions/ActionChangeValueV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,32 @@ public enum OperationType { Reset = 0, Set = 1, Add = 2, Subtract = 3, RevSubtra
[SerializeField]
private bool scaleWithTime = false;

public override string GetActionTitle() { return "Change Value"; }
public override string GetActionTitle()
{
string title = "Change Value";
switch (operation)
{
case OperationType.Reset:
return $"Reset {GetTargetName()}";
case OperationType.Set:
return $"{GetTargetName()} = {GetShortChangeValueString()}";
case OperationType.Add:
return $"{GetTargetName()} = {GetTargetName()} + {GetShortChangeValueString()}";
case OperationType.Subtract:
return $"{GetTargetName()} = {GetTargetName()} - {GetShortChangeValueString()}";
case OperationType.RevSubtract:
return $"{GetTargetName()} = {GetShortChangeValueString()} - {GetTargetName()}";
case OperationType.Multiply:
return $"{GetTargetName()} = {GetTargetName()} * {GetShortChangeValueString()}";
case OperationType.Divide:
return $"{GetTargetName()} = {GetTargetName()} / {GetShortChangeValueString()}";
case OperationType.RevDivide:
return $"{GetTargetName()} = {GetShortChangeValueString()} / {GetTargetName()}";
default:
break;
}
return title;
}

string GetChangeValueString()
{
Expand All @@ -42,6 +67,44 @@ string GetChangeValueString()
return $"{changeValue}";
}

string GetTargetName()
{
if (variable) return variable.name;
else if (valueHandler) return valueHandler.name;

return "[UNDEFINED]";
}

string GetShortChangeValueString()
{
if (scaleWithTime)
{
if (changeValueHandler)
{
return $"{changeValueHandler.name} * elapsedTime";
}
if (changeVariable)
{
return $"{changeVariable.name} * elapsedTime";
}

return $"{changeValue} * elapsedTime";
}
else
{
if (changeValueHandler)
{
return changeValueHandler.name;
}
if (changeVariable)
{
return changeVariable.name;
}

return $"{changeValue}";
}
}

public override string GetRawDescription(string ident, GameObject gameObject)
{
string n = "[UNKNOWN]";
Expand Down
1 change: 1 addition & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added InputRotatesSprite and VelocityRotatesSprite to Flip Behaviour on platformer controller. Rotating instead of scaling changes the actual objects direction, so it can affect other movement systems, for example.
- Movement components can now have conditions built in which take care of activating/deactivating that movement
- Added Dash action, which enable short bursts of movement, using variables or values
- Improved display of title on Change Value action

## V1.13.0

Expand Down

0 comments on commit 95ada44

Please sign in to comment.