Пример #1
0
        public void GetAssetObjects(EventResponse eventResponse, Dictionary <string, CustomParameter> parameters)
        {
            int l = assetObjects.Length;

            for (int i = 0; i < l; i++)
            {
                AssetObject ao = assetObjects[i];
                if (ao.solo)
                {
                    eventResponse.chosenObjects.Clear();

                    if (CustomScripting.StatementValue(ao.conditionBlock, parameters, ref eventResponse.logErrors, ref eventResponse.logWarnings))
                    {
                        eventResponse.chosenObjects.Add(assetObjects[i]);
                    }

                    break;
                }
                if (!ao.mute)
                {
                    if (CustomScripting.StatementValue(ao.conditionBlock, parameters, ref eventResponse.logErrors, ref eventResponse.logWarnings))
                    {
                        eventResponse.chosenObjects.Add(assetObjects[i]);
                    }
                }
            }
        }
Пример #2
0
 void GetFilteredStates(EventState eventState, Dictionary <string, CustomParameter> parameters, EventResponse eventResponse)
 {
     if (CustomScripting.StatementValue(eventState.conditionBlock, parameters, ref eventResponse.logErrors, ref eventResponse.logWarnings))
     {
         eventState.GetAssetObjects(eventResponse, parameters);
         int l = eventState.subStatesIDs.Length;
         for (int i = 0; i < l; i++)
         {
             GetFilteredStates(allStates[id2State[eventState.subStatesIDs[i]]], parameters, eventResponse);
         }
     }
 }
Пример #3
0
            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;
            }