Example #1
0
		public void SetTargetBeing (ABeing _target) {
			Formula.SetTargetBeing (_target);
		}
Example #2
0
	public abstract void Apply(ABeing target);
Example #3
0
		public override void Apply (ABeing target)
		{
			this.SetTargetBeing (target);

			Dictionary<string, double> quantities = new Dictionary<string, double>();
			Dictionary<BEING_KEY, ABeing> destinations = new Dictionary<BEING_KEY, ABeing>();
			destinations.Add (BEING_KEY.SELF, mSelfBeing);
			destinations.Add (BEING_KEY.TARGET, target);
			double quantityForThisRun = MaxQuantityPerRun;

			foreach (InOutVariable v in mInOuts) {
				Variable var =  destinations[v.Destination].GetVariable (v.VariableName);

				// Compute quantity according to formula
				quantities.Add(v.VariableName, v.Formula.GetResult());

				if (!v.IsOutput) {
					//Computes the maximum amount of each ressource we can consume.
					quantityForThisRun = Math.Min (var.GetValue () / quantities [v.VariableName], quantityForThisRun);
				}
			}

			foreach (InOutVariable v in mInOuts) {
				Variable var =  destinations[v.Destination].GetVariable (v.VariableName);

				//Adjust quantity according to amount consumed or produced
				var.SetValue (var.GetValue () + quantityForThisRun * v.OutputFactor * quantities [v.VariableName]);
			}

			this.SetTargetBeing (null);
		}
Example #4
0
		public void SetSelfBeing (ABeing _self) {
			Formula.SetSelfBeing (_self);
			foreach(AValue v in Formula.GetAllBindedValues()) {
				v.Change += Refresh;
			}
		}
Example #5
0
		public void SetSelfBeing (ABeing _self)
		{
			Debug.Assert (mIsInitialized, 
				"Calling SetSelfBeing on a non-initialized formula on component " + Error.Hierarchy(mParent.GetComponent()));
			mSelf = _self;

			foreach (Parameter p in mParameters.Values) {
				if (p.beingKey == BEING_KEY.SELF) {
					if (_self == null) {
						p.bindedValue = null;
					} else {
						p.bindedValue = _self.GetValue (p.valueName);
					}
				}
			}
		}
Example #6
0
		public void SetTargetBeing (ABeing _target)
		{
			Debug.Assert (mIsInitialized, "Calling SetTargetBeing on Transformation " + Error.Hierarchy (this)
			+ " while it is not yet initialized"); 
			foreach (InOutVariable v in mInOuts) {
				v.Formula.SetSelfBeing (_target);
			}
		}
Example #7
0
		public override void Apply (ABeing target)
		{
			// TODO
		}
Example #8
0
		public override void Apply(ABeing target) {
			Debug.Log (Message);
		}
Example #9
0
//		protected Dictionary<string,ATrigger> trigger = new Dictionary<string, ATrigger> ();

		public void SetParentBeing(ABeing parent) {
			mParent = parent;
		}
Example #10
0
		public void Go(ABeing target) {
			foreach (AEffect effect in mEffects) {
				effect.Apply (target);
			}
		}
Example #11
0
		public void setParentBeing(ABeing parent) {
			parentBeing = parent;
		}