Started AdditionalCropsFramework. Addedin proof for modded crop seeds, seed bags, (crop objects? needs testing) and planter boxes. Still more to do.

This commit is contained in:
2017-08-22 17:45:30 -07:00
parent 4c52e55717
commit 4fd79dae21
14 changed files with 5703 additions and 2 deletions

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C5F88D48-EA20-40CD-91E2-C8725DC11795}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AdditionalCropsFramework</RootNamespace>
<AssemblyName>AdditionalCropsFramework</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CoreObject.cs" />
<Compile Include="Framework\TerrainDataNode.cs" />
<Compile Include="ModCore.cs" />
<Compile Include="Framework\Utilities.cs" />
<Compile Include="ModularCrop.cs" />
<Compile Include="ModularCropObject.cs" />
<Compile Include="ModularSeeds.cs" />
<Compile Include="PlanterBox.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\deploy.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
using StardewValley;
using StardewValley.TerrainFeatures;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdditionalCropsFramework.Framework
{
public class TerrainDataNode
{
public GameLocation location;
public int tileX;
public int tileY;
public HoeDirt terrainFeature;
public TerrainDataNode(GameLocation loc, int Xtile, int Ytile, HoeDirt TerrainFeature)
{
location = loc;
tileX = Xtile;
tileY = Ytile;
terrainFeature = TerrainFeature;
}
}
}

View File

