Skip to content

Commit

Permalink
Update for 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Hall committed May 27, 2018
1 parent 78fd83d commit 67010c2
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ _ReSharper*/

#Project files
[Bb]uild/
.vs/

#Subversion files
.svn
Expand Down
73 changes: 35 additions & 38 deletions BetterRanching/BetterRanching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void Event_UpdateTick(object sender, EventArgs e)

private void Event_MouseChanged(object sender, EventArgsMouseStateChanged e)
{
if (!Game1.hasLoadedGame || !Game1.currentLocation.isFarm)
if (!Game1.hasLoadedGame || !Game1.currentLocation.IsFarm)
{
return;
}
Expand All @@ -55,7 +55,7 @@ private void Event_MouseChanged(object sender, EventArgsMouseStateChanged e)

private void Event_ControllerButtonPressed(object sender, EventArgsControllerButtonPressed e)
{
if (!Game1.hasLoadedGame || !Game1.currentLocation.isFarm)
if (!Game1.hasLoadedGame || !Game1.currentLocation.IsFarm)
{
return;
}
Expand Down Expand Up @@ -83,7 +83,6 @@ private void ActionTriggered(EventArgs e)
{
who.Halt();
who.faceGeneralDirection(new Vector2((float)(int)vector2.X, (float)(int)vector2.Y), 0);

}
}
OverrideRanching(Game1.currentLocation, (int)who.GetToolLocation().X, (int)who.GetToolLocation().Y, who, mouse.NewState, who.CurrentTool?.Name);
Expand All @@ -97,7 +96,6 @@ private void ActionTriggered(EventArgs e)
}
}


private void OverrideRanching(GameLocation currentLocation, int x, int y, StardewValley.Farmer who, object state, string toolName)
{
AnimalBeingRanched = null;
Expand All @@ -121,11 +119,11 @@ private void OverrideRanching(GameLocation currentLocation, int x, int y, Starde
ranchProduct = "wool";
break;
}
var rectangle = new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize);
var rectangle = new Rectangle(x - (Game1.tileSize / 2), y - (Game1.tileSize / 2), Game1.tileSize, Game1.tileSize);

