コード例 #1
0
 public void SetTransfer(UrbEnvironmentCondition i, float value)
 {
     if (this.Conditions.Length > (uint)i)
     {
         Transfer[(uint)i] = value;
     }
 }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
    float GetPull(UrbEnvironmentCondition targetCond, float Value)
    {
        float Diff = this[targetCond] - Value;

        return(Diff * Transfer[(int)targetCond]);
    }