rewrite constructor of VmcExtVrm

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-08-17 10:28:30 -04:00
parent 11c3a0c500
commit 06a269f277

View File

@ -29,11 +29,9 @@ namespace godotVmcSharp
public VmcExtVrm(godotOscSharp.OscMessage m) : base(m.Address)
{
if (m.Data.Count < 2 || m.Data.Count > 3)
switch (m.Data.Count)
{
GD.Print($"Invalid number of arguments for {addr} message. Expected 2 or 3 but received {m.Data.Count}");
return;
}
case 2:
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(addr, "path", 's', m.Data[0].Type));
@ -46,8 +44,15 @@ namespace godotVmcSharp
}
path = (string)m.Data[0].Value;
title = (string)m.Data[1].Value;
if (m.Data.Count != 3)
case 3:
if (m.Data[0].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(addr, "path", 's', m.Data[0].Type));
return;
}
if (m.Data[1].Type != 's')
{
GD.Print(InvalidArgumentType.GetErrorString(addr, "title", 's', m.Data[1].Type));
return;
}
if (m.Data[2].Type != 's')
@ -55,7 +60,13 @@ namespace godotVmcSharp
GD.Print(InvalidArgumentType.GetErrorString(addr, "hash", 's', m.Data[1].Type));
return;
}
path = (string)m.Data[0].Value;
title = (string)m.Data[1].Value;
hash = (string)m.Data[2].Value;
default:
GD.Print($"Invalid number of arguments for {addr} message. Expected 2 or 3 but received {m.Data.Count}");
return;
}
}
}
}