@ -0,0 +1,716 @@
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Locations;
using StardewValley.Objects;
using StardewValley.TerrainFeatures;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using xTile.Dimensions;
namespace AdditionalCropsFramework.Framework
{
class Utilities
{
public static List<TerrainDataNode> trackedTerrainFeatures= new List<TerrainDataNode>();
public static List<CoreObject> trackedObjectList = new List<CoreObject>();
public static List<CoreObject> NonSolidThingsToDraw = new List<CoreObject>();
public static void createObjectDebris(Item I, int xTileOrigin, int yTileOrigin, int xTileTarget, int yTileTarget, int groundLevel = -1, int itemQuality = 0, float velocityMultiplyer = 1f, GameLocation location = null)
{
Debris debris = new Debris(I, new Vector2(xTileOrigin, yTileOrigin), new Vector2(xTileTarget, yTileTarget))
{
itemQuality = itemQuality,
};
/*
Debris debris = new Debris(objectIndex, new Vector2((float)(xTile * Game1.tileSize + Game1.tileSize / 2), (float)(yTile * Game1.tileSize + Game1.tileSize / 2)), new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()))
{
itemQuality = itemQuality
};
*/
foreach (Chunk chunk in debris.Chunks)
{
double num1 = (double)chunk.xVelocity * (double)velocityMultiplyer;
chunk.xVelocity = (float)num1;
double num2 = (double)chunk.yVelocity * (double)velocityMultiplyer;
chunk.yVelocity = (float)num2;
}
if (groundLevel != -1)
debris.chunkFinalYLevel = groundLevel;
(location == null ? Game1.currentLocation : location).debris.Add(debris);
}
/*
public static void plantModdedCropHere(ModularSeeds seeds)
{
/*
if (Lists.saplingNames.Contains(Game1.player.ActiveObject.name))
{
bool f = plantSappling();
if (f == true) return;
}
//Log.AsyncC("HELLO");
try
{
HoeDirt t;
TerrainFeature r;
bool plant = Game1.player.currentLocation.terrainFeatures.TryGetValue(Game1.currentCursorTile, out r);
t = (r as HoeDirt);
if (t is HoeDirt)
{
if ((t as HoeDirt).crop == null)
{
// Log.AsyncG("BOOP");
(t as HoeDirt).crop = new ModularCrop(seeds.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, seeds.cropDataFilePath, seeds.cropTextureFilePath, seeds.cropObjectTextureFilePath, seeds.cropObjectDataFilePath);
//Game1.player.reduceActiveItemByOne();
Game1.playSound("dirtyHit");
trackedTerrainFeatures.Add(new TerrainDataNode(Game1.player.currentLocation, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, t));
}
}
}catch(Exception err)
{
Log.AsyncG("BUBBLES");
}
}
*/
public static void plantRegularCropHere()
{
/*
Log.AsyncY(Game1.player.ActiveObject.name);
if (Lists.saplingNames.Contains(Game1.player.ActiveObject.name))
{
Log.AsyncY("PLANT THE SAPLING");
bool f = plantSappling();
if (f == true) return;
}
*/
HoeDirt t;
TerrainFeature r;
bool plant = Game1.player.currentLocation.terrainFeatures.TryGetValue(Game1.currentCursorTile, out r);
t = (r as HoeDirt);
if (t is HoeDirt)
{
if ((t as HoeDirt).crop == null)
{
(t as HoeDirt).crop = new Crop(Game1.player.ActiveObject.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y);
Game1.player.reduceActiveItemByOne();
Game1.playSound("dirtyHit");
trackedTerrainFeatures.Add(new TerrainDataNode(Game1.player.currentLocation, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y,t));
}
}
}
public static bool placementAction(CoreObject cObj, GameLocation location, int x, int y, StardewValley.Farmer who = null, bool playSound = true)
{
Vector2 vector = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize));
// cObj.health = 10;
if (who != null)
{
cObj.owner = who.uniqueMultiplayerID;
}
else
{
cObj.owner = Game1.player.uniqueMultiplayerID;
}
if (!cObj.bigCraftable && !(cObj is Furniture))
{
int num = cObj.ParentSheetIndex;
if (num <= 298)
{
if (num > 94)
{
bool result;
switch (num)
{
case 286:
{
using (List<TemporaryAnimatedSprite>.Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize))
{
result = false;
return result;
}
}
}
int num2 = Game1.random.Next();
Game1.playSound("thudStep");
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who)
{
shakeIntensity = 0.5f,
shakeIntensityChange = 0.002f,
extraInfoForEndBehavior = num2,
endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID)
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
{
id = (float)num2
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, true, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
{
delayBeforeAnimationStart = 100,
id = (float)num2
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 3f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false)
{
delayBeforeAnimationStart = 200,
id = (float)num2
});
if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying)
{
Game1.fuseSound = Game1.soundBank.GetCue("fuse");
Game1.fuseSound.Play();
}
return true;
}
case 287:
{
using (List<TemporaryAnimatedSprite>.Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize))
{
result = false;
return result;
}
}
}
int num2 = Game1.random.Next();
Game1.playSound("thudStep");
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who)
{
shakeIntensity = 0.5f,
shakeIntensityChange = 0.002f,
extraInfoForEndBehavior = num2,
endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID)
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
{
id = (float)num2
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
{
delayBeforeAnimationStart = 100,
id = (float)num2
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false)
{
delayBeforeAnimationStart = 200,
id = (float)num2
});
if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying)
{
Game1.fuseSound = Game1.soundBank.GetCue("fuse");
Game1.fuseSound.Play();
}
return true;
}
case 288:
{
using (List<TemporaryAnimatedSprite>.Enumerator enumerator = Game1.currentLocation.temporarySprites.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current.position.Equals(vector * (float)Game1.tileSize))
{
result = false;
return result;
}
}
}
int num2 = Game1.random.Next();
Game1.playSound("thudStep");
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(cObj.parentSheetIndex, 100f, 1, 24, vector * (float)Game1.tileSize, true, false, Game1.currentLocation, who)
{
shakeIntensity = 0.5f,
shakeIntensityChange = 0.002f,
extraInfoForEndBehavior = num2,
endFunction = new TemporaryAnimatedSprite.endBehavior(Game1.currentLocation.removeTemporarySpritesWithID)
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.Yellow, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
{
id = (float)num2
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, true, (float)(y + 7) / 10000f, 0f, Color.Orange, (float)Game1.pixelZoom, 0f, 0f, 0f, false)
{
delayBeforeAnimationStart = 100,
id = (float)num2
});
Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(598, 1279, 3, 4), 53f, 5, 9, vector * (float)Game1.tileSize + new Vector2(5f, 0f) * (float)Game1.pixelZoom, true, false, (float)(y + 7) / 10000f, 0f, Color.White, (float)Game1.pixelZoom * 0.75f, 0f, 0f, 0f, false)
{
delayBeforeAnimationStart = 200,
id = (float)num2
});
if (Game1.fuseSound != null && !Game1.fuseSound.IsPlaying)
{
Game1.fuseSound = Game1.soundBank.GetCue("fuse");
Game1.fuseSound.Play();
}
return true;
}
default:
if (num != 297)
{
if (num != 298)
{
goto IL_FD7;
}
if (location.objects.ContainsKey(vector))
{
return false;
}
location.objects.Add(vector, new Fence(vector, 5, false));
Game1.playSound("axe");
return true;
}
else
{
if (location.objects.ContainsKey(vector) || location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Grass(1, 4));
Game1.playSound("dirtyHit");
return true;
}
break;
}
return result;
}
if (num != 93)
{
if (num == 94)
{
if (location.objects.ContainsKey(vector))
{
return false;
}
new Torch(vector, 1, 94).placementAction(location, x, y, who);
return true;
}
}
else
{
if (location.objects.ContainsKey(vector))
{
return false;
}
Utility.removeLightSource((int)(cObj.tileLocation.X * 2000f + cObj.tileLocation.Y));
Utility.removeLightSource((int)Game1.player.uniqueMultiplayerID);
new Torch(vector, 1).placementAction(location, x, y, (who == null) ? Game1.player : who);
return true;
}
}
else if (num <= 401)
{
switch (num)
{
case 309:
case 310:
case 311:
{
bool flag = location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is HoeDirt && (location.terrainFeatures[vector] as HoeDirt).crop == null;
if (!flag && (location.objects.ContainsKey(vector) || location.terrainFeatures.ContainsKey(vector) || (!(location is Farm) && !location.name.Contains("Greenhouse"))))
{
Game1.showRedMessage("Invalid Position");
return false;
}
string text = location.doesTileHaveProperty(x, y, "NoSpawn", "Back");
if ((text == null || (!text.Equals("Tree") && !text.Equals("All"))) && (flag || (location.isTileLocationOpen(new Location(x * Game1.tileSize, y * Game1.tileSize)) && !location.isTileOccupied(new Vector2((float)x, (float)y), "") && location.doesTileHaveProperty(x, y, "Water", "Back") == null)))
{
int which = 1;
num = cObj.parentSheetIndex;
if (num != 310)
{
if (num == 311)
{
which = 3;
}
}
else
{
which = 2;
}
location.terrainFeatures.Remove(vector);
location.terrainFeatures.Add(vector, new Tree(which, 0));
Game1.playSound("dirtyHit");
return true;
}
break;
}
default:
switch (num)
{
case 322:
if (location.objects.ContainsKey(vector))
{
return false;
}
location.objects.Add(vector, new Fence(vector, 1, false));
Game1.playSound("axe");
return true;
case 323:
if (location.objects.ContainsKey(vector))
{
return false;
}
location.objects.Add(vector, new Fence(vector, 2, false));
Game1.playSound("stoneStep");
return true;
case 324:
if (location.objects.ContainsKey(vector))
{
return false;
}
location.objects.Add(vector, new Fence(vector, 3, false));
Game1.playSound("hammer");
return true;
case 325:
if (location.objects.ContainsKey(vector))
{
return false;
}
location.objects.Add(vector, new Fence(vector, 4, true));
Game1.playSound("axe");
return true;
case 326:
case 327:
case 330:
case 332:
break;
case 328:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(0));
Game1.playSound("axchop");
return true;
case 329:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(1));
Game1.playSound("thudStep");
return true;
case 331:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(2));
Game1.playSound("axchop");
return true;
case 333:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(3));
Game1.playSound("thudStep");
return true;
default:
if (num == 401)
{
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(4));
Game1.playSound("thudStep");
return true;
}
break;
}
break;
}
}
else
{
switch (num)
{
case 405:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(6));
Game1.playSound("woodyStep");
return true;
case 406:
case 408:
case 410:
break;
case 407:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(5));
Game1.playSound("dirtyHit");
return true;
case 409:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(7));
Game1.playSound("stoneStep");
return true;
case 411:
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(8));
Game1.playSound("stoneStep");
return true;
default:
if (num != 415)
{
if (num == 710)
{
if (location.objects.ContainsKey(vector) || location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Water", "Back") == null)
{
return false;
}
new CrabPot(vector, 1).placementAction(location, x, y, who);
return true;
}
}
else
{
if (location.terrainFeatures.ContainsKey(vector))
{
return false;
}
location.terrainFeatures.Add(vector, new Flooring(9));
Game1.playSound("stoneStep");
return true;
}
break;
}
}
}
else
{
int num = cObj.ParentSheetIndex;
if (num <= 130)
{
if (num == 71)
{
if (location is MineShaft)
{
if ((location as MineShaft).mineLevel != 120 && (location as MineShaft).recursiveTryToCreateLadderDown(vector, "hoeHit", 16))
{
return true;
}
Game1.showRedMessage("Unsuitable Location");
}
return false;
}
if (num == 130)
{
if (location.objects.ContainsKey(vector) || Game1.currentLocation is MineShaft)
{
Game1.showRedMessage("Unsuitable Location");
return false;
}
location.objects.Add(vector, new Chest(true)
{
shakeTimer = 50
});
Game1.playSound("axe");
return true;
}
}
else
{
switch (num)
{
case 143:
case 144:
case 145:
case 146:
case 147:
case 148:
case 149:
case 150:
case 151:
if (location.objects.ContainsKey(vector))
{
return false;
}
new Torch(vector, cObj.parentSheetIndex, true)
{
shakeTimer = 25
}.placementAction(location, x, y, who);
return true;
default:
if (num == 163)
{
location.objects.Add(vector, new Cask(vector));
Game1.playSound("hammer");
}
break;
}
}
}
IL_FD7:
if (cObj.name.Equals("Tapper"))
{
if (location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is Tree && (location.terrainFeatures[vector] as Tree).growthStage >= 5 && !(location.terrainFeatures[vector] as Tree).stump && !location.objects.ContainsKey(vector))
{
cObj.tileLocation = vector;
location.objects.Add(vector, cObj);
int treeType = (location.terrainFeatures[vector] as Tree).treeType;
(location.terrainFeatures[vector] as Tree).tapped = true;
switch (treeType)
{
case 1:
cObj.heldObject = new StardewValley.Object(725, 1, false, -1, 0);
cObj.minutesUntilReady = 13000 - Game1.timeOfDay;
break;
case 2:
cObj.heldObject = new StardewValley.Object(724, 1, false, -1, 0);
cObj.minutesUntilReady = 16000 - Game1.timeOfDay;
break;
case 3:
cObj.heldObject = new StardewValley.Object(726, 1, false, -1, 0);
cObj.minutesUntilReady = 10000 - Game1.timeOfDay;
break;
case 7:
cObj.heldObject = new StardewValley.Object(420, 1, false, -1, 0);
cObj.minutesUntilReady = 3000 - Game1.timeOfDay;
if (!Game1.currentSeason.Equals("fall"))
{
cObj.heldObject = new StardewValley.Object(404, 1, false, -1, 0);
cObj.minutesUntilReady = 6000 - Game1.timeOfDay;
}
break;
}
Game1.playSound("axe");
return true;
}
return false;
}
else if (cObj.name.Contains("Sapling"))
{
Vector2 key = default(Vector2);
for (int i = x / Game1.tileSize - 2; i <= x / Game1.tileSize + 2; i++)
{
for (int j = y / Game1.tileSize - 2; j <= y / Game1.tileSize + 2; j++)
{
key.X = (float)i;
key.Y = (float)j;
if (location.terrainFeatures.ContainsKey(key) && (location.terrainFeatures[key] is Tree || location.terrainFeatures[key] is FruitTree))
{
Game1.showRedMessage("Too close to another tree");
return false;
}
}
}
if (location.terrainFeatures.ContainsKey(vector))
{
if (!(location.terrainFeatures[vector] is HoeDirt) || (location.terrainFeatures[vector] as HoeDirt).crop != null)
{
return false;
}
location.terrainFeatures.Remove(vector);
}
if (location is Farm && (location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)vector.X, (int)vector.Y, "Type", "Back").Equals("Grass")))
{
Game1.playSound("dirtyHit");
DelayedAction.playSoundAfterDelay("coin", 100);
location.terrainFeatures.Add(vector, new FruitTree(cObj.parentSheetIndex));
return true;
}
Game1.showRedMessage("Can't be planted here.");
return false;
}
else
{
//Game1.showRedMessage("STEP 1");
if (cObj.category == -74)
{
return true;
}
if (!cObj.performDropDownAction(who))
{
CoreObject @object = (CoreObject)cObj.getOne();
@object.shakeTimer = 50;
@object.tileLocation = vector;
@object.performDropDownAction(who);
if (location.objects.ContainsKey(vector))
{
if (location.objects[vector].ParentSheetIndex != cObj.parentSheetIndex)
{
Game1.createItemDebris(location.objects[vector], vector * (float)Game1.tileSize, Game1.random.Next(4));
location.objects[vector] = @object;
}
}
else
{
// Game1.showRedMessage("STEP 2");
Log.Info(vector);
Vector2 newVec = new Vector2(vector.X, vector.Y);
// cObj.boundingBox.Inflate(32, 32);
location.objects.Add(newVec, cObj);
}
@object.initializeLightSource(vector);
}
if (playSound == true) Game1.playSound("woodyStep");
else
{
Log.AsyncG("restoring item from file");
}
//Log.AsyncM("Placed and object");
cObj.locationsName = location.name;
trackedObjectList.Add(cObj);
return true;
}
}
public static bool addItemToInventoryAndCleanTrackedList(CoreObject I)
{
if (Game1.player.isInventoryFull() == false)
{
Game1.player.addItemToInventoryBool(I, false);
trackedObjectList.Remove(I);
return true;
}
else
{
Random random = new Random(129);
int i = random.Next();
i = i % 4;
Vector2 v2 = new Vector2(Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize);
Game1.createItemDebris(I, v2, i);
return false;
}
}
}
}

