Skip to content

Commit

Permalink
Pully and direction related documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Oct 12, 2023
1 parent a29c3ab commit 5c402d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ExampleMod/Content/Tiles/ExampleStatue.cs
Expand Up @@ -16,7 +16,7 @@ public class ExampleStatue : ModTile
Main.tileFrameImportant[Type] = true;
Main.tileObsidianKill[Type] = true;
TileID.Sets.DisableSmartCursor[Type] = true;
TileID.Sets.IsAMechanism[Type] = true; // Ensures that this tile and connected pressure plate won't be removed during the "Remove Broken Traps" worlden step
TileID.Sets.IsAMechanism[Type] = true; // Ensures that this tile and connected pressure plate won't be removed during the "Remove Broken Traps" worldgen step

TileObjectData.newTile.CopyFrom(TileObjectData.Style2xX);
TileObjectData.addTile(Type);
Expand Down
17 changes: 15 additions & 2 deletions patches/tModLoader/Terraria/Entity.cs.patch
@@ -1,6 +1,6 @@
--- src/TerrariaNetCore/Terraria/Entity.cs
+++ src/tModLoader/Terraria/Entity.cs
@@ -3,19 +_,51 @@
@@ -3,19 +_,54 @@

namespace Terraria;

Expand All @@ -23,7 +23,7 @@
internal long entityId;
+
+ /// <summary>
+ /// The position of this Entity in world coordinates.
+ /// The position of this Entity in world coordinates. Note that this corresponds to the top left corner of the entity. Use <see cref="Center"/> instead for logic that needs the position at the center of the entity.
+ /// </summary>
public Vector2 position;
+
Expand All @@ -34,6 +34,9 @@
public Vector2 oldPosition;
public Vector2 oldVelocity;
public int oldDirection;
+ /// <summary>
+ /// The direction this entity is facing. A value of 1 means the entity is facing to the right. -1 means facing to the left.
+ /// </summary>
public int direction = 1;
+
+ /// <summary>
Expand All @@ -53,3 +56,13 @@
public bool wet;
public bool shimmerWet;
public bool honeyWet;
@@ -24,6 +_,9 @@

public virtual Vector2 VisualPosition => position;

+ /// <summary>
+ /// The center position of this entity in world coordinates. Calculated from <see cref="position"/>, <see cref="width"/>, and <see cref="height"/>.
+ /// </summary>
public Vector2 Center {
get {
return new Vector2(position.X + (float)(width / 2), position.Y + (float)(height / 2));
18 changes: 16 additions & 2 deletions patches/tModLoader/Terraria/Player.cs.patch
Expand Up @@ -149,7 +149,7 @@
public int dashDelay;
public int eocDash;
public int eocHit;
@@ -601,6 +_,24 @@
@@ -601,8 +_,32 @@
public int gem = -1;
public int gemCount;
public BitsByte ownedLargeGems;
Expand All @@ -172,8 +172,16 @@
+ // Concrete use cases exist. Just gotta find a way to make a system for them intuitive.
+ // - Thomas
public byte meleeEnchant;
+ /// <summary>
+ /// While attached to a rope or similar tile (<see cref="pulley"/>), this value represents the how close to the rope the player is. A value of 1 means the player is centered on the rope, while a value of 2 represents that the player has nudged away from the rope but is still attached. <see cref="Entity.direction"/> is used still for the players direction.
+ /// </summary>
public byte pulleyDir;
+ /// <summary>
+ /// If true, the player is attached to a rope or similar tile.
+ /// </summary>
public bool pulley;
public int pulleyFrame;
public float pulleyFrameCounter;
@@ -612,6 +_,13 @@
public int snowBallLauncherInteractionCooldown;
public bool iceSkate;
Expand Down Expand Up @@ -5757,8 +5765,14 @@
if (num8 > 0)
DropItemFromExtractinator(num8, num9);
}
@@ -32784,6 +_,10 @@
@@ -32782,8 +_,16 @@
NetMessage.SendData(21, -1, -1, null, number, 1f);
}

+ /// <summary>
+ /// Changes the player's direction (<see cref="Entity.direction"/>) while adjusting arm and item rotations to be consistent. Will also account for <see cref="pulley"/> and <see cref="pulleyDir"/>. The player direction change will be prevented if the player is on a rope but there isn't space for the player to face the new direction.
+ /// </summary>
+ /// <param name="dir"></param>
public void ChangeDir(int dir)
{
+ // added by TML, forward port from 1.4.5
Expand Down

0 comments on commit 5c402d6

Please sign in to comment.