Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions SmartCursor/CursorPosition.cs

This file was deleted.

24 changes: 14 additions & 10 deletions SmartCursor/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@
namespace SmartCursor
{
public class ModEntry : Mod {

/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper) {
InputEvents.ButtonPressed += InputEvents_ButtonPressed;
ControlEvents.MouseChanged += ControlEvents_MouseChanged;
helper.Events.Input.ButtonPressed += OnButtonPressed;
helper.Events.Input.CursorMoved += OnCursorMoved;
}

private void ControlEvents_MouseChanged(object sender, EventArgsMouseStateChanged e) {
/// <summary>Raised after the player moves the in-game cursor.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void OnCursorMoved(object sender, CursorMovedEventArgs e) {
if (!Context.IsWorldReady || !Context.IsPlayerFree || Game1.player.isMoving() || Game1.player.isCharging || Game1.player.isRafting || Game1.player.isRidingHorse() || Game1.player.UsingTool || Game1.player.IsEmoting || !Game1.player.CanMove) {
return;
}

int dir = Game1.player.FacingDirection;

Vector2 grabTile = new Vector2(1, 0);
switch(GetOctant(new Vector2(e.NewPosition.X, e.NewPosition.Y))) {
switch(GetOctant(new Vector2(e.NewPosition.ScreenPixels.X, e.NewPosition.ScreenPixels.Y))) {
case 0:
grabTile = new Vector2(1, 0);
dir = Game1.right;
Expand Down Expand Up @@ -80,7 +84,6 @@ private double GetAngle(Vector2 screenPixels) {
private int GetOctant(Vector2 screenPixels) {
double angle = GetAngle(screenPixels);

Vector2 grabTile = Game1.player.getTileLocation();
angle += 22.5;

if (angle < 45) {
Expand All @@ -103,8 +106,11 @@ private int GetOctant(Vector2 screenPixels) {
return 0;
}

private void InputEvents_ButtonPressed(object sender, EventArgsInput e) {
if (!Context.IsWorldReady || !Context.IsPlayerFree || !(e.Button == SButton.MouseLeft) || Game1.player.isCharging || Game1.player.isRidingHorse() || Game1.player.UsingTool) {
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event data.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e) {
if (!Context.IsWorldReady || !Context.IsPlayerFree || e.Button != SButton.MouseLeft || Game1.player.isCharging || Game1.player.isRidingHorse() || Game1.player.UsingTool) {
return;
}

Expand Down Expand Up @@ -145,10 +151,8 @@ private void InputEvents_ButtonPressed(object sender, EventArgsInput e) {
dir = Game1.right;
}

e = new EventArgsInput(SButton.MouseLeft, new CursorPosition(cursor.AbsolutePixels, cursor.ScreenPixels, grabTile, grabTile), null);
Game1.player.lastClick = grabTile * 64 + new Vector2(32, 32);
Game1.player.FacingDirection = dir;
}

}
}
17 changes: 3 additions & 14 deletions SmartCursor/SmartCursor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<AssemblyName>SmartCursor</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -50,6 +48,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -61,23 +62,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CursorPosition.cs" />
<Compile Include="ModEntry.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180625\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180625\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180625\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-20180625\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180625\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>
6 changes: 3 additions & 3 deletions SmartCursor/manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"Name": "SmartCursor",
"Name": "Smart Cursor",
"Author": "stokastic",
"Version": "1.1",
"Version": "1.1.0",
"Description": "Allows smart targeting of adjacent 8 tiles",
"UniqueID": "stokastic.SmartCursor",
"EntryDll": "SmartCursor.dll",
"MinimumApiVersion": "2.7",
"MinimumApiVersion": "2.10.1",
"UpdateKeys": [ "Nexus:2458" ]
}
4 changes: 0 additions & 4 deletions SmartCursor/packages.config

This file was deleted.