public static IEnumerable <int> GetAllUsedIDs(int packID) { List <int> used = new List <int>(); IEnumerable <Event> allEvents = EditorUtils.GetAllAssetsOfType <Event>(); foreach (var e in allEvents) { if (e.mainPackID == packID) { for (int i = 0; i < e.allStates.Length; i++) { GetAOIDs(e.allStates[i], used);//, packID); } } } if (used.Count == 0) { Debug.LogWarning("no IDs used for " + PacksManager.ID2Name(packID) + " pack!"); } return(used); }
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; }