Scaffold Kit
This commit is contained in:
1 parent
c66a484644
commit
29fd8dc6d7
15 files changed
+679
-1
No files matched your search
@@ -126,9 +126,13 @@ namespace CalamityMod.Effects
|
||||
Filters.Scene["PixelatedSightLine"] = new Filter(new ScreenShaderData(screenRef, "SightLinePass"), EffectPriority.High);
|
||||
Filters.Scene["PixelatedSightLine"].Load();
|
||||
|
||||
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/Compiler/WulfrumTilePing", AssetRequestMode.ImmediateLoad).Value);
|
||||
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/WulfrumTilePing", AssetRequestMode.ImmediateLoad).Value);
|
||||
Filters.Scene["WulfrumTilePing"] = new Filter(new ScreenShaderData(screenRef, "TilePingPass"), EffectPriority.High);
|
||||
Filters.Scene["WulfrumTilePing"].Load();
|
||||
|
||||
screenRef = new Ref<Effect>(CalamityMod.Instance.Assets.Request<Effect>("Effects/WulfrumScaffoldSelection", AssetRequestMode.ImmediateLoad).Value);
|
||||
Filters.Scene["WulfrumScaffoldSelection"] = new Filter(new ScreenShaderData(screenRef, "TilePingPass"), EffectPriority.High);
|
||||
Filters.Scene["WulfrumScaffoldSelection"].Load();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
float Resolution; //Pixel resolution
|
||||
|
||||
float time;
|
||||
float tileEdgeBlendStrenght; //How hard the border of a tile should get blended away.
|
||||
float mainOpacity;
|
||||
float blinkTime;
|
||||
|
||||
float4 baseTintColor; //Color of the tile's overlay
|
||||
float3 tileEdgeColor; //Color of the tile's edge effects
|
||||
float4 scanlineColor; //Color of the scanline effects
|
||||
float4 placementGlowColor; //Color of the tile when first placed
|
||||
|
||||
float4 ScanLines[10];
|
||||
int ScanLinesCount;
|
||||
int verticalScanLinesIndex;
|
||||
|
||||
//Per tile stuff
|
||||
float2 tilePosition; //The position of the top left of the tile
|
||||
bool4 cardinalConnections; //Up, Left, Right, Down connections.
|
||||
|
||||
|
||||
texture sampleTexture;
|
||||
sampler2D Texture1Sampler = sampler_state { texture = <sampleTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; };
|
||||
|
||||
bool AND(bool4 value)
|
||||
{
|
||||
return value.x && value.y && value.z && value.w;
|
||||
}
|
||||
|
||||
int COUNT(bool4 value)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (value.x)
|
||||
count++;
|
||||
if (value.y)
|
||||
count++;
|
||||
if (value.z)
|
||||
count++;
|
||||
if (value.w)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
float MOD(float a, float n)
|
||||
{
|
||||
return a - floor(a / n) * n;
|
||||
}
|
||||
|
||||
float inverselerp(float x, float start, float end)
|
||||
{
|
||||
return clamp((x - start) / (end - start), 0, 1);
|
||||
}
|
||||
|
||||
//Checks if a corner should be drawn or excluded, based on how many edges the pixel is near to.
|
||||
bool cornerDrawCheck(float2 position)
|
||||
{
|
||||
float oneEight = 1 / Resolution;
|
||||
float sevenEights = 7 / Resolution;
|
||||
|
||||
bool4 edgeChecks = bool4(false, false, false, false);
|
||||
|
||||
//top
|
||||
if (position.y < oneEight && !cardinalConnections.x)
|
||||
edgeChecks.x = true;
|
||||
|
||||
//bottom
|
||||
if (position.y >= sevenEights && !cardinalConnections.w)
|
||||
edgeChecks.w = true;
|
||||
|
||||
//left
|
||||
if (position.x < oneEight && !cardinalConnections.y)
|
||||
edgeChecks.y = true;
|
||||
|
||||
//right
|
||||
if (position.x >= sevenEights && !cardinalConnections.z)
|
||||
edgeChecks.z = true;
|
||||
|
||||
//if on 2 edges at once, youre on a corner
|
||||
return COUNT(edgeChecks) < 2;
|
||||
}
|
||||
|
||||
//Gets the gradient from the tile outline effects
|
||||
float getOpacityFromEdge(float2 position)
|
||||
{
|
||||
//If fully surrounded, don't draw anything
|
||||
if (AND(cardinalConnections))
|
||||
return 0;
|
||||
|
||||
float oneFourth = 1 / Resolution;
|
||||
float twoFourths = 3 / Resolution;
|
||||
float threeFourths = 4 / Resolution;
|
||||
float one = 7 / Resolution;
|
||||
|
||||
float baseOpacity = 0;
|
||||
|
||||
//up
|
||||
if (!cardinalConnections.x)
|
||||
baseOpacity += pow(inverselerp(position.y, twoFourths, 0), tileEdgeBlendStrenght);
|
||||
|
||||
//down
|
||||
if (!cardinalConnections.w)
|
||||
baseOpacity += pow(inverselerp(position.y, threeFourths, one), tileEdgeBlendStrenght);
|
||||
|
||||
//left
|
||||
if (!cardinalConnections.y)
|
||||
baseOpacity += pow(inverselerp(position.x, twoFourths, 0), tileEdgeBlendStrenght);
|
||||
|
||||
//right
|
||||
if (!cardinalConnections.z)
|
||||
baseOpacity += pow(inverselerp(position.x, threeFourths, one), tileEdgeBlendStrenght);
|
||||
|
||||
return baseOpacity;
|
||||
}
|
||||
|
||||
//Gets the opacity of the scanline on the specific pixel
|
||||
float getOpacityFromScanLine(float2 position)
|
||||
{
|
||||
float opacity = 0;
|
||||
float4 scanline;
|
||||
|
||||
//x = offset from origin, y = period, z = speed, w = opacity.
|
||||
for (int i = 0; i < ScanLinesCount; i++)
|
||||
{
|
||||
scanline = ScanLines[i];
|
||||
|
||||
float pixelPos;
|
||||
if (i >= verticalScanLinesIndex)
|
||||
pixelPos = (position.x + tilePosition.x / 16) % scanline.y;
|
||||
|
||||
else
|
||||
pixelPos = (position.y + tilePosition.y / 16) % scanline.y;
|
||||
|
||||
//Custom mod in case scanline.z is negative, aka the scanline moves in the opposite direction.
|
||||
float scanlinePos = MOD((scanline.x + time * scanline.z), scanline.y);
|
||||
|
||||
scanlinePos -= scanlinePos % (1 / Resolution);
|
||||
|
||||
pixelPos -= pixelPos % (1 / Resolution);
|
||||
|
||||
if (pixelPos == scanlinePos)
|
||||
opacity += scanline.w;
|
||||
}
|
||||
|
||||
|
||||
return opacity * (scanlineColor.a - baseTintColor.a);
|
||||
}
|
||||
|
||||
float4 main(float2 uv : TEXCOORD) : COLOR
|
||||
{
|
||||
//Pixelate
|
||||
uv.x -= uv.x % (1 / Resolution);
|
||||
uv.y -= uv.y % (1 / Resolution);
|
||||
|
||||
//Don't draw the corner the case of a missing corner.
|
||||
if (!cornerDrawCheck(uv))
|
||||
return float4(0, 0, 0, 0);
|
||||
|
||||
|
||||
float3 ColorTotal = lerp(baseTintColor.rgb, placementGlowColor.rgb, blinkTime);
|
||||
float OpacityTotal = lerp(baseTintColor.a, placementGlowColor.a, blinkTime);
|
||||
|
||||
//Do the outlines
|
||||
float tileEdgeBlend = getOpacityFromEdge(uv);
|
||||
OpacityTotal = lerp(OpacityTotal, 1, tileEdgeBlend);
|
||||
ColorTotal = lerp(ColorTotal, tileEdgeColor, tileEdgeBlend);
|
||||
|
||||
float scanlineOpacity = getOpacityFromScanLine(uv);
|
||||
if (scanlineOpacity > 0)
|
||||
{
|
||||
OpacityTotal += scanlineOpacity;
|
||||
ColorTotal = lerp(ColorTotal, scanlineColor.rgb, scanlineOpacity);
|
||||
}
|
||||
|
||||
//General fade out
|
||||
OpacityTotal *= mainOpacity;
|
||||
|
||||
ColorTotal = ColorTotal * OpacityTotal;
|
||||
return float4(ColorTotal, OpacityTotal);
|
||||
}
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass TileSelectPass
|
||||
{
|
||||
PixelShader = compile ps_3_0 main();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
File renamed without changes.
Binary file not shown.
@@ -97,6 +97,7 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.WorldGen.Chlorophyte += AdjustChlorophyteSpawnLimits;
|
||||
IL.Terraria.GameContent.UI.States.UIWorldCreation.SetDefaultOptions += ChangeDefaultWorldSize;
|
||||
IL.Terraria.GameContent.UI.States.UIWorldCreation.AddWorldSizeOptions += SwapSmallDescriptionKey;
|
||||
On.Terraria.IO.WorldFile.ClearTempTiles += ClearModdedTempTiles;
|
||||
|
||||
// Removal of vanilla stupidity
|
||||
IL.Terraria.GameContent.Events.Sandstorm.HasSufficientWind += DecreaseSandstormWindSpeedRequirement;
|
||||
@@ -120,6 +121,8 @@ namespace CalamityMod.ILEditing
|
||||
// IL.Terraria.Main.DoUpdate += FixProjectileUpdatePriorityProblems;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unloads all IL Editing changes in the mod.
|
||||
/// </summary>
|
||||
@@ -191,6 +194,7 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.WorldGen.Chlorophyte -= AdjustChlorophyteSpawnLimits;
|
||||
IL.Terraria.GameContent.UI.States.UIWorldCreation.SetDefaultOptions -= ChangeDefaultWorldSize;
|
||||
IL.Terraria.GameContent.UI.States.UIWorldCreation.AddWorldSizeOptions -= SwapSmallDescriptionKey;
|
||||
On.Terraria.IO.WorldFile.ClearTempTiles -= ClearModdedTempTiles;
|
||||
|
||||
// Removal of vanilla stupidity
|
||||
IL.Terraria.GameContent.Events.Sandstorm.HasSufficientWind -= DecreaseSandstormWindSpeedRequirement;
|
||||
|
||||
@@ -206,5 +206,21 @@ namespace CalamityMod.ILEditing
|
||||
c.Emit(OpCodes.Ldstr, "Mods.CalamityMod.UI.SmallWorldWarning");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Clear temporary modded tiles
|
||||
private static void ClearModdedTempTiles(On.Terraria.IO.WorldFile.orig_ClearTempTiles orig)
|
||||
{
|
||||
orig();
|
||||
|
||||
for (int i = 0; i < Main.maxTilesX; i++)
|
||||
{
|
||||
for (int j = 0; j < Main.maxTilesY; j++)
|
||||
{
|
||||
if (Main.tile[i, j].TileType == Items.Tools.WulfrumScaffoldKit.PlacedTileType)
|
||||
WorldGen.KillTile(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using CalamityMod.Items.Materials;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Systems;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.IO;
|
||||
using CalamityMod.Projectiles.Typeless;
|
||||
using CalamityMod.Tiles;
|
||||
|
||||
namespace CalamityMod.Items.Tools
|
||||
{
|
||||
public class WulfrumScaffoldKit : ModItem
|
||||
{
|
||||
public int storedScrap = 0;
|
||||
public static int TilesPerScrap = 40;
|
||||
public static int TileTime = 6 * 60;
|
||||
public static int TileReach = 40;
|
||||
public static int PlacedTileType => ModContent.TileType<WulfrumPipes>();
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Wulfrum Scaffold Kit");
|
||||
Tooltip.SetDefault("\"For when you need something built fast and don't need it to last.\"\n" +
|
||||
"Places down temporary metal scaffolding. Uses up one wulfrum metal scrap for " + TilesPerScrap.ToString() + " tiles built"
|
||||
);
|
||||
SacrificeTotal = 1;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 52;
|
||||
Item.height = 42;
|
||||
Item.useTime = Item.useAnimation = 25;
|
||||
Item.autoReuse = false;
|
||||
Item.noUseGraphic = true;
|
||||
Item.useStyle = ItemUseStyleID.HiddenAnimation;
|
||||
Item.UseSound = null;
|
||||
Item.noMelee = true;
|
||||
Item.channel = true;
|
||||
Item.rare = ItemRarityID.Blue;
|
||||
Item.value = Item.buyPrice(silver: 50);
|
||||
storedScrap = 0;
|
||||
Item.shoot = ModContent.ProjectileType<WulfrumScaffoldKitHoldout>();
|
||||
TileTime = 6 * 60;
|
||||
}
|
||||
|
||||
public override void HoldItem(Player player)
|
||||
{
|
||||
player.Calamity().mouseWorldListener = true;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
return storedScrap > 0 || player.HasItem(ModContent.ItemType<WulfrumShard>());
|
||||
}
|
||||
|
||||
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
||||
{
|
||||
float barScale = 1f;
|
||||
|
||||
var barBG = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GenericBarBack").Value;
|
||||
var barFG = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GenericBarFront").Value;
|
||||
|
||||
Vector2 drawPos = position + Vector2.UnitY * (frame.Height - 2) * scale + Vector2.UnitX * (frame.Width - barBG.Width * barScale) * scale * 0.5f;
|
||||
Rectangle frameCrop = new Rectangle(0, 0, (int)(storedScrap / (float)TilesPerScrap * barFG.Width), barFG.Height);
|
||||
Color colorBG = Color.RoyalBlue;
|
||||
Color colorFG = Color.Lerp(Color.Teal, Color.YellowGreen, storedScrap / (float)TilesPerScrap);
|
||||
|
||||
spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, origin, scale * barScale, 0f, 0f);
|
||||
spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG * 0.8f, 0f, origin, scale * barScale, 0f, 0f);
|
||||
}
|
||||
|
||||
|
||||
#region saving the durability
|
||||
public override ModItem Clone(Item item)
|
||||
{
|
||||
ModItem clone = base.Clone(item);
|
||||
if (clone is WulfrumScaffoldKit a && item.ModItem is WulfrumScaffoldKit a2)
|
||||
{
|
||||
a.storedScrap = a2.storedScrap;
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
public override void SaveData(TagCompound tag)
|
||||
{
|
||||
tag["storedScrap"] = storedScrap;
|
||||
}
|
||||
|
||||
public override void LoadData(TagCompound tag)
|
||||
{
|
||||
storedScrap = tag.GetInt("storedScrap");
|
||||
}
|
||||
|
||||
public override void NetSend(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(storedScrap);
|
||||
}
|
||||
|
||||
public override void NetReceive(BinaryReader reader)
|
||||
{
|
||||
storedScrap = reader.ReadInt32();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
//Intentionally craftable anywhere.
|
||||
CreateRecipe().
|
||||
AddIngredient<WulfrumShard>(6).
|
||||
AddIngredient<EnergyCore>(1).
|
||||
AddTile(TileID.Anvils).
|
||||
Register();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 903 B |
@@ -0,0 +1,70 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Items.Tools;
|
||||
using CalamityMod.Systems;
|
||||
using Terraria;
|
||||
using CalamityMod.Items.Materials;
|
||||
using System.Linq;
|
||||
using Terraria.ID;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.Graphics.Effects;
|
||||
|
||||
namespace CalamityMod.Projectiles.Typeless
|
||||
{
|
||||
public class WulfrumScaffoldKitCleanupManager : ModProjectile
|
||||
{
|
||||
//Probs need mp syncing
|
||||
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Wulfrum Scaffold Kit");
|
||||
}
|
||||
|
||||
public List<Point> ManagedTiles = new List<Point>(); //Might need some cloning stuff for mp? idk
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 1;
|
||||
Projectile.height = 1;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.netImportant = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
Projectile.timeLeft = WulfrumScaffoldKit.TileTime;
|
||||
}
|
||||
|
||||
public override bool? CanDamage() => false;
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Projectile.timeLeft < WulfrumScaffoldKit.TileTime * 0.1f)
|
||||
{
|
||||
int tileIndex = Main.rand.Next(ManagedTiles.Count);
|
||||
|
||||
if (Main.tile[ManagedTiles[tileIndex]].TileType == WulfrumScaffoldKit.PlacedTileType)
|
||||
{
|
||||
Vector2 dustpos = ManagedTiles[tileIndex].ToWorldCoordinates();
|
||||
Dust.NewDustPerfect(dustpos, 226, Main.rand.NextVector2Circular(4f, 4f), Scale: Main.rand.NextFloat(0.4f, 1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
foreach (Point pos in ManagedTiles)
|
||||
{
|
||||
if (Main.tile[pos].TileType == WulfrumScaffoldKit.PlacedTileType)
|
||||
{
|
||||
WorldGen.KillTile(pos.X, pos.Y);
|
||||
NetMessage.SendTileSquare(-1, pos.X, pos.Y, TileChangeType.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.Items.Tools;
|
||||
using CalamityMod.Systems;
|
||||
using Terraria;
|
||||
using CalamityMod.Items.Materials;
|
||||
using System.Linq;
|
||||
using Terraria.ID;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.Graphics.Effects;
|
||||
using System;
|
||||
|
||||
namespace CalamityMod.Projectiles.Typeless
|
||||
{
|
||||
public class WulfrumScaffoldKitHoldout : ModProjectile
|
||||
{
|
||||
public Player Owner => Main.player[Projectile.owner];
|
||||
public WulfrumScaffoldKit Kit => Owner.HeldItem.ModItem as WulfrumScaffoldKit;
|
||||
public bool CanOwnerGoOn => Kit.storedScrap > 0 || Owner.HasItem(ModContent.ItemType<WulfrumShard>());
|
||||
|
||||
public bool CanSelectTile(Point tilePos)
|
||||
{
|
||||
//You only need to check when starting a scaffold
|
||||
if (SelectedTiles.Count > 0)
|
||||
return CanSelectMoreTiles(tilePos);
|
||||
|
||||
|
||||
for (int i = -1; i < 2; i++)
|
||||
{
|
||||
for (int j = -1; j < 2; j++)
|
||||
{
|
||||
if (Main.tile[tilePos.X + i, tilePos.Y + j].IsTileFull())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CanSelectMoreTiles(Point tilePos)
|
||||
{
|
||||
for (int i = -2; i < 3; i++)
|
||||
{
|
||||
for (int j = -2; j < 3; j++)
|
||||
{
|
||||
if (Math.Abs(i) == 2 && Math.Abs(j) == 2)
|
||||
continue;
|
||||
|
||||
if (Main.tile[tilePos.X + i, tilePos.Y + j].TileType == WulfrumScaffoldKit.PlacedTileType || SelectedTiles.ContainsKey(new Point(tilePos.X + i, tilePos.Y + j)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Wulfrum Scaffold Kit");
|
||||
}
|
||||
|
||||
public static int tileGlowTime = 10;
|
||||
|
||||
public Dictionary<Point, int> SelectedTiles = new Dictionary<Point, int>(); //Might need some cloning stuff for mp? idk
|
||||
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Projectile.width = 1;
|
||||
Projectile.height = 1;
|
||||
Projectile.penetrate = -1;
|
||||
Projectile.netImportant = true;
|
||||
Projectile.tileCollide = false;
|
||||
Projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
public override bool? CanDamage() => false;
|
||||
public override bool ShouldUpdatePosition() => false;
|
||||
|
||||
/*
|
||||
public Vector2 raytracePosition()
|
||||
{
|
||||
//Don't raycast when the scaffold has been started, since itd be able to reach around walls and such.
|
||||
//At this stage, the raycast relies on the fact it needs proximity with other scaffolding
|
||||
if (SelectedTiles.Count > 0)
|
||||
return Projectile.position;
|
||||
|
||||
Vector2 properPosition = Owner.Center;
|
||||
Vector2 finalPosition = Projectile.position;
|
||||
|
||||
float steps = (properPosition - finalPosition).Length() / 8f;
|
||||
float strikes = 0;
|
||||
|
||||
//Fun fact this was a while loop before and obviously it ended up doing an infinite loop for whatever reason. Truly, while loops are peak.
|
||||
for (int i = 0; i < steps; i ++)
|
||||
{
|
||||
properPosition = properPosition.MoveTowards(finalPosition, 8);
|
||||
|
||||
if (Collision.SolidCollision(properPosition - Vector2.One * 1, 2, 2))
|
||||
strikes++;
|
||||
|
||||
if (strikes > 1)
|
||||
break;
|
||||
}
|
||||
|
||||
return properPosition;
|
||||
}
|
||||
*/
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
if (Owner.channel && CanOwnerGoOn)
|
||||
{
|
||||
//Initialize the position
|
||||
if (Projectile.timeLeft > 2)
|
||||
Projectile.position = Owner.Calamity().mouseWorld;
|
||||
|
||||
Projectile.position = Projectile.position.MoveTowards(Owner.Calamity().mouseWorld, 16);
|
||||
//Projectile.position = raytracePosition();
|
||||
|
||||
if ((Projectile.position - Owner.Center).Length() > WulfrumScaffoldKit.TileReach * 16)
|
||||
Projectile.position = Owner.Center + Vector2.Normalize(Projectile.position - Owner.Center) * WulfrumScaffoldKit.TileReach * 16;
|
||||
|
||||
if (Owner.whoAmI == Main.myPlayer)
|
||||
{
|
||||
Point tilePos = Projectile.position.ToTileCoordinates();
|
||||
Tile hoveredTile = Main.tile[tilePos];
|
||||
|
||||
if (!hoveredTile.HasTile && !SelectedTiles.ContainsKey(tilePos) && CanSelectTile(tilePos))
|
||||
{
|
||||
SelectedTiles.Add(tilePos, tileGlowTime);
|
||||
|
||||
if (Kit.storedScrap > 0)
|
||||
Kit.storedScrap--;
|
||||
|
||||
else
|
||||
{
|
||||
Owner.ConsumeItem(ModContent.ItemType<WulfrumShard>());
|
||||
Kit.storedScrap = WulfrumScaffoldKit.TilesPerScrap - 1;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Point position in SelectedTiles.Keys)
|
||||
{
|
||||
if (SelectedTiles[position] > 0)
|
||||
SelectedTiles[position]--;
|
||||
}
|
||||
}
|
||||
|
||||
Projectile.timeLeft = 2;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(ref Color lightColor)
|
||||
{
|
||||
if (Main.myPlayer != Owner.whoAmI)
|
||||
return false;
|
||||
|
||||
Texture2D sprite = ModContent.Request<Texture2D>(Texture).Value;
|
||||
|
||||
Effect tileEffect = Filters.Scene["WulfrumScaffoldSelection"].GetShader().Shader;
|
||||
|
||||
tileEffect.Parameters["mainOpacity"].SetValue(1f);
|
||||
tileEffect.Parameters["tileEdgeBlendStrenght"].SetValue(2f);
|
||||
tileEffect.Parameters["placementGlowColor"].SetValue(Color.GreenYellow.ToVector4());
|
||||
tileEffect.Parameters["baseTintColor"].SetValue(Color.DeepSkyBlue.ToVector4() * 0.5f);
|
||||
tileEffect.Parameters["scanlineColor"].SetValue(Color.YellowGreen.ToVector4() * 1f);
|
||||
tileEffect.Parameters["tileEdgeColor"].SetValue(Color.GreenYellow.ToVector3());
|
||||
tileEffect.Parameters["Resolution"].SetValue(8f);
|
||||
|
||||
tileEffect.Parameters["time"].SetValue(Main.GameUpdateCount);
|
||||
Vector4[] scanLines = new Vector4[]
|
||||
{
|
||||
new Vector4(0f, 4f, 0.1f, 0.5f),
|
||||
new Vector4(1f, 4f, 0.1f, 0.5f),
|
||||
new Vector4(37f, 60f, 0.4f, 1f),
|
||||
new Vector4(2f, 6f, -0.2f, 0.3f),
|
||||
new Vector4(0f, 4f, 0.1f, 0.5f), //vertical start
|
||||
new Vector4(1f, 4f, 0.1f, 0.5f),
|
||||
new Vector4(2f, 6f, -0.2f, 0.3f)
|
||||
};
|
||||
|
||||
tileEffect.Parameters["ScanLines"].SetValue(scanLines);
|
||||
tileEffect.Parameters["ScanLinesCount"].SetValue(scanLines.Length);
|
||||
tileEffect.Parameters["verticalScanLinesIndex"].SetValue(4);
|
||||
|
||||
Main.spriteBatch.End();
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, tileEffect, Main.GameViewMatrix.TransformationMatrix);
|
||||
|
||||
foreach (Point pos in SelectedTiles.Keys)
|
||||
{
|
||||
tileEffect.Parameters["blinkTime"].SetValue(SelectedTiles[pos] / (float)tileGlowTime);
|
||||
tileEffect.Parameters["cardinalConnections"].SetValue(new bool[] { Connected(pos, 0, -1), Connected(pos, -1, 0), Connected(pos, 1, 0), Connected(pos, 0, 1) });
|
||||
tileEffect.Parameters["tilePosition"].SetValue(pos.ToVector2() * 16f);
|
||||
|
||||
Main.spriteBatch.Draw(sprite, pos.ToWorldCoordinates() - Main.screenPosition, null, Color.White, 0, new Vector2(sprite.Width / 2f, sprite.Height / 2f), 16f, 0, 0);
|
||||
}
|
||||
|
||||
CalamityUtils.ExitShaderRegion(Main.spriteBatch);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Connected(Point pos, int displaceX, int displaceY) => SelectedTiles.ContainsKey(new Point(pos.X + displaceX, pos.Y + displaceY));
|
||||
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
|
||||
if (Main.myPlayer == Owner.whoAmI)
|
||||
{
|
||||
foreach (Point pos in SelectedTiles.Keys)
|
||||
{
|
||||
WorldGen.PlaceTile(pos.X, pos.Y, WulfrumScaffoldKit.PlacedTileType) ;
|
||||
NetMessage.SendTileSquare(-1, pos.X, pos.Y, TileChangeType.None);
|
||||
}
|
||||
|
||||
Projectile proj = Projectile.NewProjectileDirect(Projectile.GetSource_Death(), Projectile.position, Vector2.Zero, ModContent.ProjectileType<WulfrumScaffoldKitCleanupManager>(), 0, 0, Owner.whoAmI);
|
||||
(proj.ModProjectile as WulfrumScaffoldKitCleanupManager).ManagedTiles = SelectedTiles.Keys.ToList<Point>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,7 @@ namespace CalamityMod.Systems
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
bool check = Main.drawToScreen;
|
||||
//This makes it flash every other frame on smooth lighting modes
|
||||
pingedTiles.Clear();
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ID;
|
||||
using Terraria.Audio;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.DataStructures;
|
||||
using System;
|
||||
|
||||
namespace CalamityMod.Tiles
|
||||
{
|
||||
public class WulfrumPipes : ModTile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.tileSolid[Type] = true;
|
||||
Main.tileBlockLight[Type] = true;
|
||||
|
||||
HitSound = SoundID.Item52;
|
||||
DustType = 32;
|
||||
MinPick = 30;
|
||||
AddMapEntry(new Color(128, 90, 77));
|
||||
}
|
||||
|
||||
public override bool CanExplode(int i, int j) => false;
|
||||
|
||||
public override void PlaceInWorld(int i, int j, Item item)
|
||||
{
|
||||
SoundEngine.PlaySound(SoundID.Item52 with { Volume = SoundID.Item52.Volume * 0.75f, Pitch = SoundID.Item52.Pitch - 0.5f }, new Vector2( i * 16, j * 16 ));
|
||||
}
|
||||
|
||||
public override void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref TileDrawInfo drawData)
|
||||
{
|
||||
drawData.tileWidth += (int)Math.Sin(Main.GlobalTimeWrappedHourly) * 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
@@ -504,5 +504,11 @@ namespace CalamityMod
|
||||
/// </summary>
|
||||
/// <param name="tile">The tile to check.</param>
|
||||
public static bool IsTileSolid(this Tile tile) => tile != null && tile.HasUnactuatedTile && Main.tileSolid[tile.TileType] && !TileID.Sets.Platforms[tile.TileType];
|
||||
|
||||
/// <summary>
|
||||
/// Determines if a tile is "full" based on if the tile is solid. This will count platforms and actuated tiles but no other non-solid ground tiles.
|
||||
/// </summary>
|
||||
/// <param name="tile">The tile to check.</param>
|
||||
public static bool IsTileFull(this Tile tile) => tile != null && tile.HasTile && Main.tileSolid[tile.TileType];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user