Exemplo n.º 1
0
		public CalculationCommand(AsmInterpreter interpreter, string[] lineParts)
			: base(interpreter, lineParts)
		{
			string operatorName = lineParts[0];
			string targetName = lineParts[1];
			string sourceName = lineParts[2];

			CalculationDelegate delegation = GetCalculationDelegation(operatorName);
			if (delegation == null)
				throw new InvalidOperationException("Invalid calculation operator.");
			calc = delegation;

			ValueStorage vs = null;
			vs = parent.GetVariableByName(sourceName);
			if (vs == null)
			{
				vs = parent.GetRegisterByName(sourceName);
				if (vs == null)
				{
					vs = parent.GetStackValueFromTop(sourceName);
					if (vs == null)
					{
						float number = 0.0f;
						if (float.TryParse(sourceName, out number))
						{
							vs = new ValueStorage();
							vs.SetValue(number);
							parent.m_constants.Add(vs);
						}
					}
				}
			}
			if (vs == null)
				throw new InvalidOperationException("Invalid calculation operand.");
			operand = vs;

			vs = parent.GetVariableByName(targetName);
			if (vs == null)
			{
				vs = parent.GetRegisterByName(targetName);
				if (vs == null)
				{
					vs = parent.GetStackValueFromTop(targetName);
				}
			}
			if (vs == null)
				throw new InvalidOperationException("Invalid calculation target.");
			target = vs;
		}
Exemplo n.º 2
0
 public TalentBonusCalculatedFromMethod(TalentDelegate talent, CalculationDelegate calculation)
     : base(talent)
 {
     _calculation = calculation;
 }
Exemplo n.º 3
0
 public TalentBonusCalculatedFromMethod(TalentDelegate talent, CalculationDelegate calculation)
     : base(talent)
 {
     _calculation = calculation;
 }
Exemplo n.º 4
0
        public void StartCalculation(int count) 
        {
            lock (this) 
            {
                if (_calcState == CalculationStatus.NotCalculating) 
                {
                    CalculationDelegate calc = new CalculationDelegate(Calculation);

                    calc.BeginInvoke(count, new AsyncCallback(EndCalculate), calc); 
                }
            }
        }