static void BroadcastMessage(int playerLayer, EventPlayer receiver, string message, Vector3 runtimePosition, ref string logErrors) { string[] split = message.Split('('); string msgName = split[0]; string paramsS = split[1]; int l = paramsS.Length; int lastIndex = l - 1; if (lastIndex == 0) { receiver.SendMessage(msgName, new object[] { playerLayer }, SendMessageOptions.RequireReceiver); return; } string allParamsString = paramsS.Substring(0, lastIndex); bool isMultipleParams = allParamsString.Contains(","); string[] parameterStrings = isMultipleParams ? allParamsString.Split(',') : new string[] { allParamsString }; object[] parameters = new object[parameterStrings.Length + 1]; parameters[0] = playerLayer; for (int i = 1; i < parameters.Length; i++) { parameters[i] = ParamFromString(parameterStrings[i - 1], runtimePosition, ref logErrors); } receiver.SendMessage(msgName, parameters, SendMessageOptions.RequireReceiver); }
void InitializeEventPlayer() { eventPlayer = GetComponent <EventPlayer>(); //tell the event player to call this component's "Use Asset Object" method //whenever it plays an event that uses the pack name eventPlayer.LinkAsPlayer(ListenForPackName(), UseAssetObject); }
public static void InitializePerformance(string debugReason, Event[] events, EventPlayer player, bool looped, int playerLayer, MiniTransform transforms, bool forceInterrupt = true, Action[] onEndPerformanceCallbacks = null) { Playlists.Performance.playlistPerformances.GetNewPerformance().InitializePerformance( true, debugReason, playerLayer, new Channel[] { new Channel(events) }, new EventPlayer[] { player }, transforms, looped, forceInterrupt, onEndPerformanceCallbacks ); }
public static void ExecuteMessageBlock(int playerLayer, EventPlayer receiver, string messageBlock, Vector3 runtimePosition, ref string logErrors) { messageBlock = StripAllSpace(messageBlock); if (messageBlock == null || messageBlock.IsEmpty()) { return; } if (!messageBlock.Contains(";")) { #if UNITY_EDITOR logErrors += (" :: missing ';' in message block" + "\n\n"); #endif return; } string[] individualMessages = messageBlock.Split(';'); //skip last empty int l = individualMessages.Length - 1; for (int i = 0; i < l; i++) { BroadcastMessage(playerLayer, receiver, individualMessages[i], runtimePosition, ref logErrors); } }
public static void InitializePerformance(string debugReason, CueBehavior playlists, EventPlayer players, bool looped, int playerLayer, MiniTransform transforms, bool forceInterrupt = true, Action onEndPerformanceCallbacks = null) { InitializePerformance(debugReason, new CueBehavior[] { playlists }, new EventPlayer[] { players }, looped, playerLayer, transforms, forceInterrupt, new Action[] { onEndPerformanceCallbacks }); }
bool PlayEvent( MiniTransform transforms, EventPlayer myPlayer, Dictionary <int, PlayerMessage> pack2playEvents, Dictionary <string, CustomParameter> paramDict, Event e, bool isMainEvent, bool asInterrupter, bool endAfterDuration) { int packID = e.mainPackID; if (skipPlays.Contains(packID)) { return(false); } EventResponse eventResponse = new EventResponse();//skipPlays); e.GetParamFilteredObjects(paramDict, eventResponse); eventResponse.LogErrors(); eventResponse.LogWarnings(); // bool mainFound = !eventResponse.noMainFound; // foreach (var k in eventResponse.objectsPerPack.Keys) { // bool isMainPack = k == e.mainPackID; // List<AssetObject> list = eventResponse.objectsPerPack[k]; List <AssetObject> list = eventResponse.chosenObjects; if (list.Count > 0) { AssetObject o = list.RandomChoice(); if (!endAfterDuration) { // if (isMainPack && isMainEvent) { if (isMainEvent) { SetDuration(o["Duration"].GetValue <float>()); // current_duration = o["Duration"].GetValue<float>(); } } HashSet <Action> endUseSuccessCBs = new HashSet <Action>(); if (!endAfterDuration) { //give control to object when it's the main event //and when the duration is < 0 and not overriden // if (isMainEvent && isMainPack) { if (isMainEvent) { endUseSuccessCBs.Add(() => { EndPlayAttempt(true, "controlled"); }); } } string logErrors = ""; CustomScripting.ExecuteMessageBlock(myLayer, myPlayer, o.messageBlock, Vector3.zero, ref logErrors); if (!logErrors.IsEmpty()) { logErrors = "Broadcast message from asset object: " + o.objRef.name + "\n" + logErrors; Debug.LogError(logErrors); } int k = packID; if (!pack2playEvents.ContainsKey(k)) { Debug.LogError("skipping " + PacksManager.ID2Name(k) + " not connected to player"); return(false); } pack2playEvents[k](o, asInterrupter, transforms, endUseSuccessCBs); } return(list.Count > 0);// mainFound; }
public void PlayEvents( string eventsHolder, MiniTransform transforms, EventPlayer myPlayer, Dictionary <int, PlayerMessage> pack2playEvents, Dictionary <string, CustomParameter> paramDict, Event[] events, float overrideDuration, bool asInterrupter ) { //Debug.Log("playing cue"); playing = true; duration_timer = 0; SetDuration(overrideDuration); // if (current_duration >= 0) Debug.Log("set current duration to :: " + current_duration); bool endAfterDuration = current_duration >= 0; // bool endPlayAttemptHandled = current_duration >= 0;// || endPlayOverriden; int l = 0; if (events != null) { l = events.Length; } bool successPlay = true; if (events != null) { bool isMainEvent = true; foreach (var e in events) { bool success = PlayEvent(transforms, myPlayer, pack2playEvents, paramDict, e, isMainEvent, asInterrupter, endAfterDuration); if (isMainEvent && !success) { successPlay = false; } isMainEvent = false; } } skipPlays.Clear(); if (!successPlay) { if (current_duration < 0) { // Debug.Log("not succes end " + eventsHolder); EndPlayAttempt(false, " coulnt find any"); } } else { if (l == 0 && !endAfterDuration) // !endPlayAttemptHandled) { //if (endPlayOverriden) Debug.Log("reason " + endPlayOverrideReason); // Debug.Log("zero events not event handled early out " + eventsHolder); { EndPlayAttempt(true, "no events specified"); } } }