Skip to content

Commit

Permalink
PaintedFallingLeaf gore set, fix ExampleTreeLeaf (#3588)
Browse files Browse the repository at this point in the history
* PaintedFallingLeaf gore set, ChildSafely tweak

* revert ChildSafety change

* newline
  • Loading branch information
direwolf420 authored Jun 27, 2023
1 parent cf17cff commit e171965
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ExampleMod/Content/Tiles/Plants/ExampleTreeLeaf.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;

Expand All @@ -13,8 +9,9 @@ public class ExampleTreeLeaf : ModGore
public override string Texture => "ExampleMod/Content/Tiles/Plants/ExampleTree_Leaf";

public override void SetStaticDefaults() {

GoreID.Sets.SpecialAI[Type] = 3;
ChildSafety.SafeGore[Type] = true; // Leaf gore should appear regardless of the "Blood and Gore" setting
GoreID.Sets.SpecialAI[Type] = 3; // Falling leaf behavior
GoreID.Sets.PaintedFallingLeaf[Type] = true; // This is used for all vanilla tree leaves, related to the bigger spritesheet for tile paints
}
}
}
10 changes: 10 additions & 0 deletions patches/tModLoader/Terraria/Gore.cs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@
if (!ChildSafety.Disabled && ChildSafety.DangerousGore(Type)) {
Main.gore[num].type = Main.rand.Next(11, 14);
Main.gore[num].scale = Main.rand.NextFloat() * 0.5f + 0.5f;
@@ -1126,7 +_,8 @@
int num2 = GoreID.Sets.SpecialAI[Type];
if (num2 == 3) {
Main.gore[num].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 1f, Main.rand.NextFloat() * ((float)Math.PI * 2f));
- bool flag = (Type >= 910 && Type <= 925) || (Type >= 1113 && Type <= 1121) || (Type >= 1248 && Type <= 1255) || Type == 1257 || Type == 1278;
+ //bool flag = (Type >= 910 && Type <= 925) || (Type >= 1113 && Type <= 1121) || (Type >= 1248 && Type <= 1255) || Type == 1257 || Type == 1278;
+ bool flag = GoreID.Sets.PaintedFallingLeaf[Type];
Gore obj = Main.gore[num];
SpriteFrame spriteFrame = new SpriteFrame((byte)((!flag) ? 1u : 32u), 8) {
CurrentRow = (byte)Main.rand.Next(8)
@@ -1194,6 +_,9 @@

public Color GetAlpha(Color newColor)
Expand Down
7 changes: 7 additions & 0 deletions patches/tModLoader/Terraria/ID/GoreID.TML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ public static partial class Sets
/// <br/> Defaults to <see langword="false"/>.
/// </summary>
public static bool[] DrawBehind = Factory.CreateBoolSet(706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 943, 1147, 1160, 1161, 1162);

// TML: Definition from GoreID.Sets.SpecialAI[Type] == 3 check in 'Gore.NewGore'
/// <summary>
/// If <see langword="true"/> for a given gore type (<see cref="Gore.type"/>), then that gore has columns in its sprite corresponding to the amount of tile paints, and Gore.Frame.CurrentColumn will be set to tile.TileColor on spawn if it's coming from a tree via wind effects.
/// <br/> Defaults to <see langword="false"/>.
/// </summary>
public static bool[] PaintedFallingLeaf = Factory.CreateBoolSet(910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1257, 1278);
}
}

0 comments on commit e171965

Please sign in to comment.