static void BroadcastMessageToPlayer(int layer, EventPlayer player, MiniTransform runtimeTransform, CueBehavior cueBehavior, Cue.MessageEvent messageEvent) { if (cueBehavior == null) { return; } string stepBlock = cueBehavior.messageBlocks[(int)messageEvent]; string logErrors = ""; CustomScripting.ExecuteMessageBlock(layer, player, stepBlock, runtimeTransform.pos, ref logErrors); if (!logErrors.IsEmpty()) { logErrors = (0, cueBehavior.name + " broadcast message " + messageEvent.ToString()) + logErrors; Debug.LogError(logErrors); } }
public void InitializePerformance(bool isTopLevel, string debugReason, int useLayer, Playlist.Channel[] playlistChannels, EventPlayer[] players, MiniTransform transforms, bool looped, bool forceInterrupt, System.Action[] onEndPerformance) { this.suppliedTransform = transforms; this.playlistChannels = playlistChannels; this.isTopLevel = isTopLevel; this.onEndPerformance = onEndPerformance; this.looped = looped; this.useLayer = useLayer; this.forceInterrupt = forceInterrupt; this.debugReason = debugReason; this.players = players; if (forceInterrupt) { for (int i = 0; i < players.Length; i++) { players[i].InterruptLayer(useLayer, debugReason); } } int channelsCount = playlistChannels.Length; for (int i = 0; i < channelsCount; i++) { players[i].currentPlaylists.Add(this); } if (channels.Length != channelsCount) { channels = channelsCount.Generate(i => new PerformanceChannel()).ToArray(); } ReInitializeChannels(); coroutineHandler.StartCoroutine(UpdatePerformance()); }
public void OnStart(bool isTopLevel, Playlist.Channel playlistChannel, Cue cue, CueBehavior cueBehavior, Event[] aoEvents, int layer, EventPlayer player, MiniTransform suppliedTransform) { this.cueBehavior = cueBehavior; this.player = player; this.layer = layer; this.playImmediate = cueBehavior != null && cueBehavior.playImmediate; isActive = true; posReady = true; isPlaying = false; // if we're loading a sub cue of a cue playlist if (!isTopLevel) { Vector3 posOffset = cueBehavior != null ? cueBehavior.positionOffset : Vector3.zero; Vector3 rotOffset = cueBehavior != null ? cueBehavior.rotationOffset : Vector3.zero; Vector3 lPos = cue.transform.localPosition; if (posOffset != Vector3.zero) { lPos += posOffset; } Quaternion lRot = cue.transform.localRotation; if (rotOffset != Vector3.zero) { lRot = Quaternion.Euler(lRot.eulerAngles + rotOffset); } suppliedTransform = new MiniTransform(suppliedTransform.pos + (suppliedTransform.rot * lPos), suppliedTransform.rot * lRot); } this.runtimeTransform = suppliedTransform; BroadcastMessageToPlayer(layer, player, runtimeTransform, cueBehavior, Cue.MessageEvent.OnStart); InitializeSnap(); }
public void InitializeChannel(bool isTopLevel, int layer, EventPlayer player, Playlist.Channel playlistChannel, MiniTransform suppliedTransform, Performance performance) { this.playlistChannel = playlistChannel; this.player = player; //only if it has subcues if (playlistChannel.useRandomChoice) { List <int> enabledIndicies = new List <int>(); for (int i = 0; i < playlistChannel.cues.Length; i++) { if (playlistChannel.cues[i].gameObject.activeSelf) { enabledIndicies.Add(i); } i++; } cueIndex = enabledIndicies.RandomChoice(); } else { cueIndex = 0; } if (!isTopLevel) { if (SkipAheadPastDisabledCues(performance)) { return; } } curCueRepeats = 0; isActive = true; head.OnStart(isTopLevel, playlistChannel, GetCurrentCue(), GetCurrentCueBehavior(), GetCurrentPlayingEvents(), layer, player, suppliedTransform); }
public void OnCueEnd(int channelIndex, bool isTopLevel, int layer, Performance performance, MiniTransform suppliedTransform) { if (playlistChannel.cues == null) { OnPerformanceEnd(performance, false); return; } curCueRepeats++; Cue cueAtIndex = playlistChannel.cues[cueIndex]; // repeat again if (curCueRepeats < cueAtIndex.repeats) { head.OnStart(isTopLevel, playlistChannel, cueAtIndex, cueAtIndex.behavior, null, layer, player, suppliedTransform); return; } //only playing one random one, and we're done repeating it, so end if (playlistChannel.useRandomChoice) { OnPerformanceEnd(performance, false); return; } curCueRepeats = 0; cueIndex++; if (SkipAheadPastDisabledCues(performance)) { return; } cueAtIndex = playlistChannel.cues[cueIndex]; head.OnStart(isTopLevel, playlistChannel, cueAtIndex, cueAtIndex.behavior, null, layer, player, suppliedTransform); }
// HashSet<System.Action> endUseCallbacks; /* * called when the attached event player plays an * "Animations" event and chooses an appropriate asset object * * endUseCallbacks should be called whenever the animation is done * * in this case, this component tracks when the animator is exiting an animation * that has been played */ protected override void UseAssetObject(AssetObject assetObject, bool asInterrupter, MiniTransform transforms, HashSet <System.Action> endUseCallbacks) { bool looped = assetObject["Looped"].GetValue <bool>(); int layer = assetObject["Layer"].GetValue <int>(); if (!looped) { if (this.endUseCallbacksPerLayer[layer] != null && this.endUseCallbacksPerLayer[layer].Count != 0) { // Debug.Log("clearing old callbacks"); this.endUseCallbacksPerLayer[layer].Clear(); } this.endUseCallbacksPerLayer[layer] = endUseCallbacks; // if (this.endUseCallbacks != null && this.endUseCallbacks.Count != 0) { // Debug.Log("clearing old callbacks"); // this.endUseCallbacks.Clear(); // } // this.endUseCallbacks = endUseCallbacks; } //get asset object parameter values int mirrorMode = assetObject["Mirror"].GetValue <int>(); bool mirror = (mirrorMode == 2) ? Random.value < .5f : mirrorMode == 1; float timeOffset = assetObject["TimeOffset"].GetValue <float>(); AnimationClip clip = assetObject.objRef as AnimationClip;// ((AnimationClip)assetObject.objRef); if (timeOffset != 0) { if (clip != null) { timeOffset = timeOffset * clip.length; } else { timeOffset = 0; } } Play( clip, assetObject.id, asInterrupter, mirror, looped, //if null clip and assetObject["Transition"].GetValue <float>(), assetObject["Speed"].GetValue <float>(), layer, timeOffset ); if (looped) { if (assetObject.objRef != null) { // Debug.Log("playing loop: " + assetObject.objRef.name); } //BroadcastEndUse(); //dont leave loops hanging } else { lastPlayed = assetObject.objRef.name; Debug.Log("playing: " + assetObject.objRef.name); // Debug.Break(); } }
static void InitializePerformanceInternal(string debugReason, int useLayer, Cue playlist, EventPlayer player, MiniTransform transforms, bool forceInterrupt, System.Action onEndPerformanceCallback) { Performance.playlistPerformances.GetNewPerformance().InitializePerformance( false, debugReason, useLayer, new Playlist.Channel[] { new Playlist.Channel(playlist, false) }, new EventPlayer[] { player }, transforms, false, forceInterrupt, new System.Action[] { onEndPerformanceCallback } ); }
/* * called when the attached event player plays a * "ParticleFX" event and chooses an appropriate asset object */ protected override void UseAssetObject(AssetObject assetObject, bool asInterrupter, MiniTransform transforms, HashSet <System.Action> endUseCallbacks) { //speed, start width, end width, color, length, light color, light intensity, light range // float speed = assetObject["Speed"].GetValue<float>(); // float scale = assetObject["Scale"].GetValue<float>(); // ParticleSystem ps = GetParticleSystem(assetObject.objRef); // ps.transform.position = transforms.pos; // ps.transform.rotation = transforms.rot; // if (transforms.targetParent != null) { // ps.transform.SetParent(transforms.targetParent); // } // ps.transform.localScale = Vector3.one * scale; // ParticleSystem.MainModule m = ps.main; // m.simulationSpeed = speed; // //ps.main = m; // ps.Play(); // //end use immediately // if (endUseCallbacks != null) { // foreach (var endUse in endUseCallbacks) { // endUse(); // } // } }