Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Assignment"/> class.
        /// </summary>
        public Assignment()
        {
            VariableSignature signature = RegistrationManager.SelectReadWriteVariableAtRandom();

            this.readWriteVariable = new ReadWriteVariable(signature);
            this.rightStatement    = new RightStatement(signature.VariableType);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Assignment"/> class.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public Assignment(FileIOManager reader)
        {
            string nextLine = reader.ReadNextContentLineAndTrim();

            if (CommonHelperMethods.StringStartsWith(nextLine, ReadWriteVariable.Name))
            {
                this.readWriteVariable = new ReadWriteVariable(reader);
            }
            else
            {
                CommonHelperMethods.ThrowStatementParseException(
                    nextLine,
                    reader,
                    ReadWriteVariable.Name);
            }

            nextLine = reader.ReadNextContentLineAndTrim();
            if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name))
            {
                this.rightStatement = new RightStatement(reader);
            }
            else
            {
                CommonHelperMethods.ThrowStatementParseException(
                    nextLine,
                    reader,
                    RightStatement.Name);
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.RightStatementOperation`1"/> class.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public RightStatementOperation(FileIOManager reader)
        {
            // Parse operator
            this.operatorSignature = new OperatorSignature(reader);

            // Parse left hand side
            string nextLine = reader.ReadNextContentLineAndTrim();

            if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name))
            {
                this.leftHandSide = new RightStatement(reader);
            }
            else
            {
                CommonHelperMethods.ThrowStatementParseException(
                    nextLine,
                    reader,
                    RightStatement.Name);
            }

            // Parse right hand side
            nextLine = reader.ReadNextContentLineAndTrim();
            if (CommonHelperMethods.StringStartsWith(nextLine, RightStatement.Name))
            {
                this.rightHandSide = new RightStatement(reader);
            }
            else
            {
                CommonHelperMethods.ThrowStatementParseException(
                    nextLine,
                    reader,
                    RightStatement.Name);
            }
        }
Exemple #4
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                this.rightStatement = new RightStatement(typeof(bool));
                return;
            }

            if (this.rightStatement != null)
            {
                this.rightStatement.PossiblyMutate();
            }
        }
Exemple #5
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                VariableSignature signature = RegistrationManager.SelectReadWriteVariableAtRandom();
                this.readWriteVariable = new ReadWriteVariable(signature);
                this.rightStatement    = new RightStatement(signature.VariableType);
                return;
            }

            if (this.rightStatement != null)
            {
                this.rightStatement.PossiblyMutate();
            }
        }
Exemple #6
0
        /// <summary>
        /// Will possibly mutate this section of logic.
        /// </summary>
        public void PossiblyMutate()
        {
            if (GeneticLogicRoot.RollMutateDice())
            {
                OperatorSignature signature;
                if (RegistrationManager.TrySelectOperatorAtRandom(this.ReturnType, out signature))
                {
                    this.operatorSignature = signature;
                    this.leftHandSide      = new RightStatement(signature.LhsType);
                    this.rightHandSide     = new RightStatement(signature.RhsType);
                    return;
                }
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.rightHandSide = new RightStatement(this.operatorSignature.RhsType);
                return;
            }

            if (GeneticLogicRoot.RollMutateDice())
            {
                this.leftHandSide = new RightStatement(this.operatorSignature.LhsType);
                return;
            }

            if (this.rightHandSide != null)
            {
                this.rightHandSide.PossiblyMutate();
            }

            if (this.leftHandSide != null)
            {
                this.leftHandSide.PossiblyMutate();
            }
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.RightStatementOperation"/> class.
 /// </summary>
 /// <param name="returnType">Return type.</param>
 public RightStatementOperation(OperatorSignature signature)
 {
     this.operatorSignature = signature;
     this.leftHandSide      = new RightStatement(signature.LhsType);
     this.rightHandSide     = new RightStatement(signature.RhsType);
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Condition"/> class.
 /// </summary>
 public Condition()
 {
     this.rightStatement = new RightStatement(typeof(GeneticBool));
 }
Exemple #9
0
        /// <summary>
        /// Writes to this variable.
        /// </summary>
        /// <param name="instance">The instance to execute against.</param>
        /// <param name="payload">The value to write.</param>
        public void WriteToVariable(ref EntBehaviorManager instance, RightStatement payload)
        {
            GeneticObject value = payload.Evaluate(ref instance);

            instance.WriteToVariable(this.signature, value);
        }