Esempio n. 1
0
        public override string CompInspectStringExtra()
        {
            if (!this.Active)
            {
                return(null);
            }

            if (!this.Props.customResourceString.NullOrEmpty())
            {
                return(Translator.Translate(this.Props.customResourceString) + ": " + base.Fullness.ToStringPercent());
            }

            else if (ResourceDef.ToString() == "GR_EldritchInsectJelly")
            {
                return(Translator.Translate("JellyGrowth2") + ": " + base.Fullness.ToStringPercent());
            }
            else if (ResourceDef.ToString() == "GR_DarkYoungWoodLog")
            {
                return(Translator.Translate("TentacleGrowth") + ": " + base.Fullness.ToStringPercent());
            }


            else
            {
                return(Translator.Translate("ResourceGrowth") + ": " + base.Fullness.ToStringPercent());
            }
        }
Esempio n. 2
0
    bool hasEnough( ResourceDef[] res )
    {
        for( int i = 0; i < res.Length; ++i )
        {
            ResourceDef curDef = new ResourceDef();
            if( m_res.TryGetValue( res[i].type, out curDef ) )
            {
                if( curDef.amount < res[i].amount ) return false;
            }
            else
            {
                return false;
            }
        }

        return true;
    }
Esempio n. 3
0
    public void addResource( ResourceDef def )
    {
        if( def == null )
        {
            return;
        }

        ResourceDef curDef;
        if( m_res.TryGetValue( def.type, out curDef ) )
        {
            curDef.amount += def.amount;
        }
        else
        {
            curDef = def;
            m_res[def.type] = def;
        }

        print( "Have "+curDef.amount+" of "+def.type );
    }
Esempio n. 4
0
        private ResourceDef Compress(ResourceDef resource)
        {
            CoderPropID[] propIDs =
            {
                CoderPropID.DictionarySize,
                CoderPropID.PosStateBits,
                CoderPropID.LitContextBits,
                CoderPropID.LitPosBits,
                CoderPropID.Algorithm,
                CoderPropID.NumFastBytes,
                CoderPropID.MatchFinder,
                CoderPropID.EndMarker
            };
            object[] properties =
            {
                (Int32)(1 << 23),
                (Int32)(2),
                (Int32)(3),
                (Int32)(0),
                (Int32)(2),
                (Int32)(128),
                "bt4",
                true
            };

            MemoryStream outStream = new MemoryStream();

            LZMAEncoder encoder = new LZMAEncoder();

            encoder.SetCoderProperties(propIDs, properties);
            encoder.WriteCoderProperties(outStream);

            MemoryStream inStream = new MemoryStream(resource.Data);

            encoder.Code(inStream, outStream, -1, -1);

            byte[] compressed = outStream.ToArray();
            return(new ResourceDef(resource.Name, compressed));
        }
 public GodotAssetRes(ResourceDef mainResource, IReadOnlyDictionary <int, ResourceDef> subResources,
                      IReadOnlyList <ExtResourceRef> extResources) : base(subResources, extResources)
 {
     MainResource = mainResource;
 }
Esempio n. 6
0
        private static void GenerateResource(int offsetX, int offsetY, Tile[,] tiles, ResourceDef resource, long seed)
        {
            var noise     = new OpenSimplexNoise(seed + (int)resource.Item);
            var scale     = 10 * resource.Scale;
            var threshold = 0.6 * resource.Threshold;
            var amount    = 500 * resource.Amount;

            for (int x = 0; x < tiles.GetLength(0); x++)
            {
                for (int y = 0; y < tiles.GetLength(1); y++)
                {
                    double _x    = x + offsetX;
                    double _y    = y + offsetY;
                    double value = noise.EvaluateOctave(_x / scale, _y / scale, 2, 0.5);
                    if (value > threshold)
                    {
                        tiles[x, y].Resource      = resource.Item;
                        tiles[x, y].ResourceCount = (short)(amount * ((value - threshold) / (1 - threshold)));
                    }
                }
            }
        }
Esempio n. 7
0
 void useResources( ResourceDef[] res )
 {
     for( int i = 0; i < res.Length; ++i )
     {
         ResourceDef curDef = new ResourceDef();
         if( m_res.TryGetValue( res[i].type, out curDef ) )
         {
             curDef.amount -= res[i].amount;
         }
     }
 }