internal static void GetColorOffset(PointDefinition localColor, Track track, float time, out Color?color) { Vector4?pathColor = localColor?.InterpolateVector4(time) ?? TryGetVector4PathProperty(track, COLOR, time); Vector4?colorVector = MultVector4Nullables((Vector4?)TryGetPropertyAsObject(track, COLOR), pathColor); if (colorVector.HasValue) { Vector4 vectorValue = colorVector.Value; color = new Color(vectorValue.x, vectorValue.y, vectorValue.z, vectorValue.w); } else { color = null; } }
private IEnumerator ShaderEventCoroutine(ShaderProperty property, float startTime, float duration, Functions easing) { if (property == null) { Logger.log.Error("ShaderEventCoroutine received null ShaderProperty!"); yield return(null); } while (true) { float elapsedTime = _customEventCallbackController._audioTimeSource.songTime - startTime; float time = Easings.Interpolate(Mathf.Min(elapsedTime / duration, 1f), easing); PointDefinition points = property.Points; if (points != null) { switch (property.PropertyType) { case PropertyType.Linear: property.SetValue(points.InterpolateLinear(time)); break; case PropertyType.Vector3: property.Value = points.Interpolate(time); break; case PropertyType.Vector4: property.Value = points.InterpolateVector4(time); break; case PropertyType.Quaternion: property.Value = points.InterpolateQuaternion(time); break; } } else { Logger.log.Error("ShaderEventCoroutine: ShaderCommand with id \"" + property.ParentCommand.ID + "\" and _ref \"" + property.ParentCommand.ReferenceName + "\" has invalid points at \"" + property.Property + "\"!"); } if (elapsedTime < duration) { yield return(null); } else { break; } } if (property.IsLast && property.ParentCommand.ClearAfterLastPropIsDone) { if (!_shaderManager.RemoveMaterial(property.ParentCommand.ID, property.ParentCommand.ShaderEffectData)) { Logger.log.Error($"Tried to remove a Shader with an ID that doesn't exist: '{property.ParentCommand.ID}' at time (in beats) {_customEventCallbackController._audioTimeSource.songTime / 60 * _beatmapObjectSpawnController.currentBpm}!"); } StopAllCoroutinesModifyingMaterials(new List <Material>() { property.ParentCommand.Material }); Logger.log.Debug($"Material removed after last property stopped animating! ID: {property.ParentCommand.ID} - ref: {property.ParentCommand.ReferenceName}"); } }