Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ItemCheck_EmitHeldItemLight()

void Terraria.Player.ItemCheck_EmitHeldItemLight ( Item sItem)
inlineprivate

Definition at line 46949 of file Player.cs.

46950 {
46952 if (((ItemID.Sets.Torches[sItem.type] && !wet) || ItemID.Sets.WaterTorches[sItem.type]) && !pulley && !happyFunTorchTime)
46953 {
46954 float R = 1f;
46955 float G = 0.95f;
46956 float B = 0.8f;
46957 int num = 0;
46958 int num2 = BiomeTorchHoldStyle(sItem.type);
46959 if (num2 == 523)
46960 {
46961 num = 8;
46962 }
46963 else if (num2 == 974)
46964 {
46965 num = 9;
46966 }
46967 else if (num2 == 1245)
46968 {
46969 num = 10;
46970 }
46971 else if (num2 == 1333)
46972 {
46973 num = 11;
46974 }
46975 else if (num2 == 2274)
46976 {
46977 num = 12;
46978 }
46979 else if (num2 == 3004)
46980 {
46981 num = 13;
46982 }
46983 else if (num2 == 3045)
46984 {
46985 num = 14;
46986 }
46987 else if (num2 == 3114)
46988 {
46989 num = 15;
46990 }
46991 else if (num2 == 4383)
46992 {
46993 num = 16;
46994 }
46995 else if (num2 == 4384)
46996 {
46997 num = 17;
46998 }
46999 else if (num2 == 4385)
47000 {
47001 num = 18;
47002 }
47003 else if (num2 == 4386)
47004 {
47005 num = 19;
47006 }
47007 else if (num2 == 4387)
47008 {
47009 num = 20;
47010 }
47011 else if (num2 == 4388)
47012 {
47013 num = 21;
47014 }
47015 else if (num2 == 5293)
47016 {
47017 num = 22;
47018 }
47019 else if (num2 == 5353)
47020 {
47021 num = 23;
47022 }
47023 else if (num2 >= 427)
47024 {
47025 num = num2 - 426;
47026 }
47027 num = (int)MathHelper.Clamp(num, 0f, TorchID.Count - 1);
47028 TorchID.TorchColor(num, out R, out G, out B);
47029 int num3 = TorchID.Dust[num];
47030 int maxValue = 30;
47031 if (itemAnimation > 0)
47032 {
47033 maxValue = 7;
47034 }
47035 if (direction == -1)
47036 {
47037 if (Main.rand.Next(maxValue) == 0)
47038 {
47039 int num4 = Dust.NewDust(new Vector2(itemLocation.X - 16f, itemLocation.Y - 14f * gravDir), 4, 4, num3, 0f, 0f, 100);
47040 if (Main.rand.Next(3) != 0)
47041 {
47042 Main.dust[num4].noGravity = true;
47043 }
47044 Main.dust[num4].velocity *= 0.3f;
47045 Main.dust[num4].velocity.Y -= 1.5f;
47046 Main.dust[num4].position = RotatedRelativePoint(Main.dust[num4].position);
47047 if (num3 == 66)
47048 {
47049 Main.dust[num4].color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
47050 Main.dust[num4].noGravity = true;
47051 }
47052 }
47053 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 12f + velocity.X, itemLocation.Y - 14f + velocity.Y)), R, G, B);
47054 }
47055 else
47056 {
47057 if (Main.rand.Next(maxValue) == 0)
47058 {
47059 int num5 = Dust.NewDust(new Vector2(itemLocation.X + 6f, itemLocation.Y - 14f * gravDir), 4, 4, num3, 0f, 0f, 100);
47060 if (Main.rand.Next(3) != 0)
47061 {
47062 Main.dust[num5].noGravity = true;
47063 }
47064 Main.dust[num5].velocity *= 0.3f;
47065 Main.dust[num5].velocity.Y -= 1.5f;
47066 Main.dust[num5].position = RotatedRelativePoint(Main.dust[num5].position);
47067 if (num3 == 66)
47068 {
47069 Main.dust[num5].color = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
47070 Main.dust[num5].noGravity = true;
47071 }
47072 }
47073 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 12f + velocity.X, itemLocation.Y - 14f + velocity.Y)), R, G, B);
47074 }
47075 }
47076 if ((sItem.type == 105 || sItem.type == 713) && !wet && !pulley)
47077 {
47078 int maxValue2 = 20;
47079 if (itemAnimation > 0)
47080 {
47081 maxValue2 = 7;
47082 }
47083 if (direction == -1)
47084 {
47085 if (Main.rand.Next(maxValue2) == 0)
47086 {
47087 int num6 = Dust.NewDust(new Vector2(itemLocation.X - 12f, itemLocation.Y - 20f * gravDir), 4, 4, 6, 0f, 0f, 100);
47088 if (Main.rand.Next(3) != 0)
47089 {
47090 Main.dust[num6].noGravity = true;
47091 }
47092 Main.dust[num6].velocity *= 0.3f;
47093 Main.dust[num6].velocity.Y -= 1.5f;
47094 Main.dust[num6].position = RotatedRelativePoint(Main.dust[num6].position);
47095 }
47096 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), 1f, 0.95f, 0.8f);
47097 }
47098 else
47099 {
47100 if (Main.rand.Next(maxValue2) == 0)
47101 {
47102 int num7 = Dust.NewDust(new Vector2(itemLocation.X + 4f, itemLocation.Y - 20f * gravDir), 4, 4, 6, 0f, 0f, 100);
47103 if (Main.rand.Next(3) != 0)
47104 {
47105 Main.dust[num7].noGravity = true;
47106 }
47107 Main.dust[num7].velocity *= 0.3f;
47108 Main.dust[num7].velocity.Y -= 1.5f;
47109 Main.dust[num7].position = RotatedRelativePoint(Main.dust[num7].position);
47110 }
47111 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), 1f, 0.95f, 0.8f);
47112 }
47113 }
47114 else if (sItem.type == 148 && !wet && !pulley)
47115 {
47116 int maxValue3 = 10;
47117 if (itemAnimation > 0)
47118 {
47119 maxValue3 = 7;
47120 }
47121 if (direction == -1)
47122 {
47123 if (Main.rand.Next(maxValue3) == 0)
47124 {
47125 int num8 = Dust.NewDust(new Vector2(itemLocation.X - 12f, itemLocation.Y - 20f * gravDir), 4, 4, 172, 0f, 0f, 100);
47126 if (Main.rand.Next(3) != 0)
47127 {
47128 Main.dust[num8].noGravity = true;
47129 }
47130 Main.dust[num8].velocity *= 0.3f;
47131 Main.dust[num8].velocity.Y -= 1.5f;
47132 Main.dust[num8].position = RotatedRelativePoint(Main.dust[num8].position);
47133 }
47134 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), 0f, 0.5f, 1f);
47135 }
47136 else
47137 {
47138 if (Main.rand.Next(maxValue3) == 0)
47139 {
47140 int num9 = Dust.NewDust(new Vector2(itemLocation.X + 4f, itemLocation.Y - 20f * gravDir), 4, 4, 172, 0f, 0f, 100);
47141 if (Main.rand.Next(3) != 0)
47142 {
47143 Main.dust[num9].noGravity = true;
47144 }
47145 Main.dust[num9].velocity *= 0.3f;
47146 Main.dust[num9].velocity.Y -= 1.5f;
47147 Main.dust[num9].position = RotatedRelativePoint(Main.dust[num9].position);
47148 }
47149 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), 0f, 0.5f, 1f);
47150 }
47151 }
47152 else if (sItem.type == 3117 && !wet && !pulley)
47153 {
47154 itemLocation.X -= direction * 4;
47155 int maxValue4 = 10;
47156 if (itemAnimation > 0)
47157 {
47158 maxValue4 = 7;
47159 }
47160 if (direction == -1)
47161 {
47162 if (Main.rand.Next(maxValue4) == 0)
47163 {
47164 int num10 = Dust.NewDust(new Vector2(itemLocation.X - 10f, itemLocation.Y - 20f * gravDir), 4, 4, 242, 0f, 0f, 100);
47165 if (Main.rand.Next(3) != 0)
47166 {
47167 Main.dust[num10].noGravity = true;
47168 }
47169 Main.dust[num10].velocity *= 0.3f;
47170 Main.dust[num10].velocity.Y -= 1.5f;
47171 Main.dust[num10].position = RotatedRelativePoint(Main.dust[num10].position);
47172 }
47173 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), 0.9f, 0.1f, 0.75f);
47174 }
47175 else
47176 {
47177 if (Main.rand.Next(maxValue4) == 0)
47178 {
47179 int num11 = Dust.NewDust(new Vector2(itemLocation.X + 6f, itemLocation.Y - 20f * gravDir), 4, 4, 242, 0f, 0f, 100);
47180 if (Main.rand.Next(3) != 0)
47181 {
47182 Main.dust[num11].noGravity = true;
47183 }
47184 Main.dust[num11].velocity *= 0.3f;
47185 Main.dust[num11].velocity.Y -= 1.5f;
47186 Main.dust[num11].position = RotatedRelativePoint(Main.dust[num11].position);
47187 }
47188 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), 0.9f, 0.1f, 0.75f);
47189 }
47190 }
47191 else if (sItem.type == 5322 && !wet && !pulley)
47192 {
47193 float r = 0.2f;
47194 float g = 0.3f;
47195 float b = 0.32f;
47196 if (direction == -1)
47197 {
47198 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), r, g, b);
47199 }
47200 else
47201 {
47202 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), r, g, b);
47203 }
47204 }
47205 if (sItem.type == 282 && !pulley)
47206 {
47207 if (direction == -1)
47208 {
47209 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), 0.7f, 1f, 0.8f);
47210 }
47211 else
47212 {
47213 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), 0.7f, 1f, 0.8f);
47214 }
47215 }
47216 if (sItem.type == 3002 && !pulley)
47217 {
47218 float r2 = 1.05f;
47219 float g2 = 0.95f;
47220 float b2 = 0.55f;
47221 if (direction == -1)
47222 {
47223 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), r2, g2, b2);
47224 }
47225 else
47226 {
47227 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), r2, g2, b2);
47228 }
47230 if (spelunkerTimer >= 10)
47231 {
47232 spelunkerTimer = 0;
47233 Main.instance.SpelunkerProjectileHelper.AddSpotToCheck(base.Center);
47234 }
47235 }
47236 if (sItem.type == 286 && !pulley)
47237 {
47238 if (direction == -1)
47239 {
47240 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), 0.7f, 0.8f, 1f);
47241 }
47242 else
47243 {
47244 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), 0.7f, 0.8f, 1f);
47245 }
47246 }
47247 if (sItem.type == 3112 && !pulley)
47248 {
47249 if (direction == -1)
47250 {
47251 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X - 16f + velocity.X, itemLocation.Y - 14f)), 1f, 0.6f, 0.85f);
47252 }
47253 else
47254 {
47255 Lighting.AddLight(RotatedRelativePoint(new Vector2(itemLocation.X + 6f + velocity.X, itemLocation.Y - 14f)), 1f, 0.6f, 0.85f);
47256 }
47257 }
47258 if (sItem.type == 4776 && !pulley)
47259 {
47261 if (direction == -1)
47262 {
47264 }
47265 Vector3 rgb = (DelegateMethods.v3_1 = new Vector3(0.9f, 0.35f, 1f));
47266 Point p = vec.ToTileCoordinates();
47267 DelegateMethods.v2_1 = p.ToVector2();
47268 DelegateMethods.f_1 = 4.5f;
47269 Utils.PlotTileArea(p.X, p.Y, DelegateMethods.SpreadLightOpen_StopForSolids);
47270 Lighting.AddLight(vec, rgb);
47271 }
47272 if (sItem.type == 3542 && handPosition.HasValue)
47273 {
47274 Vector2 vector = handPosition.Value - velocity;
47275 for (int i = 0; i < 4; i++)
47276 {
47277 Dust dust = Main.dust[Dust.NewDust(base.Center, 0, 0, 242, direction * 2, 0f, 150, default(Color), 1.3f)];
47278 dust.position = vector;
47279 dust.velocity *= 0f;
47280 dust.noGravity = true;
47281 dust.fadeIn = 1f;
47282 dust.velocity += velocity;
47283 if (Main.rand.Next(2) == 0)
47284 {
47285 dust.position += Utils.RandomVector2(Main.rand, -4f, 4f);
47286 dust.scale += Main.rand.NextFloat();
47287 if (Main.rand.Next(2) == 0)
47288 {
47289 dust.customData = this;
47290 }
47291 }
47292 }
47293 }
47294 if (sItem.type != 4952 || pulley || isPettingAnimal)
47295 {
47296 return;
47297 }
47298 Vector2 pos = itemLocation + new Vector2(8 * direction, -10f * gravDir);
47299 Vector3 rgb2 = new Vector3(1f, 0.7f, 0.8f) * 1.3f;
47301 Lighting.AddLight(vector2, rgb2);
47302 if (Main.rand.Next(40) == 0)
47303 {
47304 Vector2 vector3 = Main.rand.NextVector2Circular(4f, 4f);
47305 Dust dust2 = Dust.NewDustPerfect(vector2 + vector3, 43, Vector2.Zero, 254, new Color(255, 255, 0, 255), 0.3f);
47306 if (vector3 != Vector2.Zero)
47307 {
47308 dust2.velocity = vector2.DirectionTo(dust2.position) * 0.2f;
47309 }
47310 dust2.fadeIn = 0.3f;
47311 dust2.noLightEmittence = true;
47312 dust2.customData = this;
47313 }
47314 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
Vector2 velocity
Definition Entity.cs:16
static bool[] Torches
Definition ItemID.cs:1110
static bool[] WaterTorches
Definition ItemID.cs:1112
static readonly short Count
Definition TorchID.cs:132
static int[] Dust
Definition TorchID.cs:75
static void TorchColor(int torchID, out float R, out float G, out float B)
Definition TorchID.cs:164
byte spelunkerTimer
Definition Player.cs:595
bool happyFunTorchTime
Definition Player.cs:2625
bool isPettingAnimal
Definition Player.cs:2459
int BiomeTorchHoldStyle(int style)
Definition Player.cs:37985
Vector2? HandPosition
Definition Player.cs:3576
Vector2 RotatedRelativePoint(Vector2 pos, bool reverseRotation=false, bool addGfxOffY=true)
Definition Player.cs:3618
Vector2 itemLocation
Definition Player.cs:1183

References Terraria.Lighting.AddLight(), System.B, Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.ID.TorchID.Count, Terraria.Main.DiscoB, Terraria.Main.DiscoG, Terraria.Main.DiscoR, Terraria.ID.TorchID.Dust, Terraria.Main.dust, System.G, Terraria.Main.instance, Terraria.Dust.NewDust(), Terraria.Dust.NewDustPerfect(), Terraria.Utils.PlotTileArea(), System.R, Terraria.Main.rand, Terraria.Utils.RandomVector2(), Terraria.DelegateMethods.SpreadLightOpen_StopForSolids(), Terraria.ID.TorchID.TorchColor(), Terraria.ID.ItemID.Sets.Torches, Terraria.ID.ItemID.Sets.WaterTorches, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Point.Y, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.