if (currentLocation is AnimalHouse)
if (currentLocation is AnimalHouse animalHouse)
{
animal = ((AnimalHouse)currentLocation).GetSelectedAnimal(rectangle);
animal = animalHouse.GetSelectedAnimal(rectangle);
}
else if (currentLocation.IsFarm && currentLocation.IsOutdoors)
{
Expand All @@ -140,7 +138,7 @@ private void OverrideRanching(GameLocation currentLocation, int x, int y, Starde

if (animal.CanBeRanched(toolName))
{
if (who.couldInventoryAcceptThisObject(animal.currentProduce, 1, 0))
if (who.couldInventoryAcceptThisObject(animal.currentProduce.Value, 1, 0))
{
AnimalBeingRanched = animal;
return;
Expand All @@ -150,10 +148,10 @@ private void OverrideRanching(GameLocation currentLocation, int x, int y, Starde
Game1.game1.OverwriteState(state, "Inventory Full");
}
}
else if (animal != null && animal.isBaby() && animal.toolUsedForHarvest.Equals(toolName))
else if (animal?.isBaby() == true && animal.toolUsedForHarvest.Equals(toolName))
{
Game1.game1.OverwriteState(state);
DelayedAction.showDialogueAfterDelay($"Baby {animal.name} will produce {ranchProduct} in {animal.ageWhenMature - animal.age} days.", 0);
DelayedAction.showDialogueAfterDelay($"Baby {animal.Name} will produce {ranchProduct} in {animal.ageWhenMature.Value - animal.age.Value} days.", 0);
}
else
{
Expand All @@ -163,21 +161,21 @@ private void OverrideRanching(GameLocation currentLocation, int x, int y, Starde

private void Event_OnPreRenderHudEvent(object sender, EventArgs e)
{
if (!Game1.hasLoadedGame || !Game1.currentLocation.isFarm)
if (!Game1.hasLoadedGame || !Game1.currentLocation.IsFarm)
{
return;
}

GameLocation currentLocation = Game1.currentLocation;

List<FarmAnimal> farmAnimalList = new List<FarmAnimal>();
if (currentLocation is AnimalHouse)
if (currentLocation is AnimalHouse animalHouse)
{
farmAnimalList = ((AnimalHouse)currentLocation).animals.Values.ToList<FarmAnimal>();
farmAnimalList = animalHouse.animals.Values.ToList();
}
else if (currentLocation is Farm)
else if (currentLocation is Farm farm)
{
farmAnimalList = ((Farm)currentLocation).animals.Values.ToList<FarmAnimal>();
farmAnimalList = farm.animals.Values.ToList();
}

foreach (FarmAnimal farmAnimal in farmAnimalList)
Expand All @@ -187,9 +185,9 @@ private void Event_OnPreRenderHudEvent(object sender, EventArgs e)

foreach (NPC npc in currentLocation.characters)
{
if (npc is Pet)
if (npc is Pet pet)
{
DrawItemBubble(Game1.spriteBatch, (Pet)npc);
DrawItemBubble(Game1.spriteBatch, pet);
}
}
}
Expand All @@ -199,34 +197,34 @@ public void DrawItemBubble(SpriteBatch spriteBatch, FarmAnimal animal)
bool hasProduce = AnimalBeingRanched != animal && (animal.CanBeRanched(GameConstants.Tools.MilkPail) || animal.CanBeRanched(GameConstants.Tools.Shears));
Rectangle? sourceRectangle = new Rectangle?(new Rectangle(218, 428, 7, 6));

if (Config.DisplayProduce && hasProduce || Config.DisplayHearts && !animal.wasPet)
if ((Config.DisplayProduce && hasProduce) || (Config.DisplayHearts && !animal.wasPet.Value))
{
float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.Now.TimeOfDay.TotalMilliseconds / 250.0), 2));
if (animal.isCoopDweller() && !animal.isBaby()) { num -= Game1.tileSize * 1 / 2; }

// Thought Bubble
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2)),
(float)(animal.Position.Y - Game1.tileSize * 4 / 3) + num)),
new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(141, 465, 20, 24)),
(float)(animal.Position.Y - (Game1.tileSize * 4 / 3)) + num)),
new Microsoft.Xna.Framework.Rectangle?(new Rectangle(141, 465, 20, 24)),
Color.White * 0.75f, 0.0f, Vector2.Zero, 4f, SpriteEffects.None,
0);

if (Config.DisplayHearts && !animal.wasPet)
if (Config.DisplayHearts && !animal.wasPet.Value)
{
if (Config.DisplayProduce && hasProduce)
{
// Small Heart
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + Game1.tileSize * .65),
(float)(animal.Position.Y - Game1.tileSize * 4 / 10) + num)),
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + (Game1.tileSize * .65)),
(float)(animal.Position.Y - (Game1.tileSize * 4 / 10)) + num)),
sourceRectangle,
Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None,
1);
}
else
{
// Big Heart
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + Game1.tileSize * 1.1),
(float)(animal.Position.Y - Game1.tileSize * 1 / 10) + num)),
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + (Game1.tileSize * 1.1)),
(float)(animal.Position.Y - (Game1.tileSize * 1 / 10)) + num)),
sourceRectangle,
Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom * 5 / 3, SpriteEffects.None,
1);
Expand All @@ -235,21 +233,21 @@ public void DrawItemBubble(SpriteBatch spriteBatch, FarmAnimal animal)

