Skip to content

Commit

Permalink
remove unsued code, fix left click to perform special weapon just didn't
Browse files Browse the repository at this point in the history
work
  • Loading branch information
nghiango1 committed May 23, 2024
1 parent d581966 commit fa0c7d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 208 deletions.
208 changes: 5 additions & 203 deletions MouseMoveMode/Decompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,209 +264,11 @@ public static bool pressActionButtonMod(Vector2 grabTile, bool forceNonDirectedT
}
}

if (player.CurrentTool is MeleeWeapon && player.CanMove && !player.canOnlyWalk && !eventUp && !player.onBridge && didPlayerJustRightClick(ignoreNonMouseHeldInput: true))
{
((MeleeWeapon)player.CurrentTool).animateSpecialMove(player);
return false;
}
return true;
}

public static bool pressActionButton(KeyboardState currentKBState, MouseState currentMouseState, GamePadState currentPadState)
{
oldKBState = currentKBState;

input = Game1.input;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;


if (!player.UsingTool && (!eventUp || (currentLocation.currentEvent != null && currentLocation.currentEvent.playerControlSequence)) && !fadeToBlack)
{
if (wasMouseVisibleThisFrame && currentLocation.animals.Length > 0)
{
Vector2 mousePosition = new Vector2(getOldMouseX() + viewport.X, getOldMouseY() + viewport.Y);
if (Utility.withinRadiusOfPlayer((int)mousePosition.X, (int)mousePosition.Y, 1, player))
{
if (currentLocation.CheckPetAnimal(mousePosition, player))
{
return true;
}
if (didPlayerJustRightClick(ignoreNonMouseHeldInput: true) && currentLocation.CheckInspectAnimal(mousePosition, player))
{
return true;
}
}
}
Vector2 grabTile = new Vector2(getOldMouseX() + viewport.X, getOldMouseY() + viewport.Y) / 64f;
Vector2 cursorTile = grabTile;
bool non_directed_tile = false;
if (!wasMouseVisibleThisFrame || mouseCursorTransparency == 0f || !Utility.tileWithinRadiusOfPlayer((int)grabTile.X, (int)grabTile.Y, 1, player))
{
grabTile = player.GetGrabTile();
non_directed_tile = true;
}
bool was_character_at_grab_tile = false;
if (eventUp && !isFestival())
{
CurrentEvent?.receiveActionPress((int)grabTile.X, (int)grabTile.Y);
oldKBState = currentKBState;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;
return false;
}
if (tryToCheckAt(grabTile, player))
{
return false;
}
if (player.isRidingHorse())
{
player.mount.checkAction(player, player.currentLocation);
return false;
}
if (!player.canMove)
{
return false;
}
if (!was_character_at_grab_tile && player.currentLocation.isCharacterAtTile(grabTile) != null)
{
was_character_at_grab_tile = true;
}
bool isPlacingObject = false;
if (player.ActiveObject != null && !(player.ActiveObject is Furniture))
{
if (player.ActiveObject.performUseAction(currentLocation))
{
player.reduceActiveItemByOne();
oldKBState = currentKBState;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;
return false;
}
int stack = player.ActiveObject.Stack;
isCheckingNonMousePlacement = !IsPerformingMousePlacement();
if (non_directed_tile)
{
isCheckingNonMousePlacement = true;
}
if (isOneOfTheseKeysDown(currentKBState, options.actionButton))
{
isCheckingNonMousePlacement = true;
}
Vector2 valid_position = Utility.GetNearbyValidPlacementPosition(player, currentLocation, player.ActiveObject, (int)grabTile.X * 64 + 32, (int)grabTile.Y * 64 + 32);
if (!isCheckingNonMousePlacement && player.ActiveObject is Wallpaper && Utility.tryToPlaceItem(currentLocation, player.ActiveObject, (int)cursorTile.X * 64, (int)cursorTile.Y * 64))
{
isCheckingNonMousePlacement = false;
return true;
}
if (Utility.tryToPlaceItem(currentLocation, player.ActiveObject, (int)valid_position.X, (int)valid_position.Y))
{
isCheckingNonMousePlacement = false;
return true;
}
if (!eventUp && (player.ActiveObject == null || player.ActiveObject.Stack < stack || player.ActiveObject.isPlaceable()))
{
isPlacingObject = true;
}
isCheckingNonMousePlacement = false;
}
if (!isPlacingObject && !was_character_at_grab_tile)
{
grabTile.Y += 1f;
if (player.FacingDirection >= 0 && player.FacingDirection <= 3)
{
Vector2 normalized_offset2 = grabTile - player.Tile;
if (normalized_offset2.X > 0f || normalized_offset2.Y > 0f)
{
normalized_offset2.Normalize();
}
if (Vector2.Dot(Utility.DirectionsTileVectors[player.FacingDirection], normalized_offset2) >= 0f && tryToCheckAt(grabTile, player))
{
return false;
}
}
if (!eventUp && player.ActiveObject is Furniture furniture3)
{
furniture3.rotate();
playSound("dwoop");
oldKBState = currentKBState;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;
return false;
}
grabTile.Y -= 2f;
if (player.FacingDirection >= 0 && player.FacingDirection <= 3 && !was_character_at_grab_tile)
{
Vector2 normalized_offset = grabTile - player.Tile;
if (normalized_offset.X > 0f || normalized_offset.Y > 0f)
{
normalized_offset.Normalize();
}
if (Vector2.Dot(Utility.DirectionsTileVectors[player.FacingDirection], normalized_offset) >= 0f && tryToCheckAt(grabTile, player))
{
return false;
}
}
if (!eventUp && player.ActiveObject is Furniture furniture2)
{
furniture2.rotate();
playSound("dwoop");
oldKBState = currentKBState;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;
return false;
}
grabTile = player.Tile;
if (tryToCheckAt(grabTile, player))
{
return false;
}
if (!eventUp && player.ActiveObject is Furniture furniture)
{
furniture.rotate();
playSound("dwoop");
oldKBState = currentKBState;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;
return false;
}
}

if (!player.isEating && player.ActiveObject != null && !dialogueUp && !eventUp && !player.canOnlyWalk && !player.FarmerSprite.PauseForSingleAnimation && !fadeToBlack && player.ActiveObject.Edibility != -300 && didPlayerJustRightClick(ignoreNonMouseHeldInput: true))
{
if (player.team.SpecialOrderRuleActive("SC_NO_FOOD"))
{
MineShaft obj = player.currentLocation as MineShaft;
if (obj != null && obj.getMineArea() == 121)
{
addHUDMessage(new HUDMessage(content.LoadString("Strings\\StringsFromCSFiles:Object.cs.13053"), 3));
return false;
}
}
if (player.hasBuff("25") && player.ActiveObject != null && !player.ActiveObject.HasContextTag("ginger_item"))
{
addHUDMessage(new HUDMessage(content.LoadString("Strings\\StringsFromCSFiles:Nauseous_CantEat"), 3));
return false;
}
player.faceDirection(2);
player.itemToEat = player.ActiveObject;
player.FarmerSprite.setCurrentSingleAnimation(304);
if (Game1.objectData.TryGetValue(player.ActiveObject.ItemId, out var objectData))
{
currentLocation.createQuestionDialogue((objectData.IsDrink && player.ActiveObject.preserve.Value != Object.PreserveType.Pickle) ? content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3159", player.ActiveObject.DisplayName) : content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3160", player.ActiveObject.DisplayName), currentLocation.createYesNoResponses(), "Eat");
}
oldKBState = currentKBState;
oldMouseState = input.GetMouseState();
oldPadState = currentPadState;
return false;
}
}

