Ejemplo n.º 1
0
    public override void Awake()
    {
        Stomach      = new UrbComposition();
        FoodScents   = UrbSubstances.Scent(FoodSubstances);
        DetectedFood = new List <UrbBody>();

        base.Awake();
    }
Ejemplo n.º 2
0
    public UrbScentTag[] GetScent()
    {
        if (Dirty)
        {
            List <UrbScentTag> ScentList = new List <UrbScentTag>();

            /* TODO: This may never be the prefered solution but it has some logic to it.
             * if (Membrane != null && Membrane.Layers != null && Membrane.Layers.Length > 0)
             * {
             *  for(int i = 0; i < Membrane.Layers.Length; i++)
             *  {
             *      if (this[Membrane.Layers[i]] > 0.0)
             *      {
             *          UrbScentTag[] Scents = UrbSubstances.Scent(Membrane.Layers[i]);
             *          for (int s = 0; s < Scents.Length; s++)
             *          {
             *              if (ScentList.Contains(Scents[s]))
             *              {
             *                  continue;
             *              }
             *              ScentList.Add(Scents[s]);
             *          }
             *      }
             *  }
             * }
             * else*/
            {
                foreach (UrbSubstanceTag tag in Substances.Keys)
                {
                    if (this[tag] > 0.0)
                    {
                        UrbScentTag[] Scents = UrbSubstances.Scent(tag);
                        for (int s = 0; s < Scents.Length; s++)
                        {
                            if (ScentList.Contains(Scents[s]))
                            {
                                continue;
                            }
                            ScentList.Add(Scents[s]);
                        }
                    }
                }
            }
            CachedScents = ScentList.ToArray();
            Dirty        = false;
        }

        return(CachedScents);
    }
Ejemplo n.º 3
0
    public void OnEnable()
    {
        if (Instance == null)
        {
            HasInstance = true;
            Instance    = this;
            UrbSubstances.RegisterSubstanceProperties();
            return;
        }

        if (Debug.isDebugBuild || Debug.developerConsoleVisible)
        {
            Debug.LogWarning("OnEnable self-destruct");
        }
        Destroy(this);
    }
Ejemplo n.º 4
0
    public static UrbScentTag[] Scent(UrbSubstanceTag[] input)
    {
        List <UrbScentTag> ScentList = new List <UrbScentTag>();

        for (int i = 0; i < input.Length; i++)
        {
            UrbScentTag[] Scents = UrbSubstances.Scent(input[i]);
            for (int s = 0; s < Scents.Length; s++)
            {
                if (ScentList.Contains(Scents[s]))
                {
                    continue;
                }
                ScentList.Add(Scents[s]);
            }
        }
        return(ScentList.ToArray());
    }
Ejemplo n.º 5
0
    public float MixRecipe(UrbRecipe Recipe, float Amount)
    {
        if (Amount > UsedCapacity)
        {
            Amount = UsedCapacity;
        }

        UrbSubstance[] Proportions = UrbSubstances.GetIngredientProportions(Recipe);

        float Result = Amount;

        for (int r = 0; r < Proportions.Length; r++)
        {
            float PossibleAmount = this[Proportions[r].Substance] / Proportions[r].SubstanceAmount;
            if (PossibleAmount < Result)
            {
                Result = PossibleAmount;
            }
        }

        if (Result > 0.0f)
        {
            for (int c = 0; c < Proportions.Length; c++)
            {
                RemoveSubstance(Proportions[c].Substance, Proportions[c].SubstanceAmount * Result);
            }

            AddSubstance(Recipe.Product, Result);
        }
        else
        {
            Result = 0.0f;
        }

        Assert.IsFalse(float.IsInfinity(Result) || float.IsNaN(Result));

        return(Result);
    }
Ejemplo n.º 6
0
    public float DecomposeRecipe(UrbRecipe Recipe, float Amount)
    {
        if (Amount > UsedCapacity)
        {
            Amount = UsedCapacity;
        }
        float Result = Amount;

        Result = RemoveSubstance(Recipe.Product, Result);

        if (Result > 0)
        {
            UrbSubstance[] Proportions = UrbSubstances.GetIngredientProportions(Recipe);
            for (int r = 0; r < Proportions.Length; r++)
            {
                AddSubstance(Proportions[r].Substance, Proportions[r].SubstanceAmount * Result);
            }
        }

        Assert.IsFalse(float.IsInfinity(Result) || float.IsNaN(Result));

        return(Result);
    }