if (Config.DisplayProduce && hasProduce)
{
if (Config.DisplayHearts && !animal.wasPet)
if (Config.DisplayHearts && !animal.wasPet.Value)
{
// Small Milk
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + Game1.tileSize * .85),
(float)(animal.Position.Y - Game1.tileSize * 7 / 10) + num)),
new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, animal.currentProduce, 16, 16)),
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + (Game1.tileSize * .85)),
(float)(animal.Position.Y - (Game1.tileSize * 7 / 10)) + num)),
new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, animal.currentProduce.Value, 16, 16)),
Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), (float)(Game1.pixelZoom * .60), SpriteEffects.None,
1);
}
else
{
// Big Milk
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + Game1.tileSize * .625),
(float)(animal.Position.Y - Game1.tileSize * 7 / 10) + num)),
new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, animal.currentProduce, 16, 16)),
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(animal.Position.X + (animal.Sprite.getWidth() / 2) + (Game1.tileSize * .625)),
(float)(animal.Position.Y - (Game1.tileSize * 7 / 10)) + num)),
new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, animal.currentProduce.Value, 16, 16)),
Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), (float)(Game1.pixelZoom), SpriteEffects.None,
1);
}
Expand All @@ -263,23 +261,22 @@ public void DrawItemBubble(SpriteBatch spriteBatch, Pet pet)
bool wasPet = (bool)typeof(Pet).GetField("wasPetToday", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pet);
if (!wasPet)
{
float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.Now.TimeOfDay.TotalMilliseconds / 250.0), 2)) - Game1.tileSize * 1 / 2;
float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.Now.TimeOfDay.TotalMilliseconds / 250.0), 2)) - (Game1.tileSize * 1 / 2);

// Thought Bubble
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(pet.Position.X + (pet.Sprite.getWidth() / 2)),
(float)(pet.Position.Y - Game1.tileSize * 4 / 3) + num)),
new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(141, 465, 20, 24)),
(float)(pet.Position.Y - (Game1.tileSize * 4 / 3)) + num)),
new Microsoft.Xna.Framework.Rectangle?(new Rectangle(141, 465, 20, 24)),
Color.White * 0.75f, 0.0f, Vector2.Zero, 4f, SpriteEffects.None,
0);

// Big Heart
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(pet.Position.X + (pet.Sprite.getWidth() / 2) + Game1.tileSize * 1.1),
(float)(pet.Position.Y - Game1.tileSize * 1 / 10) + num)),
spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(pet.Position.X + (pet.Sprite.getWidth() / 2) + (Game1.tileSize * 1.1)),
(float)(pet.Position.Y - (Game1.tileSize * 1 / 10)) + num)),
sourceRectangle,
Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom * 5 / 3, SpriteEffects.None,
1);
}
}
}
}

155 changes: 79 additions & 76 deletions BetterRanching/BetterRanching.csproj
Original file line number Diff line number Diff line change
@@ -1,77 +1,80 @@
<?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>{40A8F610-B967-49B9-8445-162C034FC047}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BetterRanching</RootNamespace>
<AssemblyName>BetterRanching</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>H:\Games\SteamLibrary\steamapps\common\Stardew Valley\Mods\BetterRanching\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</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="GameExtensions.cs" />
<Compile Include="GameConstants.cs" />
<Compile Include="Config.cs" />
<Compile Include="BetterRanching.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="config.json" />
<None Include="manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<PropertyGroup>
<ModPath>$(GamePath)\Mods\$(TargetName)</ModPath>
</PropertyGroup>
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll" DestinationFolder="$(ModPath)" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).pdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).pdb')" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll.mdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).dll.mdb')" />
<Copy SourceFiles="$(ProjectDir)manifest.json" DestinationFolder="$(ModPath)" />
</Target>
<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>
<?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>{40A8F610-B967-49B9-8445-162C034FC047}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BetterRanching</RootNamespace>
<AssemblyName>BetterRanching</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<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>
<PlatformTarget>x86</PlatformTarget>
</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="GameExtensions.cs" />
<Compile Include="GameConstants.cs" />
<Compile Include="Config.cs" />
<Compile Include="BetterRanching.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="config.json" />
<None Include="manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180428\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<PropertyGroup>
<ModPath>$(GamePath)\Mods\$(TargetName)</ModPath>
</PropertyGroup>
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll" DestinationFolder="$(ModPath)" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).pdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).pdb')" />
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll.mdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).dll.mdb')" />
<Copy SourceFiles="$(ProjectDir)manifest.json" DestinationFolder="$(ModPath)" />
</Target>
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180428\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180428\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.2.1.0-beta-20180428\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180428\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>
Loading

0 comments on commit 67010c2

Please sign in to comment.