-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #951 from hyamw/master
+ Add plugin for find plantera bulb
- Loading branch information
Showing
11 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using TEditXna.ViewModel; | ||
using TEditXNA.Terraria; | ||
|
||
namespace TEditXna.Editor.Plugins | ||
{ | ||
class FindPlanteraBulbPlugin : BasePlugin | ||
{ | ||
public FindPlanteraBulbPlugin(WorldViewModel worldViewModel) | ||
: base(worldViewModel) | ||
{ | ||
Name = "Find Plantera's Bulb"; | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
if (_wvm.CurrentWorld == null) return; | ||
|
||
List<Vector2> locations = new List<Vector2>(); | ||
|
||
// Search the whole World | ||
for (int x = 0; x < _wvm.CurrentWorld.TilesWide; x++) | ||
{ | ||
for (int y = 0; y < _wvm.CurrentWorld.TilesHigh; y++) | ||
{ | ||
// Check if a tile is a chest | ||
if (_wvm.CurrentWorld.Tiles[x, y].Type == (int)TileType.PlanteraBulb) | ||
{ | ||
if (!findConnectedTitle(locations, x, y)) | ||
{ | ||
locations.Add(new Vector2(x, y)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// show the result view with the list of locations | ||
FindChestWithPluginResultView resultView = new FindChestWithPluginResultView(locations); | ||
resultView.Show(); | ||
} | ||
|
||
protected bool findConnectedTitle(List<Vector2> locations, int x, int y) | ||
{ | ||
Vector2 position; | ||
for ( int i = 0; i < locations.Count; i++ ) | ||
{ | ||
position = locations[i]; | ||
if ( Math.Abs((int)position.X - x) <= 1 && Math.Abs((int)position.Y - y) <= 1 ) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v3.9.0.0 | ||
v3.9.16365.0959 |