public void SetTransfer(UrbEnvironmentCondition i, float value) { if (this.Conditions.Length > (uint)i) { Transfer[(uint)i] = value; } }
void PerformConditionFlow(UrbEnvironmentCondition targetCond, UrbTile[] Adjacency) { float startingCondition = this[targetCond]; int IDBestTile = -1; float AbsBestPull = 0; float BestPull = 0; for (int i = 0; i < Adjacency.Length; i++) { if (Adjacency[i] == null) { continue; } float Pull = Adjacency[i].Environment.GetPull(targetCond, startingCondition); float AbsPull = Mathf.Abs(Pull); if (AbsBestPull < AbsPull) { IDBestTile = i; AbsBestPull = AbsPull; BestPull = Pull; } } if (IDBestTile > -1 && AbsBestPull > float.Epsilon) { float Push = Transfer[(int)targetCond] * BestPull * 0.5f; Adjacency[IDBestTile].Environment[targetCond] -= Push; this[targetCond] += Push; } }
public float this[UrbEnvironmentCondition i] { get { return(this.Conditions.Length > (uint)i ? this.Conditions[(uint)i] : 0); } set { if (this.Conditions.Length < (uint)i) { return; } this.Conditions[(uint)i] = value; Dirty = true; } }
float GetPull(UrbEnvironmentCondition targetCond, float Value) { float Diff = this[targetCond] - Value; return(Diff * Transfer[(int)targetCond]); }