Example #1
0
 internal static bool AttemptPlanting(Vector2 grabTile, GameLocation location, Farmer who = null)
 {
     if (PlantableCaveCarrot.canPlaceHere(location, grabTile))
     {
         try
         {
             location.terrainFeatures.Remove(grabTile);
             int  X                  = (int)grabTile.X;
             int  Y                  = (int)grabTile.Y;
             int  seedIndex          = CaveCarrotFlower.getIndex();
             bool isReallyGreenhouse = location.isGreenhouse.Value;
             location.isGreenhouse.Value = true;
             HoeDirt dirtPatch = new HoeDirt(0, location);
             location.terrainFeatures.Add(grabTile, (TerrainFeature)dirtPatch);
             dirtPatch.plant(seedIndex, X, Y, Game1.player, false, location);
             location.isGreenhouse.Value = isReallyGreenhouse;
             return(true);
         } catch (Exception e)
         {
             ModEntry.GetMonitor().Log(e.InnerException.Message);
             return(false);
         }
     }
     else
     {
         if (!IsValidLocation(location))
         {
             Game1.showRedMessage("This plant would not thrive here.");
         }
         return(false);
     }
 }
        public void Edit <T>(IAssetData asset)
        {
            VoidshroomSpore.setIndex(); //get an item index for voidshroom spores if one isn't already set.
            CaveCarrotSeed.setIndex();
            CaveCarrot.setIndex();
            CaveCarrot.setCropIndex();
            if (asset.AssetNameEquals("Maps\\springobjects"))
            {
                IAssetDataForImage editor    = asset.AsImage();
                Texture2D          data      = editor.Data;
                Texture2D          texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
                editor.ReplaceWith(texture2D);
                editor.PatchImage(data, new Rectangle?(), new Rectangle?(), PatchMode.Replace);
                try
                {
                    editor.PatchImage(TextureSet.voidShroomSpore, new Rectangle?(), new Rectangle?(this.objectRect(VoidshroomSpore.getIndex())), PatchMode.Replace);
                    editor.PatchImage(TextureSet.caveCarrotSeed, new Rectangle?(), new Rectangle?(this.objectRect(CaveCarrotSeed.getIndex())), PatchMode.Replace);
                }
                catch (Exception)
                {
                }
            }
            else if (asset.AssetNameEquals("Data\\ObjectInformation"))
            {
                IAssetDataForDictionary <int, string> editor = asset.AsDictionary <int, string>();

                IDictionary <int, string> data = editor.Data;
                if (!data.ContainsKey(VoidshroomSpore.getIndex()))
                {
                    int    voidShroomSporeIndex = VoidshroomSpore.getIndex();
                    String voidShroomSpore      = VoidshroomSpore.getObjectData();
                    this.log("Add voidshroom spore object data: " + voidShroomSporeIndex + ": " + voidShroomSpore);
                    data.Add(voidShroomSporeIndex, voidShroomSpore);
                }

                if (!data.ContainsKey(CaveCarrotSeed.getIndex()))
                {
                    int    caveCarrotSeedIndex = CaveCarrotSeed.getIndex();
                    String caveCarrotObject    = CaveCarrotSeed.getObjectData();
                    this.log("Add cave carrot seed object data: " + caveCarrotSeedIndex + ": " + caveCarrotObject);
                    data.Add(caveCarrotSeedIndex, caveCarrotObject);
                }

                if (!data.ContainsKey(CaveCarrotFlower.getIndex()))
                {
                    int    caveCarrotFlowerIndex  = CaveCarrotFlower.getIndex();
                    String caveCarrotFlowerObject = CaveCarrotFlower.getObjectData();
                    this.log("Add cave carrot flower 'seed' data: " + caveCarrotFlowerIndex + ": " + caveCarrotFlowerObject);
                    data.Add(caveCarrotFlowerIndex, caveCarrotFlowerObject);
                }
            }
            else if (asset.AssetNameEquals("Data\\Crops"))
            {
                IAssetDataForDictionary <int, string> editor = asset.AsDictionary <int, string>();
                IDictionary <int, string>             data   = editor.Data;

                int seedIndex = CaveCarrot.getIndex();
                this.log("seedIndex is: " + seedIndex);
                if (!data.ContainsKey(seedIndex))
                {
                    String cropData = CaveCarrot.getCropData();
                    this.monitor.Log("Loading crop data: " + cropData);
                    data.Add(CaveCarrot.getIndex(), cropData);
                }

                int caveCarrotFlowerIndex = CaveCarrotFlower.getIndex();
                this.log("seedIndex is: " + caveCarrotFlowerIndex);
                if (!data.ContainsKey(caveCarrotFlowerIndex))
                {
                    String cropData = CaveCarrotFlower.getCropData();
                    this.monitor.Log("Loading crop data: " + cropData);
                    data.Add(caveCarrotFlowerIndex, cropData);
                }
            }
            else if (asset.AssetNameEquals("TileSheets\\crops"))
            {
                IAssetDataForImage editor    = asset.AsImage();
                Texture2D          data      = editor.Data;
                Texture2D          texture2D = new Texture2D(Game1.graphics.GraphicsDevice, data.Width, Math.Max(data.Height, 4096));
                editor.ReplaceWith(texture2D);
                editor.PatchImage(data, new Rectangle?(), new Rectangle?(), PatchMode.Replace);
                try
                {
                    int index = CaveCarrot.getCropIndex();
                    this.monitor.Log("Loading cave carrot crop texture.  Crop index: " + index);
                    editor.PatchImage(TextureSet.caveCarrotCrop, new Rectangle?(), new Rectangle?(this.cropRect(index)), PatchMode.Replace);

                    index = CaveCarrotFlower.getCropIndex();
                    this.monitor.Log("Loading cave carrot flower crop texture.  Crop index: " + index);
                    editor.PatchImage(TextureSet.caveCarrotFlowerCrop, new Rectangle?(), new Rectangle?(this.cropRect(index)), PatchMode.Replace);
                }
                catch (Exception)
                {
                }
            }
        }
Example #3
0
 private bool isModCrop(Crop crop)
 {
     return(crop.netSeedIndex.Value == CaveCarrotSeed.getIndex() || crop.netSeedIndex.Value == CaveCarrotFlower.getIndex());
 }