View File

@ -0,0 +1,59 @@
using AdditionalCropsFramework.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using StardewModdingAPI;
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdditionalCropsFramework
{
/*
Todo: + Reuse Seedbag code from revitalize in this mod. (Done!)
+ Make a way to interact with the modded seedbags (look at revitalize's code again) (Done! Fixed with planter boxes)
! Serialize and deserialize the modded crop objects and planter boxes and seed bags that exist in the game. Maybe have a list to keep track of all of them or just iterate through everything in the world?
+ Make it so I can plant the modded crops. (DONE! Fixed in planterboxes)
! Make sure crops grow overnight.
! Add way for crops to be watered and to ensure that there is a graphical update when the crop is being watered.
! Add way to harvest crop from planterbox without removing planterbox.
! Fix invisible planterbox so that it does get removed when planting seeds on tillable soil and keep that soil as HoeDirt instead of reverting to normal. This can also be used to just make the dirt look wet.
* * */
public class ModCore : Mod
{
public static IModHelper ModHelper;
public static readonly List<ModularCropObject> SpringWildCrops = new List<ModularCropObject>();
public static readonly List<ModularCropObject> SummerWildCrops = new List<ModularCropObject>();
public static readonly List<ModularCropObject> FallWildCrops = new List<ModularCropObject>();
public static readonly List<ModularCropObject> WinterWildCrops = new List<ModularCropObject>();
public override void Entry(IModHelper helper)
{
ModHelper = helper;
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
}
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
{
if (e.KeyPressed == Keys.U)
{
List<Item> shopInventory = new List<Item>();
shopInventory.Add((Item)new ModularSeeds(1, "SeedsGraphics", "SeedsData", "CropsGraphics", "CropsData","CropsObjectTexture","CropsObjectData"));
shopInventory.Add((Item)new PlanterBox(0, Vector2.Zero));
shopInventory.Add((Item)new PlanterBox(1, Vector2.Zero, "PlanterBox.png", "PlanterBox"));
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(shopInventory);
}
}
}
}

View File

