Ejemplo n.º 1
0
        public bool TryProcess(TagData inData, object inContext, out TagEventData outEvent)
        {
            EventRule rule = m_EventRules.FindMatch(inData.Id);

            if (rule != null)
            {
                return(rule.Evaluate(inData, inContext, out outEvent));
            }

            if (m_EventInheritFrom != null)
            {
                return(m_EventInheritFrom.TryProcess(inData, inContext, out outEvent));
            }

            outEvent = default(TagEventData);
            return(false);
        }
Ejemplo n.º 2
0
        public bool TryEvaluate(TagEventData inEventData, object inContext, out IEnumerator outCoroutine)
        #endif // EXPANDED_REFS
        {
            StringHash32 id = inEventData.Type;
            Handler      handler;

            if (m_Handlers.TryGetValue(id, out handler))
            {
                outCoroutine = handler.Execute(inEventData, inContext);
                return(true);
            }

            if (m_Base != null)
            {
                return(m_Base.TryEvaluate(inEventData, inContext, out outCoroutine));
            }

            Debug.LogErrorFormat("[TagStringEventHandler] Unable to handle event type '{0}'", id.ToDebugString());
            outCoroutine = null;
            return(false);
        }
Ejemplo n.º 3
0
            internal bool Evaluate(TagData inData, object inContext, out TagEventData outEvent)
            {
                outEvent           = new TagEventData(m_EventId);
                outEvent.IsClosing = inData.IsClosing();

                switch (m_DataMode)
                {
                case DataMode.String:
                {
                    if (inData.Data.IsEmpty)
                    {
                        outEvent.StringArgument = m_DefaultString;
                    }
                    else
                    {
                        outEvent.StringArgument = inData.Data;
                    }
                    break;
                }

                case DataMode.Float:
                {
                    float arg;
                    if (!StringParser.TryParseFloat(inData.Data, out arg))
                    {
                        arg = m_DefaultValue.AsFloat();
                    }
                    outEvent.Argument0 = arg;
                    break;
                }

                case DataMode.Bool:
                {
                    bool arg;
                    if (!StringParser.TryParseBool(inData.Data, out arg))
                    {
                        arg = m_DefaultValue.AsBool();
                    }
                    outEvent.Argument0 = arg;
                    break;
                }

                case DataMode.StringHash:
                {
                    StringHash32 arg;
                    if (!StringHash32.TryParse(inData.Data, out arg))
                    {
                        arg = m_DefaultValue.AsStringHash();
                    }
                    outEvent.Argument0 = arg;
                    break;
                }
                }

                if (m_HandleClosing && outEvent.IsClosing)
                {
                    outEvent.Type = m_EventClosingId;
                    if (m_EventClosingDelegate != null)
                    {
                        m_EventClosingDelegate(inData, inContext, ref outEvent);
                    }

                    return(true);
                }
                else
                {
                    if (m_EventDelegate != null)
                    {
                        m_EventDelegate(inData, inContext, ref outEvent);
                    }

                    return(true);
                }
            }