Skip to content

Commit

Permalink
Fixed merge issues, made commands case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnThyme committed Feb 14, 2025
1 parent ad58191 commit f1c4c64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System.Collections.Generic;
using UnityEngine;

namespace CustomLogic
{
Expand Down Expand Up @@ -163,7 +164,8 @@ public void PlayAnimation(string anim, float fade = 0.1f)
}

[CLMethod("Gets the length of the specified animation.")]
public float GetAnimationLength(string anim) => {
public float GetAnimationLength(string anim)
{
var animation = Value.GetComponent<Animation>(); // TODO: Cache this value or find a way to avoid calling GetComponent every time.
if (animation != null)
return animation[anim].length;
Expand All @@ -179,7 +181,7 @@ public float GetAnimationLength(string anim) => {
}
return _animatorClips[anim].length;
}
return null;
return -1;
}

[CLMethod("Plays the sound.")]
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/GameManagers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public static void Init()
{
cmdAttr.Command = info;

CommandsCache.Add(cmdAttr.Name, cmdAttr);
CommandsCache.Add(cmdAttr.Name.ToLower(), cmdAttr);

// Create second mapping from alias to cmd, has to be a separate object flagged as alias.
// This lets us ignore alias's later on in the help function.
if (cmdAttr.Alias != null)
{
CommandAttribute alias = new CommandAttribute(cmdAttr);
alias.IsAlias = true;
CommandsCache.Add(alias.Alias, alias);
CommandsCache.Add(alias.Alias.ToLower(), alias);
}
}
}
Expand Down Expand Up @@ -274,7 +274,7 @@ public static void HandleInput(string input)

private static void HandleCommand(string[] args)
{
if (CommandsCache.TryGetValue(args[0], out CommandAttribute cmdAttr))
if (CommandsCache.TryGetValue(args[0].ToLower(), out CommandAttribute cmdAttr))
{
MethodInfo info = cmdAttr.Command;
if (info.IsStatic)
Expand Down

0 comments on commit f1c4c64

Please sign in to comment.