@ -0,0 +1,489 @@
using AdditionalCropsFramework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewValley.Characters;
using StardewValley.Objects;
using StardewValley.TerrainFeatures;
using System;
using System.Collections.Generic;
namespace StardewValley
{
public class ModularCrop : StardewValley.Crop
{
public List<int> phaseDays = new List<int>();
public int phaseToShow = -1;
public List<string> seasonsToGrowIn = new List<string>();
public const int mixedSeedIndex = 770;
public const int seedPhase = 0;
public const int grabHarvest = 0;
public const int sickleHarvest = 1;
public const int rowOfWildSeeds = 23;
public const int finalPhaseLength = 99999;
public const int forageCrop_springOnion = 1;
public int rowInSpriteSheet;
public int currentPhase;
public int harvestMethod;
public int indexOfHarvest;
public int regrowAfterHarvest;
public int dayOfCurrentPhase;
public int minHarvest;
public int maxHarvest;
public int maxHarvestIncreasePerFarmingLevel;
public int daysOfUnclutteredGrowth;
public int whichForageCrop;
public Color tintColor;
public bool flip;
public bool fullyGrown;
public bool raisedSeeds;
public bool programColored;
public bool dead;
public bool forageCrop;
public double chanceForExtraCrops;
public int experienceGainWhenHarvesting;
public Texture2D spriteSheet;
public string spriteSheetName;
public string dataFileName;
public string cropObjectTexture;
public string cropObjectData;
public ModularCrop()
{
}
public ModularCrop(bool forageCrop, int which, int tileX, int tileY)
{
this.forageCrop = forageCrop;
this.whichForageCrop = which;
this.fullyGrown = true;
this.currentPhase = 5;
}
public ModularCrop(int seedIndex, int tileX, int tileY, string DataFileName, string cropTextureSheet,string AssociatedObjectTextureSheet,string AssociatedObjectDataFile)
{
this.forageCrop = false;
this.dataFileName = DataFileName;
this.spriteSheet = ModCore.ModHelper.Content.Load<Texture2D>(cropTextureSheet);
this.spriteSheetName = cropTextureSheet;
this.experienceGainWhenHarvesting = 0;
this.fullyGrown = false;
cropObjectTexture = AssociatedObjectTextureSheet;
cropObjectData = AssociatedObjectDataFile;
Dictionary<int, string> dictionary = ModCore.ModHelper.Content.Load<Dictionary<int,string>>(dataFileName); //Game1.content.Load<Dictionary<int, string>>("Data\\Crops");
if (seedIndex == 770)
{
seedIndex = ModularCrop.getRandomLowGradeCropForThisSeason(Game1.currentSeason);
if (seedIndex == 473)
--seedIndex;
}
if (dictionary.ContainsKey(seedIndex))
{
string[] strArray1 = dictionary[seedIndex].Split('/');
string str1 = strArray1[0];
char[] chArray1 = new char[1] { ' ' };
foreach (string str2 in str1.Split(chArray1))
this.phaseDays.Add(Convert.ToInt32(str2));
this.phaseDays.Add(99999);
string str3 = strArray1[1];
char[] chArray2 = new char[1] { ' ' };
foreach (string str2 in str3.Split(chArray2))
this.seasonsToGrowIn.Add(str2);
this.rowInSpriteSheet = Convert.ToInt32(strArray1[2]);
this.indexOfHarvest = Convert.ToInt32(strArray1[3]);
this.regrowAfterHarvest = Convert.ToInt32(strArray1[4]);
this.harvestMethod = Convert.ToInt32(strArray1[5]);
string[] strArray2 = strArray1[6].Split(' ');
if (strArray2.Length != 0 && strArray2[0].Equals("true"))
{
this.minHarvest = Convert.ToInt32(strArray2[1]);
this.maxHarvest = Convert.ToInt32(strArray2[2]);
this.maxHarvestIncreasePerFarmingLevel = Convert.ToInt32(strArray2[3]);
this.chanceForExtraCrops = Convert.ToDouble(strArray2[4]);
}
this.raisedSeeds = Convert.ToBoolean(strArray1[7]);
string[] strArray3 = strArray1[8].Split(' ');
if (strArray3.Length != 0 && strArray3[0].Equals("true"))
{
List<Color> colorList = new List<Color>();
int index = 1;
while (index < strArray3.Length)
{
colorList.Add(new Color((int)Convert.ToByte(strArray3[index]), (int)Convert.ToByte(strArray3[index + 1]), (int)Convert.ToByte(strArray3[index + 2])));
index += 3;
}
Random random = new Random(tileX * 1000 + tileY + Game1.dayOfMonth);
this.tintColor = colorList[random.Next(colorList.Count)];
this.programColored = true;
}
this.flip = Game1.random.NextDouble() < 0.5;
}
if (this.rowInSpriteSheet != 23)
return;
this.whichForageCrop = seedIndex;
}
public static int getRandomLowGradeCropForThisSeason(string season)
{
if (season.Equals("winter"))
season = Game1.random.NextDouble() < 0.33 ? "spring" : (Game1.random.NextDouble() < 0.5 ? "summer" : "fall");
if (season == "spring")
return Game1.random.Next(472, 476);
if (!(season == "summer"))
{
if (season == "fall")
return Game1.random.Next(487, 491);
}
else
{
switch (Game1.random.Next(4))
{
case 0:
return 487;
case 1:
return 483;
case 2:
return 482;
case 3:
return 484;
}
}
return -1;
}
public void growCompletely()
{
this.currentPhase = this.phaseDays.Count - 1;
this.dayOfCurrentPhase = 0;
if (this.regrowAfterHarvest == -1)
return;
this.fullyGrown = true;
}
public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null)
{
if (this.dead)
return junimoHarvester != null;
if (this.forageCrop)
{
ModularCropObject @object = (ModularCropObject)null;
int howMuch = 3;
if (this.whichForageCrop == 1)
//@object = new ModularCropObject(399, 1, false, -1, 0);
if (Game1.player.professions.Contains(16))
@object.quality = 4;
else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 30.0)
@object.quality = 2;
else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 15.0)
@object.quality = 1;
Game1.stats.ItemsForaged += (uint)@object.Stack;
if (junimoHarvester != null)
{
junimoHarvester.tryToAddItemToHut((Item)@object);
return true;
}
if (Game1.player.addItemToInventoryBool((Item)@object, false))
{
Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
Game1.player.animateOnce(279 + Game1.player.facingDirection);
Game1.player.canMove = false;
Game1.playSound("harvest");
DelayedAction.playSoundAfterDelay("coin", 260);
if (this.regrowAfterHarvest == -1)
{
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0));
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
}
Game1.player.gainExperience(2, howMuch);
return true;
}
Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588"));
}
else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0))
{
int num1 = 1;
int num2 = 0;
int num3 = 0;
if (this.indexOfHarvest == 0)
return true;
Random random = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame);
switch (soil.fertilizer)
{
case 368:
num3 = 1;
break;
case 369:
num3 = 2;
break;
}
double num4 = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)num3 * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01;
double num5 = Math.Min(0.75, num4 * 2.0);
if (random.NextDouble() < num4)
num2 = 2;
else if (random.NextDouble() < num5)
num2 = 1;
if (this.minHarvest > 1 || this.maxHarvest > 1)
num1 = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel));
if (this.chanceForExtraCrops > 0.0)
{
while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops))
++num1;
}
if (this.harvestMethod == 1)
{
if (junimoHarvester == null)
DelayedAction.playSoundAfterDelay("daggerswipe", 150);
if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation))
Game1.playSound("harvest");
if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation))
DelayedAction.playSoundAfterDelay("coin", 260);
for (int index = 0; index < num1; ++index)
{
if (junimoHarvester != null)
junimoHarvester.tryToAddItemToHut((Item)new ModularCropObject(this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData));
else
AdditionalCropsFramework.Framework.Utilities.createObjectDebris((Item)new ModularCropObject(this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1);
//Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, (GameLocation)null);
}
if (this.regrowAfterHarvest == -1)
return true;
this.dayOfCurrentPhase = this.regrowAfterHarvest;
this.fullyGrown = true;
}
else
{
if (junimoHarvester == null)
{
Farmer player = Game1.player;
ModularCropObject @object= new ModularCropObject(this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData);
int num7 = 0;
if (!player.addItemToInventoryBool((Item)@object, num7 != 0))
{
Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588"));
goto label_86;
}
}
Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
if (junimoHarvester == null)
{
Game1.player.animateOnce(279 + Game1.player.facingDirection);
Game1.player.canMove = false;
}
else
{
JunimoHarvester junimoHarvester1 = junimoHarvester;
ModularCropObject @object = new ModularCropObject(this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData);
junimoHarvester1.tryToAddItemToHut((Item)@object);
}
if (random.NextDouble() < (double)Game1.player.LuckLevel / 1500.0 + Game1.dailyLuck / 1200.0 + 9.99999974737875E-05)
{
num1 *= 2;
if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation))
Game1.playSound("dwoop");
}
else if (this.harvestMethod == 0)
{
if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation))
Game1.playSound("harvest");
if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation))
DelayedAction.playSoundAfterDelay("coin", 260);
if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals((object)Game1.currentLocation)))
{
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0));
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
}
}
if (this.indexOfHarvest == 421)
{
this.indexOfHarvest = 431;
num1 = random.Next(1, 4);
}
for (int index = 0; index < num1 - 1; ++index)
{
if (junimoHarvester == null)
AdditionalCropsFramework.Framework.Utilities.createObjectDebris((Item)new ModularCropObject(this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1);
else
junimoHarvester.tryToAddItemToHut((Item)new ModularCropObject(this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData));
}
float num8 = (float)(16.0 * Math.Log(0.018 * (double)Convert.ToInt32(this.experienceGainWhenHarvesting + 1.0), Math.E));
if (junimoHarvester == null)
Game1.player.gainExperience(0, (int)Math.Round((double)num8));
if (this.regrowAfterHarvest == -1)
return true;
this.dayOfCurrentPhase = this.regrowAfterHarvest;
this.fullyGrown = true;
}
}
label_86:
return false;
}
/// <summary>
/// Not yet implemented. Contact the mod author if this is something you want!
/// </summary>
/// <param name="season"></param>
/// <returns></returns>
public new ModularCropObject getRandomWildCropForSeason(string season)
{
ModularCropObject newThing=null;
if (season == "spring" || season=="Spring")
{
Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina);
int cropListIndex = r.Next(0,ModCore.SpringWildCrops.Count-1);
newThing = ModCore.SpringWildCrops[cropListIndex];
}
if (season == "summer" || season=="Summer")
{
Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina);
int cropListIndex = r.Next(0, ModCore.SummerWildCrops.Count - 1);
newThing = ModCore.SummerWildCrops[cropListIndex];
}
if (season == "fall" || season=="Fall")
{
Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina);
int cropListIndex = r.Next(0, ModCore.FallWildCrops.Count - 1);
newThing = ModCore.FallWildCrops[cropListIndex];
}
if (season == "winter" || season=="Winter")
{
Random r = new Random((Game1.timeOfDay + Game1.dayOfMonth + Game1.player.money) / Game1.player.maxStamina);
int cropListIndex = r.Next(0, ModCore.WinterWildCrops.Count - 1);
newThing = ModCore.WinterWildCrops[cropListIndex];
}
return newThing;
}
private Rectangle getSourceRect(int number)
{
if (this.dead)
return new Rectangle(192 + number % 4 * 16, 384, 16, 32);
return new Rectangle(Math.Min(240, (this.fullyGrown ? (this.dayOfCurrentPhase <= 0 ? 6 : 7) : (this.phaseToShow != -1 ? this.phaseToShow : this.currentPhase) + ((this.phaseToShow != -1 ? this.phaseToShow : this.currentPhase) != 0 || number % 2 != 0 ? 0 : -1) + 1) * 16 + (this.rowInSpriteSheet % 2 != 0 ? 128 : 0)), this.rowInSpriteSheet / 2 * 16 * 2, 16, 32);
}
public void newDay(int state, int fertilizer, int xTile, int yTile, GameLocation environment)
{
if (!environment.name.Equals("Greenhouse") && (this.dead || !this.seasonsToGrowIn.Contains(Game1.currentSeason)))
{
this.dead = true;
}
else
{
if (state == 1)
{
this.dayOfCurrentPhase = this.fullyGrown ? this.dayOfCurrentPhase - 1 : Math.Min(this.dayOfCurrentPhase + 1, this.phaseDays.Count > 0 ? this.phaseDays[Math.Min(this.phaseDays.Count - 1, this.currentPhase)] : 0);
if (this.dayOfCurrentPhase >= (this.phaseDays.Count > 0 ? this.phaseDays[Math.Min(this.phaseDays.Count - 1, this.currentPhase)] : 0) && this.currentPhase < this.phaseDays.Count - 1)
{
this.currentPhase = this.currentPhase + 1;
this.dayOfCurrentPhase = 0;
}
while (this.currentPhase < this.phaseDays.Count - 1 && this.phaseDays.Count > 0 && this.phaseDays[this.currentPhase] <= 0)
this.currentPhase = this.currentPhase + 1;
if (this.rowInSpriteSheet == 23 && this.phaseToShow == -1 && this.currentPhase > 0)
this.phaseToShow = Game1.random.Next(1, 7);
if (environment is Farm && this.currentPhase == this.phaseDays.Count - 1 && (this.indexOfHarvest == 276 || this.indexOfHarvest == 190 || this.indexOfHarvest == 254) && new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + xTile * 2000 + yTile).NextDouble() < 0.01)
{
for (int index1 = xTile - 1; index1 <= xTile + 1; ++index1)
{
for (int index2 = yTile - 1; index2 <= yTile + 1; ++index2)
{
Vector2 key = new Vector2((float)index1, (float)index2);
if (!environment.terrainFeatures.ContainsKey(key) || !(environment.terrainFeatures[key] is HoeDirt) || ((environment.terrainFeatures[key] as HoeDirt).crop == null || (environment.terrainFeatures[key] as HoeDirt).crop.indexOfHarvest != this.indexOfHarvest))
return;
}
}
for (int index1 = xTile - 1; index1 <= xTile + 1; ++index1)
{
for (int index2 = yTile - 1; index2 <= yTile + 1; ++index2)
{
Vector2 index3 = new Vector2((float)index1, (float)index2);
(environment.terrainFeatures[index3] as HoeDirt).crop = (ModularCrop)null;
}
}
(environment as Farm).resourceClumps.Add((ResourceClump)new GiantCrop(this.indexOfHarvest, new Vector2((float)(xTile - 1), (float)(yTile - 1))));
}
}
if (this.fullyGrown && this.dayOfCurrentPhase > 0 || (this.currentPhase < this.phaseDays.Count - 1 || this.rowInSpriteSheet != 23))
return;
Vector2 index = new Vector2((float)xTile, (float)yTile);
environment.objects.Remove(index);
string season = Game1.currentSeason;
switch (this.whichForageCrop)
{
case 495:
season = "spring";
break;
case 496:
season = "summer";
break;
case 497:
season = "fall";
break;
case 498:
season = "winter";
break;
}
ModularCropObject @object = this.getRandomWildCropForSeason(season);
@object.isSpawnedObject = true;
@object.canBeGrabbed = true;
environment.objects.Add(index, this.getRandomWildCropForSeason(season));
if (environment.terrainFeatures[index] == null || !(environment.terrainFeatures[index] is HoeDirt))
return;
(environment.terrainFeatures[index] as HoeDirt).crop = (ModularCrop)null;
}
}
public bool isWildSeedCrop()
{
return this.rowInSpriteSheet == 23;
}
public new void draw(SpriteBatch b, Vector2 tileLocation, Color toTint, float rotation)
{
if (this.forageCrop)
{
b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
Log.AsyncC((float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0)));
}
else
{
b.Draw(this.spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(this.getSourceRect((int)tileLocation.X * 7 + (int)tileLocation.Y * 11)), toTint, rotation, new Vector2(8f, 24f), (float)Game1.pixelZoom, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0)));
Log.AsyncG((float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0)));
if (this.tintColor.Equals(Color.White) || this.currentPhase != this.phaseDays.Count - 1 || this.dead)
return;
b.Draw(this.spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (this.raisedSeeds || this.currentPhase >= this.phaseDays.Count - 1 ? 0.0 : ((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((this.fullyGrown ? (this.dayOfCurrentPhase <= 0 ? 6 : 7) : this.currentPhase + 1 + 1) * 16 + (this.rowInSpriteSheet % 2 != 0 ? 128 : 0), this.rowInSpriteSheet / 2 * 16 * 2, 16, 32)), this.tintColor, rotation, new Vector2(8f, 24f), (float)Game1.pixelZoom, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0 / (this.currentPhase != 0 || this.raisedSeeds ? 1.0 : 2.0)));
}
}
public new void drawInMenu(SpriteBatch b, Vector2 screenPosition, Color toTint, float rotation, float scale, float layerDepth)
{
b.Draw(this.spriteSheet, screenPosition, new Rectangle?(this.getSourceRect(0)), toTint, rotation, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize + Game1.tileSize / 2)), scale, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
}
public int getQualityOfCrop()
{
return 0;
}
public int getAmountForHarvest()
{
return 1;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,579 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Locations;
using StardewValley.Menus;
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace AdditionalCropsFramework
{
///Make xtra crops data sheet
///edit crops png, crops xnb, and objectInformation.XNB and springObjects.png.
/// <summary>
/// Stardew ExtraSeeds Class. VERY Broken. Only extend from this class.
/// </summary>
///
public class ModularSeeds : CoreObject
{
public new Texture2D TextureSheet;
public string dataFilePath;
public string cropDataFilePath;
public string cropTextureFilePath;
public string cropObjectDataFilePath;
public string cropObjectTextureFilePath;
public override string Name
{
get
{
return this.name;
}
}
public ModularSeeds()
{
this.updateDrawPosition();
}
public ModularSeeds(int which, string ObjectSpriteSheet, string ObjectDataFile, string AssociatedCropTextureFile, string AssociatedCropDataFile, string AssociatedCropObjectTexture,string AssociatedCropObjectDataFile)
{
if (TextureSheet == null)
{
TextureSheet = ModCore.ModHelper.Content.Load<Texture2D>(ObjectSpriteSheet); //Game1.content.Load<Texture2D>("Revitalize\\CropsNSeeds\\Graphics\\seeds");
texturePath = ObjectSpriteSheet;
}
Dictionary<int, string> dictionary = ModCore.ModHelper.Content.Load<Dictionary<int, string>>(ObjectDataFile);//Game1.content.Load<Dictionary<int, string>>("Revitalize\\CropsNSeeds\\Data\\seeds");
dataFilePath = ObjectDataFile;
cropDataFilePath = AssociatedCropDataFile;
cropTextureFilePath = AssociatedCropTextureFile;
cropObjectDataFilePath = AssociatedCropObjectDataFile;
cropObjectTextureFilePath = AssociatedCropObjectTexture;
Log.AsyncC(cropDataFilePath);
Log.AsyncG(cropTextureFilePath);
//Log.AsyncC(which);
string[] array = dictionary[which].Split(new char[]
{
'/'
});
this.name = array[0];
try
{
this.description = array[6];
this.description += "\nGrown in ";
ModularCrop c = parseCropInfo(which);
int trackCount = 0;
foreach (var v in c.seasonsToGrowIn)
{
if (c.seasonsToGrowIn.Count > 1)
{
trackCount++;
if (trackCount != c.seasonsToGrowIn.Count) description += v + ", ";
else description += "and " + v;
}
else description += v;
}
this.description += ".\n";
this.description += "Takes ";
int totalDaysToGrow = 0;
foreach (var v in c.phaseDays)
{
totalDaysToGrow += v;
}
totalDaysToGrow -= 99999;
this.description += Convert.ToString(totalDaysToGrow) + " days to mature.\n";
try
{
this.description += array[7];
}
catch (Exception e)
{
}
}
catch (Exception e)
{
this.description = "Some seeds! Maybe you should plant them.";
}
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
if (array[2].Equals("-1"))
{
}
else
{
this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[]
{
' '
})[0]);
this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[]
{
' '
})[1]);
this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
this.defaultSourceRect = this.sourceRect;
}
this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
if (array[3].Equals("-1"))
{
}
else
{
this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[]
{
' '
})[0]);
this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[]
{
' '
})[1]);
this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
this.defaultBoundingBox = this.boundingBox;
}
this.updateDrawPosition();
this.rotations = Convert.ToInt32(array[4]);
this.price = Convert.ToInt32(array[5]);
this.parentSheetIndex = which;
}
public override string getDescription()
{
return this.description;
}
public override bool performDropDownAction(StardewValley.Farmer who)
{
this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation);
return false;
}
public override void hoverAction()
{
base.hoverAction();
if (!Game1.player.isInventoryFull())
{
Game1.mouseCursor = 2;
}
}
public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false)
{
var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
return this.RightClicked(who);
// Game1.showRedMessage("YOOO");
//do some stuff when the right button is down
// rotate();
if (this.heldObject != null)
{
// Game1.player.addItemByMenuIfNecessary(this.heldObject);
// this.heldObject = null;
}
else
{
// this.heldObject = Game1.player.ActiveObject;
// Game1.player.removeItemFromInventory(heldObject);
}
//this.minutesUntilReady = 30;
}
else
{
//Game1.showRedMessage("CRY");
}
if (justCheckingForActivity)
{
return true;
}
return this.clicked(who);
}
//DONT USE THIS BASE IT IS TERRIBLE
public override bool clicked(StardewValley.Farmer who)
{
/*
// Game1.showRedMessage("THIS IS CLICKED!!!");
//var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
if (removable == false) return false;
Game1.haltAfterCheck = false;
if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null)
{
// Game1.showRedMessage("Why1?");
return false;
}
if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is ExtraSeeds)))
{
if (Game1.player.currentLocation is FarmHouse)
{
//
Util.addItemToInventoryAndCleanTrackedList(this);
removeLights(this.thisLocation);
this.lightsOn = false;
Game1.playSound("coin");
// this.flaggedForPickUp = true;
thisLocation = null;
return true;
}
else
{
// return true;
// this.heldObject = new ExtraSeeds(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize);
Util.addItemToInventoryAndCleanTrackedList(this);
removeLights(this.thisLocation);
this.lightsOn = false;
Game1.playSound("coin");
thisLocation = null;
return true;
}
}
if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false))
{
// Game1.showRedMessage("Why3?");
// if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject);
Util.addItemToInventoryAndCleanTrackedList(this);
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
this.heldObject = null;
Game1.playSound("coin");
removeLights(this.thisLocation);
this.lightsOn = false;
thisLocation = null;
return true;
}
*/
return false;
}
public virtual bool RightClicked(StardewValley.Farmer who)
{
// Game1.showRedMessage("THIS IS CLICKED!!!");
//var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
/*
Game1.haltAfterCheck = false;
if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null)
{
// Game1.showRedMessage("Why1?");
return false;
}
if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is ExtraSeeds)))
{
if (Game1.player.currentLocation is FarmHouse)
{
//
Game1.player.addItemByMenuIfNecessary(this);
removeLights(this.thisLocation);
this.lightsOn = false;
Game1.playSound("coin");
// this.flaggedForPickUp = true;
return true;
}
else
{
// return true;
// this.heldObject = new ExtraSeeds(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize);
Game1.player.addItemByMenuIfNecessary(this);
removeLights(this.thisLocation);
this.lightsOn = false;
Game1.playSound("coin");
return true;
}
}
if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false))
{
// Game1.showRedMessage("Why3?");
// if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject);
Util.addItemToInventoryElseDrop(this);
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
this.heldObject = null;
Game1.playSound("coin");
removeLights(this.thisLocation);
this.lightsOn = false;
return true;
}
*/
return false;
}
public override void DayUpdate(GameLocation location)
{
base.DayUpdate(location);
this.lightGlowAdded = false;
if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining))
{
this.removeLights(location);
return;
}
// this.addLights(thisLocation, lightColor);
this.addLights(thisLocation, lightColor);
}
public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who)
{
return false;
}
public override bool minutesElapsed(int minutes, GameLocation environment)
{
return false;
}
public override void performRemoveAction(Vector2 tileLocation, GameLocation environment)
{
}
public override bool canBeGivenAsGift()
{
return false;
}
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
{
return false;
}
public virtual void updateDrawPosition()
{
this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)));
}
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
{
}
public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
{
return true;
}
public override bool isPlaceable()
{
return false;
}
public override int salePrice()
{
return this.price;
}
public override int getStack()
{
return this.stack;
}
public override int addToStack(int amount)
{
return 1;
}
private float getScaleSize()
{
int num = this.sourceRect.Width / 16;
int num2 = this.sourceRect.Height / 16;
if (num >= 5)
{
return 0.75f;
}
if (num2 >= 3)
{
return 1f;
}
if (num <= 2)
{
return 2f;
}
if (num <= 4)
{
return 1f;
}
return 0.1f;
}
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
{
spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
if (f.ActiveObject != null && f.ActiveObject.Name.Contains("="))
{
spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97)
{
return;
}
Game1.starCropShimmerPause += 0.04f;
if (Game1.starCropShimmerPause >= 0.8f)
{
Game1.starCropShimmerPause = -0.8f;
}
}
}
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
{
//spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth);
spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize * 1.5f, SpriteEffects.None, layerDepth);
}
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
if (x == -1)
{
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
}
else
{
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
}
if (this.heldObject != null)
{
if (this.heldObject is ModularSeeds)
{
(this.heldObject as ModularSeeds).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as ModularSeeds).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha);
return;
}
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f);
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
}
}
public override void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f)
{
spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
}
public override Item getOne()
{
ModularSeeds ExtraSeeds = new ModularSeeds(this.parentSheetIndex, this.texturePath, this.dataFilePath,this.cropTextureFilePath,this.cropDataFilePath,this.cropObjectTextureFilePath,this.cropObjectDataFilePath);
/*
drawPosition = this.drawPosition;
defaultBoundingBox = this.defaultBoundingBox;
boundingBox = this.boundingBox;
currentRotation = this.currentRotation - 1;
rotations = this.rotations;
rotate();
*/
return ExtraSeeds;
}
public override string getCategoryName()
{
return "Modular Seeds";
// return base.getCategoryName();
}
public override Color getCategoryColor()
{
return Color.Turquoise;
}
public override int maximumStackSize()
{
return base.maximumStackSize();
}
public ModularCrop parseCropInfo(int seedIndex)
{
ModularCrop c = new ModularCrop();
Log.AsyncC(this.cropDataFilePath);
Dictionary<int, string> dictionary = ModCore.ModHelper.Content.Load<Dictionary<int, string>>(this.cropDataFilePath); //Game1.content.Load<Dictionary<int, string>>("Data\\Crops");
if (dictionary.ContainsKey(seedIndex))
{
string[] array = dictionary[seedIndex].Split(new char[]
{
'/'
});
string[] array2 = array[0].Split(new char[]
{
' '
});
for (int i = 0; i < array2.Length; i++)
{
c.phaseDays.Add(Convert.ToInt32(array2[i]));
}
c.phaseDays.Add(99999);
string[] array3 = array[1].Split(new char[]
{
' '
});
for (int j = 0; j < array3.Length; j++)
{
c.seasonsToGrowIn.Add(array3[j]);
}
c.rowInSpriteSheet = Convert.ToInt32(array[2]);
c.indexOfHarvest = Convert.ToInt32(array[3]);
c.regrowAfterHarvest = Convert.ToInt32(array[4]);
c.harvestMethod = Convert.ToInt32(array[5]);
string[] array4 = array[6].Split(new char[]
{
' '
});
if (array4.Length != 0 && array4[0].Equals("true"))
{
c.minHarvest = Convert.ToInt32(array4[1]);
c.maxHarvest = Convert.ToInt32(array4[2]);
c.maxHarvestIncreasePerFarmingLevel = Convert.ToInt32(array4[3]);
c.chanceForExtraCrops = Convert.ToDouble(array4[4]);
}
c.raisedSeeds = Convert.ToBoolean(array[7]);
string[] array5 = array[8].Split(new char[]
{
' '
});
if (array5.Length != 0 && array5[0].Equals("true"))
{
List<Color> list = new List<Color>();
for (int k = 1; k < array5.Length; k += 3)
{
list.Add(new Color((int)Convert.ToByte(array5[k]), (int)Convert.ToByte(array5[k + 1]), (int)Convert.ToByte(array5[k + 2])));
}
Random random = new Random(seedIndex * 1000 + Game1.timeOfDay + Game1.dayOfMonth);
c.tintColor = list[random.Next(list.Count)];
c.programColored = true;
}
c.flip = (Game1.random.NextDouble() < 0.5);
}
if (c.rowInSpriteSheet == 23)
{
c.whichForageCrop = seedIndex;
}
return c;
}
}
}

