コード例 #1
0
ファイル: MHLink.cs プロジェクト: mcgoober/mheg-dotnet
        // Check this link to see if the event matches the requirements.  If the link does not specify
        // any event data the link fires whatever the value of the data.
        public void MatchEvent(MHObjectRef sourceRefRef, int ev, MHUnion evData, MHEngine engine)
        {
            Logging.Assert(RunningStatus); // Should now be true if we call this.
            if (RunningStatus && m_nEventType == ev && sourceRefRef.Equal(m_EventSource, engine))
            {                              // Source and event type match.
                bool fMatch = false;
                switch (m_EventData.Type)
                {
                case MHUnion.U_None: fMatch = true; break; // No data specified - always matches.

                case MHUnion.U_Bool: evData.CheckType(MHUnion.U_Bool);
                    fMatch = evData.Bool == m_EventData.Bool; break;

                case MHUnion.U_Int: evData.CheckType(MHUnion.U_Int); fMatch = evData.Int == m_EventData.Int; break;

                case MHUnion.U_String: evData.CheckType(MHUnion.U_String); fMatch = evData.String.Equal(m_EventData.String); break;

                default: Logging.Log(Logging.MHLogWarning, "Unmatched Event: " + m_EventData.Type); Logging.Assert(false); break; // Should only be the above types.
                }
                // Fire the link
                if (fMatch)
                {
                    Logging.Log(Logging.MHLogLinks, "Link fired - " + m_ObjectIdentifier.Printable());
                    engine.AddActions(m_LinkEffect);
                }
            }
        }