if (player.CurrentTool is MeleeWeapon && player.CanMove && !player.canOnlyWalk && !eventUp && !player.onBridge && didPlayerJustRightClick(ignoreNonMouseHeldInput: true))
{
((MeleeWeapon)player.CurrentTool).animateSpecialMove(player);
return false;
}
// if (player.CurrentTool is MeleeWeapon && player.CanMove && !player.canOnlyWalk && !eventUp && !player.onBridge && didPlayerJustRightClick(ignoreNonMouseHeldInput: true))
// {
// ((MeleeWeapon)player.CurrentTool).animateSpecialMove(player);
// return false;
// }
return true;
}

Expand Down
16 changes: 11 additions & 5 deletions MouseMoveMode/MouseMoveMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ModConfig
public float MouseWhellingMinZoom = Options.minZoom;
public KeybindList FullScreenKeybindShortcut { get; set; } = KeybindList.Parse("RightAlt + Enter");
public int PathFindLimit { get; set; } = 500;
public bool ShowMousePositionHint { get; set; } = true;
}

/// <summary>The mod entry point.</summary>
Expand Down Expand Up @@ -100,9 +101,12 @@ private void RenderedEvents(object sender, RenderedEventArgs e)
if (!config.RightClickMoveModeDefault)
return;

var mouseHelper = ModEntry.position_MouseOnScreen + new Vector2(Game1.viewport.X, Game1.viewport.Y);
var mouseBox = Util.toBoxPosition(Util.toTile(mouseHelper));
DrawHelper.drawCursorHelper(e.SpriteBatch, mouseBox);
if (config.ShowMousePositionHint)
{
var mouseHelper = ModEntry.position_MouseOnScreen + new Vector2(Game1.viewport.X, Game1.viewport.Y);
var mouseBox = Util.toBoxPosition(Util.toTile(mouseHelper));
DrawHelper.drawCursorHelper(e.SpriteBatch, mouseBox);
}

if (ModEntry.isMovingAutomaticaly && !ModEntry.isHoldingMove && !ModEntry.isBeingControl)
{
Expand Down Expand Up @@ -409,7 +413,8 @@ private bool handleWhenUsingWeapon(SButton button, MeleeWeapon weapon)
return false;
}

bool isMouseWithinRadiusOfPlayer = Utility.withinRadiusOfPlayer((int)position_Destination.X, (int)position_Destination.Y, 1, Game1.player);
var mousePosition = ModEntry.position_MouseOnScreen + new Vector2(Game1.viewport.X, Game1.viewport.Y);
bool isMouseWithinRadiusOfPlayer = Utility.withinRadiusOfPlayer((int)mousePosition.X, (int)mousePosition.Y, 1, Game1.player);

if (config.WeaponsSpecticalInteractionType == 1)
{
Expand Down Expand Up @@ -516,7 +521,8 @@ private void ButtonPressedMods(object sender, ButtonPressedEventArgs e)
var isWeapon = tool is MeleeWeapon;
if (isWeapon)
{
this.Monitor.Log("It seem we using weapon here");
if (ModEntry.isDebugVerbose)
this.Monitor.Log("It seem we using weapon here");

isFinishHandling = handleWhenUsingWeapon(e.Button, (MeleeWeapon)tool);
if (isFinishHandling) return;
Expand Down

0 comments on commit fa0c7d4

Please sign in to comment.