Example #1
0
        void Start()
        {
            Handler = gameObject.GetComponent <VRC_EventHandler>();

            if (EventTypesToUpdate.Count > 0)
            {
                ChurroHandler = gameObject.GetComponent <VRC_CT_EventHandler>();
            }
        }
Example #2
0
 private void UpdateChildren(GameObject obj)
 {
     for (int i = 0; i < obj.transform.childCount; i++)
     {
         VRC_CT_EventHandler handler = obj.transform.GetChild(i).GetComponent <VRC_CT_EventHandler>();
         if (handler != null)
         {
             handler.FindCustomEvents();
             handler.CustomEvents.UnionWith(events);
         }
         UpdateChildren(obj.transform.GetChild(i).gameObject);
     }
 }
Example #3
0
        public override void TriggerEvent()
        {
            if (didLoad)
            {
                if (Value1 != "")
                {
                    intValue1 = scoreboard.GetValue(Value1);
                }
                if (Value2 != "")
                {
                    intValue2 = scoreboard.GetValue(Value2);
                }

                bool returnTrue = false;

                if ((compareBehavior & LESS_THAN) == LESS_THAN)
                {
                    returnTrue |= intValue1 < intValue2;
                }
                if ((compareBehavior & GREATER_THAN) == GREATER_THAN)
                {
                    returnTrue |= intValue1 > intValue2;
                }
                if ((compareBehavior & EQUALS) == EQUALS)
                {
                    returnTrue |= intValue1 == intValue2;
                }

                if (returnTrue)
                {
                    handler.TriggerEvent(compareTrueEvent, VRC_EventHandler.VrcBroadcastType.Always);
                    VRC_CT_EventHandler.print("Trigger Event: " + compareTrueEvent);
                }
                else
                {
                    handler.TriggerEvent(compareFalseEvent, VRC_EventHandler.VrcBroadcastType.Always);
                    VRC_CT_EventHandler.print("Trigger Event: " + compareFalseEvent);
                }
            }
        }
Example #4
0
        public override void SetEvent(VRC_EventHandler.VrcEvent EventContents)
        {
            base.SetEvent(EventContents);
            string[] stringSplit = EventContents.ParameterString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            VRC_CT_EventHandler.print("StringSplit.Length = " + stringSplit.Length);

            if (EventContents.ParameterObject != null)
            {
                scoreboard = EventContents.ParameterObject.GetComponent <VRC_CT_ScoreboardManager>();
                handler    = EventContents.ParameterObject.GetComponent <VRC_EventHandler>();
            }

            if (stringSplit.Length < 5 || (stringSplit.Length == 4 && !(stringSplit[3].Equals(":") || stringSplit[3].Equals("?"))))
            {
                return;
            }

            Value1 = stringSplit[0];
            try
            {
                intValue1 = int.Parse(Value1);
                Value1    = "";
            }
            catch (Exception e) { }
            if (Value1 != "" && Value1.StartsWith("\"") && Value1.EndsWith("\""))
            {
                Value1 = Value1.Substring(1, Value1.Length - 2);
            }

            Value2 = stringSplit[2];
            try
            {
                intValue2 = int.Parse(Value2);
                Value2    = "";
            }
            catch (Exception e) { }
            if (Value2 != "" && Value2.StartsWith("\"") && Value2.EndsWith("\""))
            {
                Value2 = Value2.Substring(1, Value2.Length - 2);
            }

            if (Value1 == Value2)
            {
                return;
            }

            VRC_CT_EventHandler.print("Values have been found: " + (Value1 == "" ? intValue1.ToString() : Value1) + " and " + (Value2 == "" ? intValue2.ToString() : Value2));

            try
            {
                compareBehavior = int.Parse(stringSplit[1]);
                if (compareBehavior < 0)
                {
                    compareBehavior = 0;
                }
                else if (compareBehavior > 7)
                {
                    compareBehavior = 7;
                }
            }
            catch (Exception e)
            {
                if (stringSplit[1].Contains("<"))
                {
                    compareBehavior |= LESS_THAN;
                }
                if (stringSplit[1].Contains(">"))
                {
                    compareBehavior |= GREATER_THAN;
                }
                if (stringSplit[1].Contains("="))
                {
                    compareBehavior |= EQUALS;
                }
                if (stringSplit[1].Contains("!"))
                {
                    int newBehavior = 0;

                    if ((compareBehavior & LESS_THAN) == 0)
                    {
                        newBehavior |= LESS_THAN;
                    }

                    if ((compareBehavior & GREATER_THAN) == 0)
                    {
                        newBehavior |= GREATER_THAN;
                    }

                    if ((compareBehavior & EQUALS) == 0)
                    {
                        newBehavior |= EQUALS;
                    }
                    compareBehavior = newBehavior;
                }
            }

            // Operator Compiled: 0 - Always False, 1 - Less Than, 2 - Greater Than, 3 - Not,
            // 4 - Equals, 5 - Less Than or Equal To, 6 - Greater Than or Equal To, 7 - Always True

            if (stringSplit[3].Equals("?"))
            {
                // '?' and True Case
                compareTrueEvent = stringSplit[4];

                if (stringSplit.Length > 5)
                {
                    if (stringSplit[5].Equals(":") && stringSplit.Length > 6)
                    {
                        // ':' and False Case
                        compareFalseEvent = stringSplit[6];
                    }
                    else
                    {
                        // False Case
                        compareFalseEvent = stringSplit[5];
                    }
                }
            }
            else if (stringSplit[3].Equals(":"))
            {
                // ':' and False Case
                compareFalseEvent = stringSplit[4];
            }
            else
            {
                // True Case
                compareTrueEvent = stringSplit[3];

                if (stringSplit.Length > 4)
                {
                    if (stringSplit[4].Equals(":") && stringSplit.Length > 5)
                    {
                        // ':' False Case
                        compareFalseEvent = stringSplit[5];
                    }
                    else
                    {
                        // False Case
                        compareFalseEvent = stringSplit[4];
                    }
                }
            }

            didLoad = true;
        }