Example #1
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, int depthIn)
        {
            this.depth = depthIn;

            byte nextByte = reader.ReadByte();

            if (nextByte == StatementTypeEnum.LeftMethodCall)
            {
                this.leftMethodCall = new LeftMethodCall(reader, depthIn + 1);
            }
            else if (nextByte == StatementTypeEnum.Assignment)
            {
                this.assignment = new Assignment(reader, depthIn + 1);
            }
            else
            {
                CommonHelperMethods.ThrowStatementParseException(
                    nextByte,
                    reader,
                    new List <byte>()
                {
                    StatementTypeEnum.LeftMethodCall, StatementTypeEnum.Assignment
                });
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.LeftStatement"/> class.
        /// </summary>
        public LeftStatement(int depthIn)
        {
            this.depth = depthIn;

            double nextDouble = CommonHelperMethods.GetRandomDouble0To1();

            if (nextDouble < 0.5)
            {
                MethodSignature signature = RegistrationManager.SelectLeftMethodAtRandom();
                this.leftMethodCall = new LeftMethodCall(signature, depthIn + 1);
            }
            else
            {
                this.assignment = new Assignment(depthIn + 1);
            }
        }
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.depth + 1);
                this.assignment     = null;
                return;
            }

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

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