Skip to content

Commit

Permalink
[HaCreator] simulator mode: draw mob debug tooltip info
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed May 24, 2023
1 parent 864c60f commit 028b7b8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 13 deletions.
31 changes: 22 additions & 9 deletions HaCreator/MapEditor/Info/MobInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public class MobInfo : MapleExtractableInfo

private WzImage _LinkedWzImage;

/// <summary>
/// Constructor
/// </summary>
/// <param name="image"></param>
/// <param name="origin"></param>
/// <param name="id"></param>
/// <param name="name"></param>
/// <param name="parentObject"></param>
public MobInfo(Bitmap image, System.Drawing.Point origin, string id, string name, WzObject parentObject)
: base(image, origin, parentObject)
{
Expand Down Expand Up @@ -119,16 +127,21 @@ public WzImage LinkedWzImage
{
get
{
WzStringProperty link = (WzStringProperty)((WzSubProperty)((WzImage)ParentObject)["info"])["link"];
if (link != null)
{
string linkImgName = WzInfoTools.AddLeadingZeros(link.Value, 7) + ".img";
_LinkedWzImage = (WzImage)Program.WzManager.FindWzImageByName("mob", linkImgName);
}
else
{
if (_LinkedWzImage == null) {
string imgName = WzInfoTools.AddLeadingZeros(id, 7) + ".img";
_LinkedWzImage = (WzImage)Program.WzManager.FindWzImageByName("mob", imgName); // default

WzImage mobImage = (WzImage)Program.WzManager.FindWzImageByName("mob", imgName); // default;

WzStringProperty link = (WzStringProperty)((WzSubProperty)((WzImage)ParentObject)["info"])["link"];
if (link != null) {
string linkImgName = WzInfoTools.AddLeadingZeros(link.Value, 7) + ".img";
WzImage linkedImage = (WzImage)Program.WzManager.FindWzImageByName("mob", linkImgName);

_LinkedWzImage = linkedImage ?? mobImage; // fallback to mobImage if linkedimage isnt available
}
else {
_LinkedWzImage = mobImage;
}
}
return _LinkedWzImage;
}
Expand Down
17 changes: 17 additions & 0 deletions HaCreator/MapEditor/Instance/MobInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,24 @@ namespace HaCreator.MapEditor.Instance
public class MobInstance : LifeInstance
{
private MobInfo baseInfo;
public MobInfo MobInfo { get { return baseInfo; } }

/// <summary>
/// Constructor
/// </summary>
/// <param name="baseInfo"></param>
/// <param name="board"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="rx0Shift"></param>
/// <param name="rx1Shift"></param>
/// <param name="yShift"></param>
/// <param name="limitedname"></param>
/// <param name="mobTime"></param>
/// <param name="flip"></param>
/// <param name="hide"></param>
/// <param name="info"></param>
/// <param name="team"></param>
public MobInstance(MobInfo baseInfo, Board board, int x, int y, int rx0Shift, int rx1Shift, int yShift, string limitedname, int? mobTime, MapleBool flip, MapleBool hide, int? info, int? team)
: base(baseInfo, board, x, y, rx0Shift, rx1Shift, yShift, limitedname, mobTime, flip, hide, info, team)
{
Expand Down
28 changes: 24 additions & 4 deletions HaCreator/MapSimulator/MapSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,24 +764,44 @@ protected override void Draw(GameTime gameTime)
}

// Life (NPC + Mobs)
foreach (MobItem mapMob in mapObjects_Mobs) // Mobs
foreach (MobItem mobItem in mapObjects_Mobs) // Mobs
{
MobInstance instance = mobItem.MobInstance;

ReflectionDrawableBoundary mirrorFieldData = null;
if (mirrorBottomReflection != null)
{
if (rect_mirrorBottom.Contains(new Point(mapMob.MobInstance.X, mapMob.MobInstance.Y)))
if (rect_mirrorBottom.Contains(new Point(mobItem.MobInstance.X, mobItem.MobInstance.Y)))
mirrorFieldData = mirrorBottomReflection;
}
if (mirrorFieldData == null) // a field may contain both 'info/mirror_Bottom' and 'MirrorFieldData'
mirrorFieldData = mapBoard.BoardItems.CheckObjectWithinMirrorFieldDataBoundary(mapMob.MobInstance.X, mapMob.MobInstance.Y, MirrorFieldDataType.mob)?.ReflectionInfo;
mirrorFieldData = mapBoard.BoardItems.CheckObjectWithinMirrorFieldDataBoundary(mobItem.MobInstance.X, mobItem.MobInstance.Y, MirrorFieldDataType.mob)?.ReflectionInfo;

mapMob.Draw(spriteBatch, skeletonMeshRenderer, gameTime,
mobItem.Draw(spriteBatch, skeletonMeshRenderer, gameTime,
mapShiftX, mapShiftY, mapCenterX, mapCenterY,
mirrorFieldData,
RenderWidth, RenderHeight, RenderObjectScaling, mapRenderResolution,
TickCount);

// Draw mobs debug tooltip
if (bShowDebugMode) {
Rectangle rect = new Rectangle(
instance.X - shiftCenteredX - (instance.Width - 20),
instance.Y - shiftCenteredY - instance.Height,
Math.Max(100, instance.Width + 40),
Math.Max(120, instance.Height));

DrawBorder(spriteBatch, rect, 1, Color.White, new Color(Color.Gray, 0.3f));

StringBuilder sb = new StringBuilder();
sb.Append(" x: ").Append(rect.X).Append(Environment.NewLine);
sb.Append(" y: ").Append(rect.Y).Append(Environment.NewLine);
sb.Append(" id: ").Append(instance.MobInfo.ID).Append(Environment.NewLine);
sb.Append(" name: ").Append(instance.MobInfo.Name).Append(Environment.NewLine);

spriteBatch.DrawString(font_DebugValues, sb.ToString(), new Vector2(rect.X, rect.Y), Color.White);
Debug.WriteLine(rect.ToString());
}
}
foreach (NpcItem mapNpc in mapObjects_NPCs) // NPCs (always in front of mobs)
{
Expand Down

0 comments on commit 028b7b8

Please sign in to comment.