Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.LeftStatement"/> class.
        /// </summary>
        public LeftStatement()
        {
            double nextDouble = CommonHelperMethods.GetRandomDouble0To1();

            if (nextDouble < 0.5)
            {
                MethodSignature signature = RegistrationManager.SelectLeftMethodAtRandom();
                this.leftMethodCall = new LeftMethodCall(signature);
            }
            else
            {
                this.assignment = new Assignment();
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.LeftStatement"/> class.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public LeftStatement(FileIOManager reader)
        {
            string nextLine = reader.ReadNextContentLineAndTrim();

            if (CommonHelperMethods.StringStartsWith(nextLine, LeftMethodCall.Name))
            {
                this.leftMethodCall = new LeftMethodCall(reader);
            }
            else if (CommonHelperMethods.StringStartsWith(nextLine, Assignment.Name))
            {
                this.assignment = new Assignment(reader);
            }
            else
            {
                CommonHelperMethods.ThrowStatementParseException(
                    nextLine,
                    reader,
                    new List <string>()
                {
                    LeftMethodCall.Name, Assignment.Name
                });
            }
        }
Example #3
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                MethodSignature signature = RegistrationManager.SelectLeftMethodAtRandom();
                this.leftMethodCall = new LeftMethodCall(signature);
                this.assignment     = null;
                return;
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.leftMethodCall = null;
                this.assignment     = new Assignment();
                return;
            }

            // Note: Method calls and variables are possibly replaced, but not themselves mutated.
            if (this.assignment != null)
            {
                this.assignment.PossiblyMutate();
            }
        }