View File

@ -0,0 +1,724 @@
using AdditionalCropsFramework.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Locations;
using StardewValley.Menus;
using StardewValley.Objects;
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace AdditionalCropsFramework
{
/// <summary>
/// Original Stardew Furniture Class but rewritten to be placed anywhere.
/// </summary>
public class PlanterBox : CoreObject
{
public new int price;
public int Decoration_type;
public int rotations;
public int currentRotation;
private int sourceIndexOffset;
public Vector2 drawPosition;
public Rectangle sourceRect;
public Rectangle defaultSourceRect;
public Rectangle defaultBoundingBox;
public string description;
public Texture2D TextureSheet;
public new bool flipped;
[XmlIgnore]
public bool flaggedForPickUp;
private bool lightGlowAdded;
public string texturePath;
public string dataPath;
public bool IsSolid;
public Crop crop;
public ModularCrop modularCrop;
public bool isWatered;
public override string Name
{
get
{
return this.name;
}
}
public PlanterBox()
{
this.updateDrawPosition();
}
public PlanterBox(bool f)
{
//does nothng
}
public PlanterBox(int which, Vector2 tile, bool isRemovable = true, int price = 0, bool isSolid = false)
{
removable = isRemovable;
// this.thisType = GetType();
this.tileLocation = tile;
this.InitializeBasics(0, tile);
if (TextureSheet == null)
{
TextureSheet = ModCore.ModHelper.Content.Load<Texture2D>("PlanterBox.png"); //Game1.content.Load<Texture2D>("TileSheets\\furniture");
texturePath = "PlanterBoxGraphic";
}
dataPath = "";
this.name = "Planter Box";
this.description = "A planter box that can be used to grow many different crops in many different locations.";
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
this.defaultSourceRect.Width = 1;
this.defaultSourceRect.Height = 1;
this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
this.defaultSourceRect = this.sourceRect;
this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
this.defaultBoundingBox.Width = 1;
this.defaultBoundingBox.Height = 1;
IsSolid = isSolid;
if (isSolid == true)
{
this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
}
else
{
this.boundingBox = new Rectangle(int.MinValue, (int)this.tileLocation.Y * Game1.tileSize, 0, 0); //Throw the bounding box away as far as possible.
}
this.defaultBoundingBox = this.boundingBox;
this.updateDrawPosition();
this.price = price;
this.parentSheetIndex = which;
}
public PlanterBox(int which, Vector2 tile, string ObjectTexture, bool isRemovable = true, int price = 0, bool isSolid = false)
{
removable = isRemovable;
// this.thisType = GetType();
this.tileLocation = tile;
this.InitializeBasics(0, tile);
if (TextureSheet == null)
{
TextureSheet = ModCore.ModHelper.Content.Load<Texture2D>(ObjectTexture); //Game1.content.Load<Texture2D>("TileSheets\\furniture");
texturePath = ObjectTexture;
}
this.name = "Planter Box";
this.description = "A planter box that can be used to grow many different crops in many different locations.";
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
this.defaultSourceRect.Width = 1;
this.defaultSourceRect.Height = 1;
this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
this.defaultSourceRect = this.sourceRect;
this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
this.defaultBoundingBox.Width = 1;
this.defaultBoundingBox.Height = 1;
IsSolid = isSolid;
if (isSolid == true)
{
this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
}
else
{
this.boundingBox = new Rectangle(int.MinValue, (int)this.tileLocation.Y * Game1.tileSize, 0, 0); //Throw the bounding box away as far as possible.
}
this.defaultBoundingBox = this.boundingBox;
this.updateDrawPosition();
this.price = price;
this.parentSheetIndex = which;
}
public PlanterBox(int which, Vector2 tile, string ObjectTexture, string DataPath, bool isRemovable = true, bool isSolid = false)
{
removable = isRemovable;
// this.thisType = GetType();
this.tileLocation = tile;
this.InitializeBasics(0, tile);
TextureSheet = ModCore.ModHelper.Content.Load<Texture2D>(ObjectTexture); //Game1.content.Load<Texture2D>("TileSheets\\furniture");
texturePath = ObjectTexture;
Dictionary<int, string> dictionary = ModCore.ModHelper.Content.Load<Dictionary<int, string>>(DataPath);
dataPath = DataPath;
string s="";
dictionary.TryGetValue(which,out s);
string[] array = s.Split('/');
this.name = array[0];
this.description = array[1];
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1);
this.defaultSourceRect.Width = 1;
this.defaultSourceRect.Height = 1;
this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
this.defaultSourceRect = this.sourceRect;
this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1);
this.defaultBoundingBox.Width = 1;
this.defaultBoundingBox.Height = 1;
IsSolid = isSolid;
if (isSolid == true)
{
this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
}
else
{
this.boundingBox = new Rectangle(int.MinValue, (int)this.tileLocation.Y * Game1.tileSize, 0, 0); //Throw the bounding box away as far as possible.
}
this.defaultBoundingBox = this.boundingBox;
this.updateDrawPosition();
this.price =Convert.ToInt32(array[2]);
this.parentSheetIndex = which;
}
public override string getDescription()
{
return this.description;
}
public override bool performDropDownAction(StardewValley.Farmer who)
{
this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation);
return false;
}
public override void hoverAction()
{
base.hoverAction();
if (!Game1.player.isInventoryFull())
{
Game1.mouseCursor = 2;
}
}
public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false)
{
var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
// Game1.showRedMessage("YOOO");
//do some stuff when the right button is down
// rotate();
if (Game1.player.ActiveObject == null) return false;
if (Game1.player.ActiveObject is ModularSeeds || Game1.player.ActiveObject.getCategoryName() == "Modular Seeds")
{
this.plantModdedCrop((Game1.player.ActiveObject as ModularSeeds));
Log.AsyncO("Modded seeds");
}
if (Game1.player.ActiveObject.getCategoryName() == "Seeds" || Game1.player.ActiveObject.getCategoryName() == "seeds")
{
this.plantRegularCrop();
Log.AsyncY("regular seeds");
}
if(Game1.player.getToolFromName(Game1.player.CurrentItem.Name) is StardewValley.Tools.WateringCan)
{
//Do a thing.
}
Game1.playSound("coin");
return true;
}
else
{
//Game1.showRedMessage("CRY");
}
if (justCheckingForActivity)
{
return true;
}
if (this.parentSheetIndex == 1402)
{
Game1.activeClickableMenu = new Billboard(false);
}
return this.clicked(who); //check for left clicked action.
}
public void plantModdedCrop(ModularSeeds seeds)
{
this.modularCrop = new ModularCrop(seeds.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y, seeds.cropDataFilePath, seeds.cropTextureFilePath, seeds.cropObjectTextureFilePath, seeds.cropObjectDataFilePath);
// Game1.player.reduceActiveItemByOne();
Game1.playSound("dirtyHit");
}
public void plantRegularCrop()
{
this.crop = new Crop(Game1.player.ActiveObject.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y);
// Game1.player.reduceActiveItemByOne();
Game1.playSound("dirtyHit");
}
public override bool clicked(StardewValley.Farmer who)
{
if (removable == false) return false;
// Game1.showRedMessage("THIS IS CLICKED!!!");
Game1.haltAfterCheck = false;
if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null)
{
// Game1.showRedMessage("Why1?");
return false;
}
if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is PlanterBox)))
{
if (Game1.player.currentLocation is FarmHouse)
{
// Game1.showRedMessage("Why2?");
// this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero);
Utilities.addItemToInventoryAndCleanTrackedList(this);
this.flaggedForPickUp = true;
this.thisLocation = null;
return true;
}
else
{
// return true;
this.flaggedForPickUp = true;
if (this is TV)
{
this.heldObject = new TV(parentSheetIndex, Vector2.Zero);
}
else
{
// this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero);
Utilities.addItemToInventoryAndCleanTrackedList(this);
// this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
// this.heldObject = null;
Game1.playSound("coin");
this.thisLocation = null;
return true;
}
}
}
if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false))
{
// Game1.showRedMessage("Why3?");
this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation);
this.heldObject = null;
Utilities.addItemToInventoryAndCleanTrackedList(this);
Game1.playSound("coin");
this.thisLocation = null;
return true;
}
return false;
}
public override void DayUpdate(GameLocation location)
{
base.DayUpdate(location);
this.lightGlowAdded = false;
if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining))
{
this.removeLights(location);
return;
}
this.addLights(location);
}
public void resetOnPlayerEntry(GameLocation environment)
{
this.removeLights(environment);
if (Game1.isDarkOut())
{
this.addLights(environment);
}
}
public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, StardewValley.Farmer who)
{
if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is PlanterBox) || ((dropIn as PlanterBox).getTilesWide() == 1 && (dropIn as PlanterBox).getTilesHigh() == 1)))
{
this.heldObject = (StardewValley.Object)dropIn.getOne();
this.heldObject.tileLocation = this.tileLocation;
this.heldObject.boundingBox.X = this.boundingBox.X;
this.heldObject.boundingBox.Y = this.boundingBox.Y;
// Log.AsyncO(getDefaultBoundingBoxForType((dropIn as PlanterBox).Decoration_type));
this.heldObject.performDropDownAction(who);
if (!probe)
{
Game1.playSound("woodyStep");
// Log.AsyncC("HUH?");
if (who != null)
{
who.reduceActiveItemByOne();
}
}
return true;
}
return false;
}
private void addLights(GameLocation environment)
{
// this.lightSource.lightTexture = Game1.content.Load<Texture2D>("LooseSprites\\Lighting\\lantern");
if (this.Decoration_type == 7)
{
if (this.sourceIndexOffset == 0)
{
this.sourceRect = this.defaultSourceRect;
this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width;
}
this.sourceIndexOffset = 1;
if (this.lightSource == null)
{
Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, Color.Black, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y));
Game1.currentLightSources.Add(this.lightSource);
return;
}
}
else if (this.Decoration_type == 13)
{
if (this.sourceIndexOffset == 0)
{
this.sourceRect = this.defaultSourceRect;
this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width;
}
this.sourceIndexOffset = 1;
if (this.lightGlowAdded)
{
environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)));
this.lightGlowAdded = false;
}
}
}
public override bool minutesElapsed(int minutes, GameLocation environment)
{
if (Game1.isDarkOut())
{
this.addLights(environment);
}
else
{
this.removeLights(environment);
}
return false;
}
public override void performRemoveAction(Vector2 tileLocation, GameLocation environment)
{
this.removeLights(environment);
if (this.Decoration_type == 13 && this.lightGlowAdded)
{
environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)));
this.lightGlowAdded = false;
}
base.performRemoveAction(tileLocation, environment);
}
public bool isGroundFurniture()
{
return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13;
}
public override bool canBeGivenAsGift()
{
return false;
}
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
{
if ((l is FarmHouse))
{
for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
{
for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
{
Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
vector.X += (float)(Game1.tileSize / 2);
vector.Y += (float)(Game1.tileSize / 2);
foreach (KeyValuePair<Vector2, StardewValley.Object> something in l.objects)
{
StardewValley.Object obj = something.Value;
if ((obj.GetType()).ToString().Contains("PlanterBox"))
{
PlanterBox current = (PlanterBox)obj;
if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
{
bool result = true;
return result;
}
if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
{
bool result = false;
return result;
}
}
}
}
}
return base.canBePlacedHere(l, tile);
}
else
{
// Game1.showRedMessage("NOT FARMHOUSE");
for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
{
for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
{
Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
vector.X += (float)(Game1.tileSize / 2);
vector.Y += (float)(Game1.tileSize / 2);
/*
foreach (PlanterBox current in (l as FarmHouse).PlanterBox)
{
if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
{
bool result = true;
return result;
}
if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
{
bool result = false;
return result;
}
}
*/
}
}
return base.canBePlacedHere(l, tile);
}
}
public void updateDrawPosition()
{
this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)));
}
public int getTilesWide()
{
return this.boundingBox.Width / Game1.tileSize;
}
public int getTilesHigh()
{
return this.boundingBox.Height / Game1.tileSize;
}
public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
{
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
this.tileLocation = new Vector2((float)point.X, (float)point.Y);
bool flag = false;
if (this.IsSolid)
{
this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
}
else
{
this.boundingBox = new Rectangle(int.MinValue, y / Game1.tileSize * Game1.tileSize, 0, 0);
}
/*
foreach (Furniture current2 in (location as DecoratableLocation).furniture)
{
if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
{
current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
bool result = true;
return result;
}
}
*/
using (List<StardewValley.Farmer>.Enumerator enumerator3 = location.getFarmers().GetEnumerator())
{
while (enumerator3.MoveNext())
{
if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox))
{
Game1.showRedMessage("Can't place on top of a person.");
bool result = false;
return result;
}
}
}
this.updateDrawPosition();
bool f=Utilities.placementAction(this, location, x, y, who);
this.thisLocation = Game1.player.currentLocation;
return f;
// Game1.showRedMessage("Can only be placed in House");
// return false;
}
public override bool isPlaceable()
{
return true;
}
public override Rectangle getBoundingBox(Vector2 tileLocation)
{
return this.boundingBox;
}
public override int salePrice()
{
return this.price;
}
public override int maximumStackSize()
{
return 1;
}
public override int getStack()
{
return this.stack;
}
public override int addToStack(int amount)
{
return 1;
}
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
{
if (f.ActiveObject.bigCraftable)
{
spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(StardewValley.Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
return;
}
spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
if (f.ActiveObject != null && f.ActiveObject.Name.Contains("="))
{
spriteBatch.Draw(this.TextureSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97)
{
return;
}
Game1.starCropShimmerPause += 0.04f;
if (Game1.starCropShimmerPause >= 0.8f)
{
Game1.starCropShimmerPause = -0.8f;
}
}
//base.drawWhenHeld(spriteBatch, objectPosition, f);
}
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
{
spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * (3) * scaleSize, SpriteEffects.None, layerDepth);
}
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
if (x == -1)
{
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
}
else
{
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y*Game1.tileSize)), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
}
if (this.heldObject != null)
{
if (this.heldObject is PlanterBox)
{
(this.heldObject as PlanterBox).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as PlanterBox).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha);
return;
}
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f);
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
}
this.drawCrops(Game1.spriteBatch, (int)this.tileLocation.X, (int)this.tileLocation.Y);
}
public void drawCrops(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
{
if (this.thisLocation != null)
{
if (this.modularCrop != null)
{
this.modularCrop.draw(Game1.spriteBatch, this.tileLocation, Color.White, 0);
Log.AsyncM("draw a modular crop now");
}
Log.AsyncC("wait WTF");
if (this.crop != null)
{
this.crop.draw(Game1.spriteBatch, this.tileLocation, Color.White, 0);
Log.AsyncG("COWS GO MOO");
}
}
else Log.AsyncM("I DONT UNDERSTAND");
}
public void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f)
{
spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
}
public override Item getOne()
{
if (this.dataPath == "") return new PlanterBox(this.parentSheetIndex, this.tileLocation);
else return new PlanterBox(this.parentSheetIndex, this.tileLocation,this.texturePath,this.dataPath);
/*
drawPosition = this.drawPosition;
defaultBoundingBox = this.defaultBoundingBox;
boundingBox = this.boundingBox;
currentRotation = this.currentRotation - 1;
rotations = this.rotations;
rotate();
*/
}
public override string getCategoryName()
{
return "Planter Box";
// return base.getCategoryName();
}
public override Color getCategoryColor()
{
return Color.Purple;
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AdditionalCropsFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AdditionalCropsFramework")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c5f88d48-ea20-40cd-91e2-c8725dc11795")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,14 @@
{
"Name": "AdditionalCropsFramework",
"Author": "Alpha_Omegasis",
"Version": {
"MajorVersion": 1,
"MinorVersion": 0,
"PatchVersion": 0,
"Build": null
},
"MinimumApiVersion": "1.15",
"Description": "Allows additional crops to be added to their own .xnb files without having to override crop.xnb!",
"UniqueID": "Omegasis.AdditionalCropsFramework",
"EntryDll": "AdditionalCropsFramework.dll"
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Pathoschild.Stardew.ModBuildConfig" version="1.7.1" targetFramework="net45" />
</packages>

View File

@ -41,11 +41,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "~metadata", "~metadata", "{
ProjectSection(SolutionItems) = preProject
deploy.targets = deploy.targets
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
AdditionalCropsFramework\ModularCropObject.cs = AdditionalCropsFramework\ModularCropObject.cs
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleSoundManager", "SimpleSoundManager\SimpleSoundManager.csproj", "{7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdditionalCropsFramework", "AdditionalCropsFramework\AdditionalCropsFramework.csproj", "{C5F88D48-EA20-40CD-91E2-C8725DC11795}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -124,6 +127,10 @@ Global
{7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A}.Release|Any CPU.Build.0 = Release|Any CPU
{C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5F88D48-EA20-40CD-91E2-C8725DC11795}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5F88D48-EA20-40CD-91E2-C8725DC11795}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -42,9 +42,9 @@ namespace Revitalize.Draw
{
//Log.Async(i);
//i++;
if (v is ModularDecoration && v.thisLocation==Game1.player.currentLocation)
if (v is Decoration && v.thisLocation==Game1.player.currentLocation)
{
if (v.boundingBox.Height == 0 && v.boundingBox.Width == 0) (v as ModularDecoration).drawInfront(b, (int)v.tileLocation.X, (int)v.tileLocation.Y);
if (v.boundingBox.Height == 0 && v.boundingBox.Width == 0) (v as Decoration).drawInfront(b, (int)v.tileLocation.X, (int)v.tileLocation.Y);
}
}
b.End();