Commit 5ecf7d83 authored by Maurício Gomes's avatar Maurício Gomes

Updated to SMAPI 3

parent c65ecd4f

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMAPIHealthBarMod", "SMAPIHealthBarMod\SMAPIHealthBarMod.csproj", "{2B60C8FE-3917-4DCB-8BE9-6C2D0BE31F6C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6EECD74D-9FDA-4C8F-8C92-2ED70B80CDF1}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -24,4 +19,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C098836E-8C2E-4ABD-947B-34F621E49E99}
EndGlobalSection
EndGlobal
......@@ -19,8 +19,8 @@ using System;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Netcode;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Monsters;
......@@ -59,7 +59,7 @@ namespace SMAPIHealthBarMod
if (this.Config.ColourScheme >= this.ColorSchemes.Length)
this.Config.ColourScheme = this.ColorSchemes.Length - 1;
GraphicsEvents.OnPostRenderEvent += this.GraphicsEvents_DrawTick;
this.Helper.Events.Display.Rendered += this.GraphicsEvents_DrawTick;
}
......@@ -79,21 +79,21 @@ namespace SMAPIHealthBarMod
foreach (Monster monster in Game1.currentLocation.characters.OfType<Monster>())
{
// skip if not visible
if (monster.isInvisible || !Utility.isOnScreen(monster.position, 3 * Game1.tileSize))
if (monster.IsInvisible || !Utility.isOnScreen(monster.position, 3 * Game1.tileSize))
continue;
// get monster data
int health = monster.health;
int maxHealth = Math.Max(monster.maxHealth, monster.health);
int numberKilled = Game1.stats.specificMonstersKilled.ContainsKey(monster.name)
? Game1.stats.specificMonstersKilled[monster.name]
int health = monster.Health;
int maxHealth = Math.Max(monster.MaxHealth, monster.Health);
int numberKilled = Game1.stats.specificMonstersKilled.ContainsKey(monster.Name)
? Game1.stats.specificMonstersKilled[monster.Name]
: 0;
string label = "???";
// get bar data
Color barColor;
float barLengthPercent;
if (numberKilled + Game1.player.combatLevel > 15)
if (numberKilled + Game1.player.combatLevel.Value > 15)
{
float monsterHealthPercent = health / (float)maxHealth;
barLengthPercent = 1f;
......@@ -108,12 +108,12 @@ namespace SMAPIHealthBarMod
else
barColor = this.ColorSchemes[this.Config.ColourScheme][4];
if (numberKilled + Game1.player.combatLevel * 4 > 45)
if (numberKilled + Game1.player.combatLevel.Value * 4 > 45)
{
barLengthPercent = monsterHealthPercent;
label = monster.health > 999
label = monster.Health > 999
? "!!!"
: $"{monster.health:000}";
: $"{monster.Health:000}";
}
}
else
......@@ -124,15 +124,15 @@ namespace SMAPIHealthBarMod
// get monster position
Vector2 monsterLocalPosition = monster.getLocalPosition(Game1.viewport);
Rectangle monsterBox = new Rectangle((int)monsterLocalPosition.X, (int)monsterLocalPosition.Y - monster.sprite.spriteHeight / 2 * Game1.pixelZoom, monster.sprite.spriteWidth * Game1.pixelZoom, 12);
Rectangle monsterBox = new Rectangle((int)monsterLocalPosition.X, (int)monsterLocalPosition.Y - monster.Sprite.SpriteHeight / 2 * Game1.pixelZoom, monster.Sprite.SpriteWidth * Game1.pixelZoom, 12);
if (monster is GreenSlime slime)
{
if (slime.hasSpecialItem)
if (slime.hasSpecialItem.Value)
{
monsterBox.X -= 5;
monsterBox.Width += 10;
}
else if (slime.cute)
else if (slime.cute.Value)
{
monsterBox.X -= 2;
monsterBox.Width += 4;
......@@ -142,29 +142,29 @@ namespace SMAPIHealthBarMod
}
else if (monster is RockCrab || monster is LavaCrab)
{
if (monster.sprite.CurrentFrame % 4 == 0)
if (monster.Sprite.CurrentFrame % 4 == 0)
continue;
}
else if (monster is RockGolem)
{
if (monster.health == monster.maxHealth)
if (monster.Health == monster.MaxHealth)
continue;
monsterBox.Y = (int)monsterLocalPosition.Y - monster.sprite.spriteHeight * Game1.pixelZoom * 3 / 4;
monsterBox.Y = (int)monsterLocalPosition.Y - monster.Sprite.SpriteHeight * Game1.pixelZoom * 3 / 4;
}
else if (monster is Bug bug)
{
if (bug.isArmoredBug)
if (bug.isArmoredBug.Value)
continue;
monsterBox.Y -= 15 * Game1.pixelZoom;
}
else if (monster is Grub)
{
if (monster.sprite.CurrentFrame == 19)
if (monster.Sprite.CurrentFrame == 19)
continue;
monsterBox.Y = (int)monsterLocalPosition.Y - monster.sprite.spriteHeight * Game1.pixelZoom * 4 / 7;
monsterBox.Y = (int)monsterLocalPosition.Y - monster.Sprite.SpriteHeight * Game1.pixelZoom * 4 / 7;
}
else if (monster is Fly)
monsterBox.Y = (int)monsterLocalPosition.Y - monster.sprite.spriteHeight * Game1.pixelZoom * 5 / 7;
monsterBox.Y = (int)monsterLocalPosition.Y - monster.Sprite.SpriteHeight * Game1.pixelZoom * 5 / 7;
else if (monster is DustSpirit)
{
monsterBox.X += 3;
......@@ -173,7 +173,7 @@ namespace SMAPIHealthBarMod
}
else if (monster is Bat)
{
if (monster.sprite.CurrentFrame == 4)
if (monster.Sprite.CurrentFrame == 4)
continue;
monsterBox.X -= 1;
monsterBox.Width -= 2;
......@@ -183,7 +183,7 @@ namespace SMAPIHealthBarMod
monsterBox.Y -= 2 * Game1.pixelZoom;
else if (monster is Skeleton || monster is ShadowBrute || monster is ShadowShaman || monster is SquidKid)
{
if (monster.health == monster.maxHealth)
if (monster.Health == monster.MaxHealth)
continue;
monsterBox.Y -= 7 * Game1.pixelZoom;
}
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SMAPIHealthBarMod</RootNamespace>
<AssemblyName>SMAPIHealthBarMod</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
......@@ -24,14 +24,17 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\SMAPIHealthBarMod\</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HealthBarConfig.cs" />
......@@ -42,26 +45,17 @@
<None Include="manifest.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<Content Include="README.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="patreon_logo_shine100.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="screenshot.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.1.5.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.1.5.0\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.5.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.1.5.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<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)" />
<Copy SourceFiles="$(SolutionDir)README.md" DestinationFolder="$(ModPath)" />
<Copy SourceFiles="$(SolutionDir)screenshot.png" DestinationFolder="$(ModPath)" />
<Copy SourceFiles="$(SolutionDir)patreon_logo_shine100.png" DestinationFolder="$(ModPath)" />
</Target>
</Project>
\ No newline at end of file
</Project>
......@@ -3,12 +3,13 @@
"Author": "Maurício Gomes (Speeder)",
"Version": {
"MajorVersion": 1,
"MinorVersion": 8,
"PatchVersion": 0,
"MinorVersion": 9,
"PatchVersion": 1,
"Build": null
},
"MinimumApiVersion": "1.9",
"MinimumApiVersion": "3.0",
"UniqueID": "Speeder.HealthBars",
"Description": "Add health bars to monsters.",
"EntryDll": "SMAPIHealthBarMod.dll"
"EntryDll": "SMAPIHealthBarMod.dll",
"UpdateKeys": [ "Nexus:193", "Chuckklefish:3529" ]
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Pathoschild.Stardew.ModBuildConfig" version="1.5.0" targetFramework="net452" />
</packages>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment