Exemplo n.º 1
0
 public override void SetEventHandlerGameObject(GameObject obj)
 {
     if (manager == null)
     {
         manager = obj.GetComponent <VRC_CT_ScoreboardManager>();
     }
 }
Exemplo n.º 2
0
 public override void SetEvent(VRC_EventHandler.VrcEvent EventContents)
 {
     base.SetEvent(EventContents);
     if (EventContents.ParameterObject != null)
     {
         manager = EventContents.ParameterObject.GetComponent <VRC_CT_ScoreboardManager>();
     }
 }
Exemplo n.º 3
0
        public override void SetEventHandlerGameObject(UnityEngine.GameObject obj)
        {
            if (handler == null || !UseScoreboardHandler)
            {
                handler = obj.GetComponent <VRC_EventHandler>();
            }

            if (scoreboard == null)
            {
                scoreboard = obj.GetComponent <VRC_CT_ScoreboardManager>();
            }

            didLoad = handler != null && scoreboard != null && didLoad;
        }
Exemplo n.º 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;
        }