/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * Copyright (c) 2017-2019 Swan & The Quaver Team . */ using System; using System.Collections.Generic; //using MoonSharp.Interpreter; //using MoonSharp.Interpreter.Interop; using YamlDotNet.Serialization; namespace Quaver.API.Maps.Structures { /// /// SliderVelocities section of the .qua /// [Serializable] /*[MoonSharpUserData]*/ public class SliderVelocityInfo { /// /// The time in milliseconds when the new SliderVelocity section begins /// public float StartTime { get; /*[MoonSharpVisible(false)]*/ set; } /// /// The velocity multiplier relative to the current timing section's BPM /// public float Multiplier { get; /*[MoonSharpVisible(false)]*/ set; } /// /// Returns if the SV is allowed to be edited in lua scripts /// [YamlIgnore] public bool IsEditableInLuaScript { get; /*[MoonSharpVisible(false)]*/ set; } /// /// Sets the start time of the SV. /// FOR USE IN LUA SCRIPTS ONLY. /// /// /// public void SetStartTime(float time) { ThrowUneditableException(); StartTime = time; } /// /// Sets the multiplier of the SV. /// FOR USE IN LUA SCRIPTS ONLY. /// /// /// public void SetMultiplier(float multiplier) { ThrowUneditableException(); Multiplier = multiplier; } /// /// /// private void ThrowUneditableException() { if (!IsEditableInLuaScript) throw new InvalidOperationException("Value is not allowed to be edited in lua scripts."); } /// /// By-value comparer, auto-generated by Rider. /// private sealed class ByValueEqualityComparer : IEqualityComparer { public bool Equals(SliderVelocityInfo x, SliderVelocityInfo y) { if (ReferenceEquals(x, y)) return true; if (ReferenceEquals(x, null)) return false; if (ReferenceEquals(y, null)) return false; if (x.GetType() != y.GetType()) return false; return x.StartTime.Equals(y.StartTime) && x.Multiplier.Equals(y.Multiplier); } public int GetHashCode(SliderVelocityInfo obj) { unchecked { return (obj.StartTime.GetHashCode() * 397) ^ obj.Multiplier.GetHashCode(); } } } public static IEqualityComparer ByValueComparer { get; } = new ByValueEqualityComparer(); } }