/// <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, int depthIn) { this.depth = depthIn; byte nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.ReadWriteVariable) { this.readWriteVariable = new ReadWriteVariable(reader); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.ReadWriteVariable); } nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.RightStatement) { this.rightStatement = new RightStatement(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.RightStatement); } }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Assignment"/> class. /// </summary> public Assignment(int depthIn) { this.depth = depthIn; VariableSignature signature = RegistrationManager.SelectReadWriteVariableAtRandom(); this.readWriteVariable = new ReadWriteVariable(signature); this.rightStatement = new RightStatement(signature.VariableType, depthIn + 1); }
/// <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, int depthIn) { this.depth = depthIn; this.operatorSignature = signature; this.leftHandSide = new RightStatement(signature.LhsType, depthIn + 1); this.rightHandSide = new RightStatement(signature.RhsType, depthIn + 1); }
/// <summary> /// Will possibly mutate this section of logic. /// </summary> public void PossiblyMutate() { if (GeneticLogicRoot.RollMutateDice()) { this.rightStatement = new RightStatement(GeneticTypeEnum.GeneticBool, this.depth + 1); return; } if (this.rightStatement != null) { this.rightStatement.PossiblyMutate(); } }
/// <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, this.depth + 1); return; } if (this.rightStatement != null) { this.rightStatement.PossiblyMutate(); } }
/// <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, int depthIn) { this.depth = depthIn; // Parse operator this.operatorSignature = new OperatorSignature(reader); // Parse left hand side byte nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.RightStatement) { this.leftHandSide = new RightStatement(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.RightStatement); } // Parse right hand side nextByte = reader.ReadByte(); if (nextByte == StatementTypeEnum.RightStatement) { this.rightHandSide = new RightStatement(reader, depthIn + 1); } else { CommonHelperMethods.ThrowStatementParseException( nextByte, reader, StatementTypeEnum.RightStatement); } }
/// <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.depth + 1); this.rightHandSide = new RightStatement(signature.RhsType, this.depth + 1); return; } } if (GeneticLogicRoot.RollMutateDice()) { this.rightHandSide = new RightStatement(this.operatorSignature.RhsType, this.depth + 1); return; } if (GeneticLogicRoot.RollMutateDice()) { this.leftHandSide = new RightStatement(this.operatorSignature.LhsType, this.depth + 1); return; } if (this.rightHandSide != null) { this.rightHandSide.PossiblyMutate(); } if (this.leftHandSide != null) { this.leftHandSide.PossiblyMutate(); } }
/// <summary> /// Initializes a new instance of the <see cref="AssemblyCSharp.Scripts.EntLogic.SerializationObjects.Condition"/> class. /// </summary> public Condition(int depthIn) { this.depth = depthIn; this.rightStatement = new RightStatement(GeneticTypeEnum.GeneticBool, depthIn + 1); }
/// <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) { byte value = payload.Evaluate(ref instance); instance.WriteToVariable(this.signature, value); }