Skip to content

Commit

Permalink
0.1.5.7 release, Lock Camera option.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Oct 12, 2017
1 parent be260a4 commit e0a1d4b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
1 change: 1 addition & 0 deletions HEROsMod.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files %28x86%29\Steam\steamapps\common\Terraria\Terraria.exe</StartProgram>
<StartWorkingDirectory>C:\Program Files %28x86%29\Steam\steamapps\common\terraria</StartWorkingDirectory>
<StartArguments>-skipselect</StartArguments>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion HEROsModModPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HEROsModModPlayer : ModPlayer

public override void SetControls()
{
if (FlyCam.Enabled)
if (FlyCam.Enabled && !FlyCam.LockCamera)
{
player.controlDown = false;
player.controlUp = false;
Expand Down
58 changes: 45 additions & 13 deletions HEROsModServices/FlyCam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@ internal class FlyCam : HEROsModService

internal static bool Enabled { get; set; }

internal static bool LockCamera { get; set; }

/// <summary>
/// A service that allows the player to take controll of the camera
/// </summary>
public FlyCam()
{
Enabled = false;
LockCamera = false;
this._name = "Fly Camera";
this._hotbarIcon = new UIKit.UIImage(Main.itemTexture[493]);
this._hotbarIcon.onLeftClick += _hotbarIcon_onLeftClick;
this.HotbarIcon.Tooltip = "Enable Fly Camera";
this._hotbarIcon.onRightClick += _hotbarIcon_onRightClick;
this.HotbarIcon.Tooltip = "Enable Fly Camera (RMB: Lock Camera)";
//Make sure FreeCamera is off by default
Disable();
}
Expand All @@ -40,22 +44,46 @@ private void Enable()
{
this._hotbarIcon.Opacity = 1f;
Enabled = true;
this.HotbarIcon.Tooltip = "Disable Fly Camera";
LockCamera = false;
this.HotbarIcon.Tooltip = "Disable Fly Camera (RMB: Lock Camera)";
}

private void Disable()
{
this._hotbarIcon.Opacity = .5f;
Enabled = false;
this.HotbarIcon.Tooltip = "Enable Fly Camera";
LockCamera = false;
this.HotbarIcon.Tooltip = "Enable Fly Camera (RMB: Lock Camera)";
}

private void _hotbarIcon_onLeftClick(object sender, EventArgs e)
{
Enabled = !Enabled;
if (Enabled)
if (LockCamera)
{
Enable();
}
else
{
Enabled = !Enabled;
if (Enabled)
{
Enable();
}
else
{
Disable();
}
}
}

private void _hotbarIcon_onRightClick(object sender, EventArgs e)
{
if (!LockCamera)
{
Enable();
this._hotbarIcon.Opacity = .75f;
LockCamera = true;
HotbarIcon.Tooltip = "Enable Fly Camera (RMB: Disable Lock Camera)";
}
else
{
Expand All @@ -69,6 +97,7 @@ public override void MyGroupUpdated()
if (!HasPermissionToUse)
{
Enabled = false;
LockCamera = false;
}
base.MyGroupUpdated();
}
Expand All @@ -80,13 +109,16 @@ public override void Update()
//move camera with arrow keys
float speed = 30f;

if (Main.keyState.IsKeyDown(Keys.LeftAlt)) speed *= .3f;
if (Main.keyState.IsKeyDown(Keys.LeftShift)) speed *= 1.5f;
if (!LockCamera)
{
if (Main.keyState.IsKeyDown(Keys.LeftAlt)) speed *= .3f;
if (Main.keyState.IsKeyDown(Keys.LeftShift)) speed *= 1.5f;

if (PlayerInput.Triggers.Current.KeyStatus["Left"]) FlyCamPosition.X -= speed;
if (PlayerInput.Triggers.Current.KeyStatus["Right"]) FlyCamPosition.X += speed;
if (PlayerInput.Triggers.Current.KeyStatus["Up"]) FlyCamPosition.Y -= speed;
if (PlayerInput.Triggers.Current.KeyStatus["Down"]) FlyCamPosition.Y += speed;
if (PlayerInput.Triggers.Current.KeyStatus["Left"]) FlyCamPosition.X -= speed;
if (PlayerInput.Triggers.Current.KeyStatus["Right"]) FlyCamPosition.X += speed;
if (PlayerInput.Triggers.Current.KeyStatus["Up"]) FlyCamPosition.Y -= speed;
if (PlayerInput.Triggers.Current.KeyStatus["Down"]) FlyCamPosition.Y += speed;
}

//Vector2 size = new Vector2(Main.screenWidth, Main.screenHeight);
//Main.screenPosition = FlyCamPosition - size / 2;
Expand All @@ -96,7 +128,7 @@ public override void Update()
Player player = Main.player[Main.myPlayer];

//if player right clicks, move their character to that position.
if (!Main.mapFullscreen && !player.mouseInterface && Main.mouseRight)
if (!Main.mapFullscreen && !player.mouseInterface && Main.mouseRight && !LockCamera && Main.mouseY < Main.screenHeight - 80)
{
Vector2 cursorPosition = new Vector2(Main.mouseX - player.width / 2, Main.mouseY - player.height);
Vector2 cursorWorldPosition = Main.screenPosition + cursorPosition;
Expand Down Expand Up @@ -130,7 +162,7 @@ public override void Destroy()

public override void Draw(SpriteBatch spriteBatch)
{
if (Enabled)
if (Enabled && !LockCamera)
{
Main.spriteBatch.DrawString(Main.fontMouseText, "Right Click to teleport", new Vector2(15, Main.screenHeight - 120), Color.White);
Main.spriteBatch.DrawString(Main.fontMouseText, "Arrow Keys to pan, Shift for faster, Alt for slower", new Vector2(15, Main.screenHeight - 90), Color.White);
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = HERO, jopojelly
version = 0.1.5.6
version = 0.1.5.7
displayName = HERO's Mod
homepage = http://forums.terraria.org/index.php?threads/heros-mod-creative-mode-server-management-and-over-25-tools-1-3-1-1-compatible.44650/
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, tmod\*, ignore\*, ZVidBuild\*, Images\Old*, Images\AllIcons.psd, .git\*, LICENSE, .gitignore
Expand Down

0 comments on commit e0a1d4b

Please sign in to comment.