Added Draedon weapon chargers and generators. As of pushing this, it uses dirt blocks as fuel. This will be changed when a sprite and name are decided for the actual fuel. These have been roughly tested in Multiplayer. No remaining bugs exist to my knowledge. Added a schematic worldgen system. There are two .cs files that they use with autogenerated code. Please excuse their poor quality. Added a rough base for pop GUIs (for book-reading and the like. A draedons logbook exists that uses this) Adjusted Snake eyes to use a little less dust. Note: This is NOT ready to be merged into master yet. A lot of placeholders are used.
112 lines
5.8 KiB
C#
112 lines
5.8 KiB
C#
using CalamityMod.TileEntities;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ModLoader;
|
|
using Terraria.ObjectData;
|
|
|
|
namespace CalamityMod.Tiles
|
|
{
|
|
public class DreadonFactoryFieldGenerator : ModTile
|
|
{
|
|
public override void SetDefaults()
|
|
{
|
|
Main.tileLighted[Type] = true;
|
|
Main.tileFrameImportant[Type] = true;
|
|
Main.tileNoAttach[Type] = true;
|
|
Main.tileLavaDeath[Type] = false;
|
|
Main.tileWaterDeath[Type] = false;
|
|
TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1);
|
|
TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance<TEDraedonFieldGenerator>().Hook_AfterPlacement, -1, 0, true);
|
|
TileObjectData.addTile(Type);
|
|
ModTranslation name = CreateMapEntryName();
|
|
name.SetDefault("Field Generator");
|
|
AddMapEntry(new Color(53, 49, 52), name);
|
|
}
|
|
public TEDraedonFieldGenerator RetrieveTileEntity(int i, int j)
|
|
{
|
|
int determinedID = ModContent.GetInstance<TEDraedonFieldGenerator>().Find(i, j);
|
|
if (determinedID == -1 || !(TileEntity.ByID[determinedID] is TEDraedonFieldGenerator))
|
|
{
|
|
ModTileEntity modTileEntity = ModTileEntity.ConstructFromType(ModContent.GetInstance<TEDraedonFieldGenerator>().type);
|
|
modTileEntity.Position = new Point16(i, j);
|
|
modTileEntity.ID = TileEntity.AssignNewID();
|
|
modTileEntity.type = ModContent.GetInstance<TEDraedonFieldGenerator>().type;
|
|
TileEntity.ByID[modTileEntity.ID] = modTileEntity;
|
|
TileEntity.ByPosition[modTileEntity.Position] = modTileEntity;
|
|
determinedID = modTileEntity.ID;
|
|
}
|
|
return (TEDraedonFieldGenerator)TileEntity.ByID[determinedID];
|
|
}
|
|
public override bool CreateDust(int i, int j, ref int type)
|
|
{
|
|
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 226);
|
|
return false;
|
|
}
|
|
public override void NumDust(int i, int j, bool fail, ref int num)
|
|
{
|
|
num = fail ? 1 : 3;
|
|
}
|
|
public override void PostDraw(int i, int j, SpriteBatch spriteBatch)
|
|
{
|
|
TEDraedonFieldGenerator charger = RetrieveTileEntity(i, j);
|
|
Color drawColor = Color.Lerp(new Color(73, 68, 72), Color.Cyan, Utils.InverseLerp(0f, TEDraedonFieldGenerator.ActiveTimerMax, charger.ActiveTimer, true));
|
|
|
|
int xPos = Main.tile[i, j].frameX;
|
|
int yPos = Main.tile[i, j].frameY;
|
|
Texture2D glowmask = ModContent.GetTexture("CalamityMod/Tiles/DreadonFactoryFieldGeneratorGlow");
|
|
Vector2 screenOffset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
|
|
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + screenOffset;
|
|
Tile trackTile = Main.tile[i, j];
|
|
if (!trackTile.halfBrick() && trackTile.slope() == 0)
|
|
{
|
|
Main.spriteBatch.Draw(glowmask, drawOffset, new Rectangle?(new Rectangle(xPos, yPos, 18, 18)), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
|
|
}
|
|
else if (trackTile.halfBrick())
|
|
{
|
|
Main.spriteBatch.Draw(glowmask, drawOffset + new Vector2(0f, 8f), new Rectangle?(new Rectangle(xPos, yPos, 18, 8)), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
|
|
}
|
|
|
|
Vector2 positionWorldCoords = new Vector2(i, j) * 16f;
|
|
Player player = Main.player[Player.FindClosest(positionWorldCoords, 1, 1)];
|
|
if (player.Distance(positionWorldCoords) < 2400f)
|
|
{
|
|
Texture2D laserTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/RedLightningTexture");
|
|
Vector2[] pointsToDraw = new Vector2[65];
|
|
for (int k = 0; k < pointsToDraw.Length; k++)
|
|
{
|
|
float angle = k / (float)pointsToDraw.Length * MathHelper.TwoPi;
|
|
pointsToDraw[k] = angle.ToRotationVector2() * 1000f;
|
|
pointsToDraw[k] += drawOffset;
|
|
pointsToDraw[k] += Main.rand.NextVector2Circular(1f, 1f);
|
|
|
|
angle = (k + 1) % pointsToDraw.Length / (float)pointsToDraw.Length * MathHelper.TwoPi;
|
|
pointsToDraw[(k + 1) % pointsToDraw.Length] = angle.ToRotationVector2() * 1000f;
|
|
pointsToDraw[(k + 1) % pointsToDraw.Length] += drawOffset;
|
|
pointsToDraw[(k + 1) % pointsToDraw.Length] += Main.rand.NextVector2Circular(1f, 1f);
|
|
|
|
if (trackTile.halfBrick())
|
|
pointsToDraw[k] += Vector2.UnitY * 8f;
|
|
if (trackTile.halfBrick())
|
|
pointsToDraw[(k + 1) % pointsToDraw.Length] += Vector2.UnitY * 8f;
|
|
|
|
DelegateMethods.c_1 = Color.Cyan;
|
|
DelegateMethods.f_1 = 1f;
|
|
Utils.DrawLaser(spriteBatch, laserTexture, pointsToDraw[k], pointsToDraw[(k + 1) % pointsToDraw.Length], new Vector2(0.3f), new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw));
|
|
|
|
DelegateMethods.c_1 = Color.White * 0.7f;
|
|
DelegateMethods.f_1 = 0.7f;
|
|
Utils.DrawLaser(spriteBatch, laserTexture, pointsToDraw[k], pointsToDraw[(k + 1) % pointsToDraw.Length], new Vector2(0.6f), new Utils.LaserLineFraming(DelegateMethods.LightningLaserDraw));
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
|
|
{
|
|
TEDraedonFieldGenerator generator = RetrieveTileEntity(i, j);
|
|
generator.Kill(i, j);
|
|
}
|
|
}
|
|
}
|