/* godotVmcSharp Copyright (C) 2023 Cassandra de la Cruz-Munoz This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ using godotOscSharp; using System.Collections.Generic; #nullable enable namespace godotVmcSharp { public class VmcExtVrm : VmcMessage { public readonly string Path; public readonly string Title; public readonly string? Hash; public static VmcExtVrm? CreateFromMessage(OscMessage m) { switch (m.Data.Count) { case 2: return new VmcExtVrm(m.Data[0].GetAsString(), m.Data[1].GetAsString()); case 1: case 0: throw new MissingArgumentsException(m.Address, "2 <= count <= 3", m.Data.Count); default: return new VmcExtVrm(m.Data[0].GetAsString(), m.Data[1].GetAsString(), m.Data[2].GetAsString()); } } public VmcExtVrm(string path, string title) : base(new OscAddress("/VMC/Ext/VRM")) { Path = path; Title = title; } public VmcExtVrm(string path, string title, string hash) : base(new OscAddress("/VMC/Ext/VRM")) { Path = path; Title = title; Hash = hash; } public new OscMessage ToMessage() { if (Hash == null) { return new OscMessage(Addr, new List{ OscArgument.CreateFromParams(Path, 's')!, OscArgument.CreateFromParams(Title, 's')! }); } return new OscMessage(Addr, new List{ OscArgument.CreateFromParams(Path, 's')!, OscArgument.CreateFromParams(Title, 's')!, OscArgument.CreateFromParams(Hash, 's')! }); } } }