private static void TrackColorize(ObstacleController obstacleController, ObstacleData obstacleData, AudioTimeSyncController audioTimeSyncController, float startTimeOffset, float move1Duration, float move2Duration, float obstacleDuration) { if (NoodleExtensions.NoodleController.NoodleExtensionsActive) { ChromaNoodleData chromaData = TryGetNoodleData(obstacleData); if (chromaData == null) { return; } Track track = chromaData.Track; PointDefinition pathPointDefinition = chromaData.LocalPathColor; if (track != null || pathPointDefinition != null) { float jumpDuration = move2Duration; float elapsedTime = audioTimeSyncController.songTime - startTimeOffset; float normalTime = (elapsedTime - move1Duration) / (jumpDuration + obstacleDuration); Chroma.AnimationHelper.GetColorOffset(pathPointDefinition, track, normalTime, out Color? colorOffset); if (colorOffset.HasValue) { obstacleController.SetObstacleColor(colorOffset.Value); obstacleController.SetActiveColors(); } } } }
private static void TrackColorize(NoteController instance, NoteData noteData, NoteMovement noteMovement) { if (NoodleExtensions.NoodleController.NoodleExtensionsActive) { ChromaNoodleData chromaData = ChromaNoodleDatas[noteData]; Track track = chromaData.Track; PointDefinition pathPointDefinition = chromaData.LocalPathColor; if (track != null || pathPointDefinition != null) { NoteJump noteJump = _noteJumpAccessor(ref noteMovement); float jumpDuration = _jumpDurationAccessor(ref noteJump); float elapsedTime = _audioTimeSyncControllerAccessor(ref noteJump).songTime - (noteData.time - (jumpDuration * 0.5f)); float normalTime = elapsedTime / jumpDuration; Chroma.AnimationHelper.GetColorOffset(pathPointDefinition, track, normalTime, out Color? colorOffset); if (colorOffset.HasValue) { Color color = colorOffset.Value; if (instance is BombNoteController bnc) { bnc.SetBombColor(color); } else { instance.SetNoteColors(color, color); instance.SetActiveColors(); } } } } }
public void FillPointDefinitionFile() { var p = new PointDefinition(); p.AlarmClass = "AE"; p.AlarmDelay = 5; p.AlarmEnabled = true; p.AlarmLimit = 1; p.AlarmMessage = "Alarm"; p.DataType = "BOOL"; p.Description = "point"; p.DeviceAddress = "M0.1"; p.Equation = ""; p.OpcGroup = "[GROUP01]"; p.PlcAddressBit = 1; p.PlcAddressByte = 0; p.PlcArea = "M"; p.PointType = "device"; p.PoolAfterSet = false; p.ReadOnly = true; p.Sufix = ".TEST"; var s = JsonConvert.SerializeObject(p, new JsonSerializerSettings() { Formatting = Formatting.Indented }); Assert.IsNotNull(s); Assert.IsTrue(s.Length > 0); System.IO.File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(PointDefinitionTests)).Location) + @"\pointdefinition.json", s); }
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter private static void Postfix(BeatmapData __result, float startBpm) #pragma warning restore SA1313 // Parameter names should begin with lower-case letter { if (__result == null) { return; } if (__result is CustomBeatmapData customBeatmapData) { TrackManager trackManager = new TrackManager(customBeatmapData); foreach (BeatmapLineData beatmapLineData in customBeatmapData.beatmapLinesData) { foreach (BeatmapObjectData beatmapObjectData in beatmapLineData.beatmapObjectsData) { dynamic customData; if (beatmapObjectData is CustomObstacleData || beatmapObjectData is CustomNoteData || beatmapObjectData is WaypointData) { customData = beatmapObjectData; } else { continue; } dynamic dynData = customData.customData; // TODO: account for base game bpm changes // for per object njs and spawn offset float bpm = startBpm; dynData.bpm = bpm; // for epic tracks thing string trackName = Trees.at(dynData, TRACK); if (trackName != null) { dynData.track = trackManager.AddTrack(trackName); } } } customBeatmapData.customData.tracks = trackManager.Tracks; IEnumerable <dynamic> pointDefinitions = (IEnumerable <dynamic>)Trees.at(customBeatmapData.customData, POINTDEFINITIONS); if (pointDefinitions == null) { return; } PointDefinitionManager pointDataManager = new PointDefinitionManager(); foreach (dynamic pointDefintion in pointDefinitions) { string pointName = Trees.at(pointDefintion, NAME); PointDefinition pointData = PointDefinition.DynamicToPointData(Trees.at(pointDefintion, POINTS)); pointDataManager.AddPoint(pointName, pointData); } customBeatmapData.customData.pointDefinitions = pointDataManager.PointData; } }
public void FillPointDefinitionFile() { var p01 = new PointDefinition(); p01.AlarmClass = "AE"; p01.AlarmDelay = 5; p01.AlarmEnabled = true; p01.AlarmLimit = 1; p01.AlarmMessage = "Alarm"; p01.DataType = "BOOL"; p01.Description = "point"; p01.DeviceAddress = "M0.1"; p01.Equation = ""; p01.OpcGroup = "[GROUP01]"; p01.PlcAddressBit = 1; p01.PlcAddressByte = 0; p01.PlcArea = "M"; p01.PointType = "device"; p01.PoolAfterSet = false; p01.ReadOnly = true; p01.Sufix = ".TEST"; var p02 = new PointDefinition(); p02.AlarmClass = "AE"; p02.AlarmDelay = 5; p02.AlarmEnabled = true; p02.AlarmLimit = 1; p02.AlarmMessage = "Alarm"; p02.DataType = "BOOL"; p02.Description = "point"; p02.DeviceAddress = "M0.1"; p02.Equation = ""; p02.OpcGroup = "[GROUp02]"; p02.PlcAddressBit = 1; p02.PlcAddressByte = 0; p02.PlcArea = "M"; p02.PointType = "device"; p02.PoolAfterSet = false; p02.ReadOnly = true; p02.Sufix = ".TEST"; var d = new PointDeviceDefinition() { Name = "device", TypeRestriction = "UDT930", CommentRestriction = "(spinac)", DeviceRestriction = "^NN" }; d.Points.Add(p01); d.Points.Add(p02); var s = JsonConvert.SerializeObject(d, new JsonSerializerSettings() { Formatting = Formatting.Indented }); Assert.IsNotNull(s); Assert.IsTrue(s.Length > 0); System.IO.File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(PointDeviceDefinitionTests)).Location) + @"\pointdevicedefinition.json", s); }
public ShaderProperty(string property, float duration, dynamic value, Functions easing, ShaderCommand parent) : base(PropertyType.Linear) { this.Property = property; this.Duration = duration; this.Easing = easing; this.ParentCommand = parent; if (value is string) { this.Value = value; } Points = PointDefinition.DynamicToPointData(value); //Logger.log.Debug("ShaderProperty: Points: " + Points); }
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; } }
public static BaseCameraListener GetListener(Defaults defaults, PointDefinition pointDefinition) { switch (defaults.Listener) { case ListenerTypeEnum.Socket: switch (pointDefinition) { case PointDefinition.PointA: SocketConfigurationModel pointA = new SocketConfigurationModel { ListenEveryMilliseconds = defaults.ListenEveryMilliseconds, TimeoutInMilliseconds = 60000, IpAddress = defaults.IpAndPortA.Split(':')[0], IpPort = int.Parse(defaults.IpAndPortA.Split(':')[1]) }; return(new iCamCameraListener(new SocketListener(pointA))); case PointDefinition.PointB: SocketConfigurationModel pointB = new SocketConfigurationModel { ListenEveryMilliseconds = defaults.ListenEveryMilliseconds, TimeoutInMilliseconds = 60000, IpAddress = defaults.IpAndPortB.Split(':')[0], IpPort = int.Parse(defaults.IpAndPortB.Split(':')[1]) }; return(new iCamCameraListener(new SocketListener(pointB))); } break; case ListenerTypeEnum.Mock: switch (pointDefinition) { case PointDefinition.PointA: MockConfigurationModel modelStart = new MockConfigurationModel { ListenEveryMilliseconds = defaults.ListenEveryMilliseconds, TimeOffsetSecondsStart = 0, TimeOffsetSecondsEnd = 5, Seed = 1500, DeviceId = 1, DeviceName = "Mock Device A", LocationCode = "MockA" }; return(new MockCameraListener(new MockListener(modelStart))); case PointDefinition.PointB: MockConfigurationModel modelEnd = new MockConfigurationModel { ListenEveryMilliseconds = defaults.ListenEveryMilliseconds, TimeOffsetSecondsStart = 250, TimeOffsetSecondsEnd = 360, Seed = 2500, DeviceId = 2, DeviceName = "Mock Device B", LocationCode = "MockB" }; return(new MockCameraListener(new MockListener(modelEnd))); } break; case ListenerTypeEnum.Disk: switch (pointDefinition) { case PointDefinition.PointA: DiskConfigurationModel pointA = new DiskConfigurationModel { ListenEveryMilliseconds = defaults.ListenEveryMilliseconds, FilePath = Helper.PathPointA, SearchPattern = Helper.PathFilter }; return(new iCamCameraListener(new DiskListener(pointA))); case PointDefinition.PointB: DiskConfigurationModel pointB = new DiskConfigurationModel { ListenEveryMilliseconds = defaults.ListenEveryMilliseconds, FilePath = Helper.PathPointB, SearchPattern = Helper.PathFilter }; return(new iCamCameraListener(new DiskListener(pointB))); } break; } return(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}"); } }