Example #1
0
            public bool TryInvoke(object inTarget, IReadOnlyList <object> inArguments, object inContext, out object outReturnValue)
            {
                if (inArguments.Count < m_RequiredParameterCount || inArguments.Count >= m_Parameters.Length)
                {
                    UnityEngine.Debug.LogErrorFormat("[MethodCache] Expected between {0} and {1} arguments to {2}::'{3}', got {4} instead",
                                                     m_RequiredParameterCount, m_Parameters.Length - m_ContextOffset, Method.DeclaringType.Name, Id.ToDebugString(), inArguments.Count);

                    outReturnValue = null;
                    return(false);
                }

                for (int i = 0; i < inArguments.Count; ++i)
                {
                    try
                    {
                        m_Arguments[i + m_ContextOffset] = Convert.ChangeType(inArguments[i], m_Parameters[i + m_ContextOffset].ParameterType);
                    }
                    catch (Exception e)
                    {
                        UnityEngine.Debug.LogException(e);
                        UnityEngine.Debug.LogErrorFormat("[MethodCache] Unable to convert object {0} to expected type {1}", inArguments[i], m_Parameters[i + m_ContextOffset].ParameterType.Name);
                        outReturnValue = null;
                        return(false);
                    }
                }

                return(DoInvoke(inTarget, inArguments.Count + m_ContextOffset, inContext, out outReturnValue));
            }
Example #2
0
 public string ToDebugString()
 {
     return(string.Format("{0}({1})", Id.ToDebugString(), Args));
 }
Example #3
0
        public bool Test(Collider2D inCollider, StringHash32 inId)
        {
            GOFilterEntry entry;

            if (!m_EntryMap.TryGetValue(inId, out entry))
            {
                Debug.LogErrorFormat("[GOFilterSet] Cannot find filter with id '{0}'", inId.ToDebugString());
                return(false);
            }

            return(entry.Evaluate(inCollider));
        }
Example #4
0
        /// <summary>
        /// Disables the filter with the given id.
        /// </summary>
        public void Disable(StringHash32 inId)
        {
            GOFilterEntry entry;

            if (!m_EntryMap.TryGetValue(inId, out entry))
            {
                Debug.LogErrorFormat("[GOFilterSet] Cannot find filter with id '{0}'", inId.ToDebugString());
                return;
            }

            entry.Enabled = false;
        }
Example #5
0
        /// <summary>
        /// Returns the filter with the given id.
        /// </summary>
        public TFilter GetFilter(StringHash32 inId)
        {
            GOFilterEntry entry;

            if (!m_EntryMap.TryGetValue(inId, out entry))
            {
                Debug.LogErrorFormat("[GOFilterSet] Cannot find filter with id '{0}'", inId.ToDebugString());
                return(null);
            }

            return(entry.Filter);
        }
Example #6
0
        /// <summary>
        /// Adds a new filter with the given id.
        /// </summary>
        public TFilter Add(StringHash32 inId)
        {
            if (m_EntryMap.ContainsKey(inId))
            {
                throw new ArgumentException(string.Format("A filter with the given id '{0}' already exists!", inId.ToDebugString()), "inId");
            }

            GOFilterEntry entry = new GOFilterEntry(inId);

            m_SortedEntryList.Add(entry);
            m_EntryMap.Add(inId, entry);
            m_Cached = false;
            return(entry.Filter);
        }