/// <summary>
        /// Sets a variant for a block.
        /// </summary>
        /// <param name="blockName">Block name</param>
        /// <param name="variant">Variant name</param>
        /// <param name="locationKey">Location key if the variant is only for a specific location</param>
        /// <returns>True if overwriting an existing variant set for this location</returns>
        public static bool SetBlockVariant(string blockName, string variant, int locationKey = AnyLocationKey)
        {
            VariantBlockKey blockKey  = new VariantBlockKey(locationKey, blockName);
            bool            overwrite = !blockVariants.ContainsKey(blockKey);

            if (variant == NoVariant)
            {
                blockVariants.Remove(blockKey);
            }
            else
            {
                blockVariants[blockKey] = variant;
            }

            Debug.LogFormat("Set variant \"{0}\" for the block {1} at locationKey {2}", variant, blockName, locationKey);
            return(overwrite);
        }
Exemplo n.º 2
0
 public static string GetBlockVariant(string blockName)
 {
     if (lastLocationKey >= 0)
     {
         VariantBlockKey blockKey = new VariantBlockKey(lastLocationKey, blockName);
         if (blockVariants.ContainsKey(blockKey))
         {
             return(blockVariants[blockKey]);
         }
         else
         {
             blockKey.locationKey = AnyLocationKey;
             if (blockVariants.ContainsKey(blockKey))
             {
                 return(blockVariants[blockKey]);
             }
         }
     }
     return(NoVariant);
 }