Skip to content

Commit

Permalink
v1.10.1.1 - Updated some obsolete stuff (including overlooked snake c…
Browse files Browse the repository at this point in the history
…ase)
  • Loading branch information
hamstar0 committed Apr 30, 2020
1 parent efbb6d0 commit 471a437
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 58 deletions.
8 changes: 4 additions & 4 deletions Wormholes/Utils/SpriteAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public class SpriteAnimator {

////////////////

public SpriteAnimator( int frame_rate, int frame_count, Texture2D tex, Color color ) {
this.FrameRate = frame_rate;
this.FrameCount = frame_count;
this.BaseHeight = tex.Height / frame_count;
public SpriteAnimator( int frameRate, int frameCount, Texture2D tex, Color color ) {
this.FrameRate = frameRate;
this.FrameCount = frameCount;
this.BaseHeight = tex.Height / frameCount;
this.CurrentFrameStage = 0;
this._frame = new Rectangle( 0, 0, tex.Width, this.BaseHeight );
this._myColor = color;
Expand Down
3 changes: 1 addition & 2 deletions Wormholes/Wormholes/WormholeManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using HamstarHelpers.Helpers.Debug;
using HamstarHelpers.Helpers.Tiles;
Expand Down Expand Up @@ -240,7 +239,7 @@ public void FinishSettingUpWormholes() {
if( this.WormholesFinishedSpawning ) { return; }

if( WormholeManager.ForceRegenWormholes ) {
ErrorLogger.Log( " Regenerating ALL portals." );
LogHelpers.Log( " Regenerating ALL portals." );
this.Links = new List<WormholeLink>( WormholeManager.PortalCount );
}

Expand Down
37 changes: 19 additions & 18 deletions Wormholes/WormholesMod_Draw.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework.Graphics;
using HamstarHelpers.Helpers.Debug;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
Expand All @@ -15,7 +16,7 @@ public override void PostDrawInterface( SpriteBatch sb ) {
this.DrawMiniMap( sb );
}
} catch( Exception e ) {
ErrorLogger.Log( "PostDrawInterface: " + e.ToString() );
LogHelpers.Warn( e.ToString() );
throw e;
}
}
Expand All @@ -27,7 +28,7 @@ public override void PostDrawFullscreenMap( ref string mouseText ) {
try {
this.DrawFullMap( Main.spriteBatch );
} catch( Exception e ) {
ErrorLogger.Log( "PostDrawFullscreenMap: " + e.ToString() );
LogHelpers.Warn( e.ToString() );
throw e;
}
}
Expand All @@ -38,13 +39,13 @@ public override void PostDrawFullscreenMap( ref string mouseText ) {
private void DrawMiniMap( SpriteBatch sb ) {
this.UI.Update();

WormholesWorld modworld = ModContent.GetInstance<WormholesWorld>();
WormholesPlayer curr_modplayer = Main.player[Main.myPlayer].GetModPlayer<WormholesPlayer>();
WormholesWorld myworld = ModContent.GetInstance<WormholesWorld>();
WormholesPlayer myplayer = Main.LocalPlayer.GetModPlayer<WormholesPlayer>();

if( !this.Config.DisableNaturalWormholes ) {
if( modworld.Wormholes != null ) {
for( int i = 0; i < modworld.Wormholes.Links.Count; i++ ) {
WormholeLink link = modworld.Wormholes.Links[i];
if( myworld.Wormholes != null ) {
for( int i = 0; i < myworld.Wormholes.Links.Count; i++ ) {
WormholeLink link = myworld.Wormholes.Links[i];
if( link == null ) { break; }

if( Main.mapStyle == 1 ) {
Expand All @@ -56,11 +57,11 @@ private void DrawMiniMap( SpriteBatch sb ) {
}
}

if( curr_modplayer.MyPortal != null ) {
if( myplayer.MyPortal != null ) {
if( Main.mapStyle == 1 ) {
this.UI.DrawMiniMap( curr_modplayer.MyPortal, sb );
this.UI.DrawMiniMap( myplayer.MyPortal, sb );
} else {
this.UI.DrawOverlayMap( curr_modplayer.MyPortal, sb );
this.UI.DrawOverlayMap( myplayer.MyPortal, sb );
}
}
}
Expand All @@ -69,22 +70,22 @@ private void DrawMiniMap( SpriteBatch sb ) {
private void DrawFullMap( SpriteBatch sb ) {
this.UI.Update();

WormholesWorld modworld = ModContent.GetInstance<WormholesWorld>();
WormholesPlayer curr_modplayer = Main.player[Main.myPlayer].GetModPlayer<WormholesPlayer>();
WormholesWorld myworld = ModContent.GetInstance<WormholesWorld>();
WormholesPlayer myplayer = Main.LocalPlayer.GetModPlayer<WormholesPlayer>();

if( !this.Config.DisableNaturalWormholes ) {
if( modworld.Wormholes != null ) {
for( int i = 0; i < modworld.Wormholes.Links.Count; i++ ) {
WormholeLink link = modworld.Wormholes.Links[i];
if( myworld.Wormholes != null ) {
for( int i = 0; i < myworld.Wormholes.Links.Count; i++ ) {
WormholeLink link = myworld.Wormholes.Links[i];
if( link == null ) { break; }

this.UI.DrawFullscreenMap( link, sb );
}
}
}

if( curr_modplayer.MyPortal != null ) {
this.UI.DrawFullscreenMap( curr_modplayer.MyPortal, sb );
if( myplayer.MyPortal != null ) {
this.UI.DrawFullscreenMap( myplayer.MyPortal, sb );
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions Wormholes/WormholesPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public override void clientClone( ModPlayer clone ) {
////////////////

public override void Load( TagCompound tag ) {
var modworld = ModContent.GetInstance<WormholesWorld>();
int wormholes = tag.GetInt( "wormholes_count" );

this.TownPortalRightPositions = new Dictionary<string, Vector2>();
Expand All @@ -58,8 +57,8 @@ public override void Load( TagCompound tag ) {
this.ChartedLinks.Add( id );
}

int my_portal_count = tag.GetInt( "my_town_portal_count" );
for( int i=0; i<my_portal_count; i++ ) {
int myPortalCount = tag.GetInt( "my_town_portal_count" );
for( int i=0; i<myPortalCount; i++ ) {
string worldId = tag.GetString( "my_town_portal_id_" + i );
float rightX = tag.GetFloat( "my_town_right_portal_x_" + i );
float rightY = tag.GetFloat( "my_town_right_portal_y_" + i );
Expand Down
56 changes: 28 additions & 28 deletions Wormholes/WormholesUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ public void DrawMiniMap( WormholeLink link, SpriteBatch sb ) {
float scale = Main.mapMinimapScale / 1.5f;
Texture2D tex = WormholesUI.Tex;

Rectangle l_rect = new Rectangle( (int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height );
Rectangle r_rect = new Rectangle( (int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height );
Rectangle lRect = new Rectangle( (int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height );
Rectangle rRect = new Rectangle( (int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height );

var l_pos_data = HUDMapHelpers.GetMiniMapScreenPosition( l_rect );
if( l_pos_data.Item2 ) {
Color l_color = link.LeftPortal.BaseColor * Main.mapMinimapAlpha;
sb.Draw( tex, l_pos_data.Item1, this.TexAnim.Frame, l_color, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
var lPosData = HUDMapHelpers.GetMiniMapPositionAsScreenPosition( lRect );
if( lPosData.IsOnScreen ) {
Color lColor = link.LeftPortal.BaseColor * Main.mapMinimapAlpha;
sb.Draw( tex, lPosData.Item1, this.TexAnim.Frame, lColor, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
}

var r_pos_data = HUDMapHelpers.GetMiniMapScreenPosition( r_rect );
if( r_pos_data.Item2 ) {
Color r_color = link.RightPortal.BaseColor * Main.mapMinimapAlpha;
sb.Draw( tex, r_pos_data.Item1, this.TexAnim.Frame, r_color, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
var rPosData = HUDMapHelpers.GetMiniMapPositionAsScreenPosition( rRect );
if( rPosData.IsOnScreen ) {
Color rColor = link.RightPortal.BaseColor * Main.mapMinimapAlpha;
sb.Draw( tex, rPosData.Item1, this.TexAnim.Frame, rColor, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
}
}

Expand All @@ -70,19 +70,19 @@ public void DrawOverlayMap( WormholeLink link, SpriteBatch sb ) {
float scale = Main.mapOverlayScale / 1.5f;
Texture2D tex = WormholesUI.Tex;

Rectangle l_rect = new Rectangle( (int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height );
Rectangle r_rect = new Rectangle( (int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height );
Rectangle lRect = new Rectangle( (int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height );
Rectangle rRect = new Rectangle( (int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height );

var l_pos_data = HUDMapHelpers.GetOverlayMapScreenPosition( l_rect );
if( l_pos_data.Item2 ) {
Color l_color = link.LeftPortal.BaseColor * Main.mapOverlayAlpha;
sb.Draw( tex, (Vector2)l_pos_data.Item1, this.TexAnim.Frame, l_color, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
var lPosData = HUDMapHelpers.GetOverlayMapPositionAsScreenPosition( lRect );
if( lPosData.IsOnScreen ) {
Color lColor = link.LeftPortal.BaseColor * Main.mapOverlayAlpha;
sb.Draw( tex, (Vector2)lPosData.Item1, this.TexAnim.Frame, lColor, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
}

var r_pos_data = HUDMapHelpers.GetOverlayMapScreenPosition( r_rect );
if( r_pos_data.Item2 ) {
Color r_color = link.RightPortal.BaseColor * Main.mapOverlayAlpha;
sb.Draw( tex, r_pos_data.Item1, this.TexAnim.Frame, r_color, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
var rPosData = HUDMapHelpers.GetOverlayMapPositionAsScreenPosition( rRect );
if( rPosData.IsOnScreen ) {
Color rColor = link.RightPortal.BaseColor * Main.mapOverlayAlpha;
sb.Draw( tex, rPosData.Item1, this.TexAnim.Frame, rColor, 0f, new Vector2(), scale, SpriteEffects.None, 1f );
}
}

Expand All @@ -93,16 +93,16 @@ public void DrawFullscreenMap( WormholeLink link, SpriteBatch sb ) {
float scale = Main.mapFullscreenScale / 1.5f;
Texture2D tex = WormholesUI.Tex;

Rectangle l_rect = new Rectangle( (int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height );
var l_pos_data = HUDMapHelpers.GetFullMapScreenPosition( l_rect );
if( l_pos_data.Item2 ) {
sb.Draw( tex, l_pos_data.Item1, this.TexAnim.Frame, link.LeftPortal.BaseColor, 0f, new Vector2 { }, scale, SpriteEffects.None, 1f );
Rectangle lRect = new Rectangle( (int)link.LeftPortal.Pos.X, (int)link.LeftPortal.Pos.Y, tex.Width, tex.Height );
var lPosData = HUDMapHelpers.GetFullMapPositionAsScreenPosition( lRect );
if( lPosData.IsOnScreen ) {
sb.Draw( tex, lPosData.Item1, this.TexAnim.Frame, link.LeftPortal.BaseColor, 0f, new Vector2 { }, scale, SpriteEffects.None, 1f );
}

Rectangle r_rect = new Rectangle( (int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height );
var r_pos_data = HUDMapHelpers.GetFullMapScreenPosition( r_rect );
if( r_pos_data.Item2 ) {
sb.Draw( tex, r_pos_data.Item1, this.TexAnim.Frame, link.RightPortal.BaseColor, 0f, new Vector2 { }, scale, SpriteEffects.None, 1f );
Rectangle rRect = new Rectangle( (int)link.RightPortal.Pos.X, (int)link.RightPortal.Pos.Y, tex.Width, tex.Height );
var rPosData = HUDMapHelpers.GetFullMapPositionAsScreenPosition( rRect );
if( rPosData.IsOnScreen ) {
sb.Draw( tex, rPosData.Item1, this.TexAnim.Frame, link.RightPortal.BaseColor, 0f, new Vector2 { }, scale, SpriteEffects.None, 1f );
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Wormholes/WormholesWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public override void NetSend( BinaryWriter writer ) {
}

public override void NetReceive( BinaryReader reader ) {
bool has_correct_id = reader.ReadBoolean();
bool hasCorrectId = reader.ReadBoolean();
string id = reader.ReadString();

if( has_correct_id ) {
this.HasCorrectID = has_correct_id;
if( hasCorrectId ) {
this.HasCorrectID = hasCorrectId;
this.ID = id;

var modplayer = Main.player[Main.myPlayer].GetModPlayer<WormholesPlayer>();
Expand Down

0 comments on commit 471a437

Please sign in to comment.