The Monument
Uses placeholder sprites
This commit is contained in:
1 parent
f1e2042162
commit
aa6a8a7956
5 files changed
+131
-2
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.Tiles.Furniture;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Items.Placeables.Furniture
|
||||
{
|
||||
public class TheMonument : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Placeables";
|
||||
public override string Texture => "Terraria/Images/Item_1177"; //Placeholder
|
||||
|
||||
public const float MonumentTaxIncrease = 0.25f;
|
||||
public const float MonumentHappinessReduction = 0.2f;
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.DefaultToPlaceableTile(ModContent.TileType<TheMonumentTile>());
|
||||
Item.rare = ItemRarityID.Pink;
|
||||
Item.value = Item.buyPrice(gold: 5);
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
On_Player.CollectTaxes += AddMonumentTaxes;
|
||||
}
|
||||
|
||||
private static void AddMonumentTaxes(On_Player.orig_CollectTaxes orig, Player self)
|
||||
{
|
||||
orig(self);
|
||||
|
||||
foreach (NPC n in Main.ActiveNPCs)
|
||||
{
|
||||
if (!n.homeless && !NPCID.Sets.IsTownPet[n.type] && NPC.TypeToDefaultHeadIndex(n.type) > 0 && n.GetGlobalNPC<CalamityGlobalTownNPC>().AffectedByTheMonument)
|
||||
self.taxMoney += (int)(CalamityGlobalTownNPC.TotalTaxesPerNPC * MonumentTaxIncrease);
|
||||
}
|
||||
if (self.taxMoney > CalamityGlobalTownNPC.TaxesToCollectLimit)
|
||||
self.taxMoney = CalamityGlobalTownNPC.TaxesToCollectLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-2
@@ -1,4 +1,5 @@
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.Items.Placeables.Furniture;
|
||||
using CalamityMod.NPCs;
|
||||
using CalamityMod.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
@@ -67,11 +68,21 @@ namespace CalamityMod.Items.Tools
|
||||
}
|
||||
}
|
||||
|
||||
// Also contains logic for The Monument, so I can make sure these apply in the correct order
|
||||
private static void TheGiftHappiness(On_ShopHelper.orig_ProcessMood orig, ShopHelper self, Player player, NPC npc)
|
||||
{
|
||||
orig(self, player, npc);
|
||||
|
||||
bool? gift = npc.GetGlobalNPC<CalamityGlobalTownNPC>().TheGiftStatus;
|
||||
var gtnpc = npc.GetGlobalNPC<CalamityGlobalTownNPC>();
|
||||
// The Monument lowers happiness by a fixed amount. This is not applied to the Tax Collector.
|
||||
if (npc.type != NPCID.TaxCollector && gtnpc.SearchForTheMonument(npc))
|
||||
{
|
||||
self._currentPriceAdjustment += TheMonument.MonumentHappinessReduction;
|
||||
self.LimitAndRoundMultiplier(self._currentPriceAdjustment);
|
||||
}
|
||||
|
||||
// The Gift sets happiness to a fixed either extremely high or extremely low value, depending on its random state.
|
||||
bool? gift = gtnpc.TheGiftStatus;
|
||||
if (gift.HasValue)
|
||||
{
|
||||
if (gift.Value)
|
||||
|
||||
@@ -990,6 +990,15 @@ ThaumaticChair: {
|
||||
Tooltip: One of Chloe's finest creations
|
||||
}
|
||||
|
||||
TheMonument: {
|
||||
DisplayName: The Monument
|
||||
Tooltip:
|
||||
'''
|
||||
A monument celebrating the accomplishments of capitalism
|
||||
Funded by the taxes of nearby Town NPCs, though they may not be too happy about that
|
||||
'''
|
||||
}
|
||||
|
||||
ThermalTorch: {
|
||||
DisplayName: Thermal Torch
|
||||
Tooltip:
|
||||
|
||||
@@ -22,6 +22,7 @@ using CalamityMod.Items.Weapons.Rogue;
|
||||
using CalamityMod.NPCs.TownNPCs;
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
using CalamityMod.Systems.Collections;
|
||||
using CalamityMod.Tiles.Furniture;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -31,6 +32,7 @@ using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.WorldBuilding;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.NPCs
|
||||
@@ -81,6 +83,8 @@ namespace CalamityMod.NPCs
|
||||
/// </summary>
|
||||
public double TheGiftReset = -1.0;
|
||||
|
||||
public bool AffectedByTheMonument = false;
|
||||
|
||||
public override bool InstancePerEntity => true;
|
||||
|
||||
public override bool AppliesToEntity(NPC entity, bool lateInstantiation)
|
||||
@@ -96,6 +100,8 @@ namespace CalamityMod.NPCs
|
||||
myClone.shopAlertAnimTimer = shopAlertAnimTimer;
|
||||
myClone.shopAlertAnimFrame = shopAlertAnimFrame;
|
||||
myClone.TheGiftStatus = TheGiftStatus;
|
||||
myClone.TheGiftReset = TheGiftReset;
|
||||
myClone.AffectedByTheMonument = AffectedByTheMonument;
|
||||
|
||||
return myClone;
|
||||
}
|
||||
@@ -828,8 +834,40 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
}
|
||||
|
||||
// Search for The Monument, for the purposes of assigning higher taxes
|
||||
AffectedByTheMonument = false;
|
||||
SearchForTheMonument(npc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SearchForTheMonument(NPC npc)
|
||||
{
|
||||
Point tileCenter = npc.Center.ToTileCoordinates();
|
||||
Rectangle searchArea = new((int)(tileCenter.X - Main.buffScanAreaWidth / 2), (int)(tileCenter.Y - Main.buffScanAreaHeight / 2), Main.buffScanAreaWidth, Main.buffScanAreaHeight);
|
||||
searchArea = WorldUtils.ClampToWorld(searchArea);
|
||||
for (int i = searchArea.Left; i < searchArea.Right; i++)
|
||||
{
|
||||
for (int j = searchArea.Top; j < searchArea.Bottom; j++)
|
||||
{
|
||||
if (!searchArea.Contains(i, j))
|
||||
continue;
|
||||
|
||||
Tile tile = Main.tile[i, j];
|
||||
if (tile == null)
|
||||
continue;
|
||||
if (!tile.HasTile)
|
||||
continue;
|
||||
|
||||
if (tile.TileType == TileType<TheMonumentTile>())
|
||||
{
|
||||
AffectedByTheMonument = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PreDraw
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using CalamityMod.Items.Placeables.Furniture;
|
||||
using Terraria;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Enums;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ObjectData;
|
||||
|
||||
namespace CalamityMod.Tiles.Furniture
|
||||
{
|
||||
public class TheMonumentTile : ModTile
|
||||
{
|
||||
public override string Texture => "CalamityMod/Tiles/Furniture/Monoliths/BlueDistortedMonolithTile"; //Placeholder
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.tileFrameImportant[Type] = true;
|
||||
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3);
|
||||
TileObjectData.newTile.Width = 5;
|
||||
TileObjectData.newTile.Height = 5;
|
||||
TileObjectData.newTile.Origin = new Point16(2, 4);
|
||||
TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16, 16, 18 };
|
||||
TileObjectData.newTile.LavaDeath = false;
|
||||
TileObjectData.newTile.UsesCustomCanPlace = true;
|
||||
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop, 5, 0);
|
||||
|
||||
AnimationFrameHeight = TileObjectData.newTile.CoordinateFullHeight;
|
||||
TileObjectData.addTile(Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user