public static void InitializePKE() { PKEMeter.Logic.PKEGaugesGetter gauge = PKEMeter.PKEMeterAPI.GetGauge(); Point?lastNearestShardTile = null; float lastGaugedManaShardPercent = 0f; int gaugeTimer = 0; PKEMeter.PKEMeterAPI.SetGauge((plr, pos) => { var config = FMCConfig.Instance; float detectChancePerTick = config.Get <float>(nameof(config.PKEDetectChancePerTick)); PKEMeter.Logic.PKEGaugeValues existingGauge = gauge?.Invoke(plr, pos) ?? new PKEMeter.Logic.PKEGaugeValues(0f, 0f, 0f, 0f); if (gaugeTimer-- <= 0) { gaugeTimer = 15; lastGaugedManaShardPercent = FMCMod.GaugeNearbyManaShards(pos, out lastNearestShardTile); } float illumAmt = 0; if (lastNearestShardTile.HasValue) { ManaCrystalShardTile.GetIlluminationAt( lastNearestShardTile.Value.X, lastNearestShardTile.Value.Y, out illumAmt ); } if (illumAmt > 0f) { existingGauge.BluePercent = lastGaugedManaShardPercent; existingGauge.BluePercent += (1f - lastGaugedManaShardPercent) * Math.Min(illumAmt, 1f); } else { if (detectChancePerTick > Main.rand.NextFloat()) { existingGauge.BluePercent = FMCMod.ApplyInterferenceToManaShardGauge(lastGaugedManaShardPercent); } } return(existingGauge); }); PKEMeter.PKEMeterAPI.SetMeterText("FindableManaCrystals", (plr, pos, gauges) => { Color color = new Color(32, 64, 255); color = color * (0.5f + (Main.rand.NextFloat() * 0.5f)); return(new PKEMeter.Logic.PKETextMessage( message: "CLASS II ETHEREAL GEOFORM", color: color, priority: lastGaugedManaShardPercent * 0.99999f )); }); PKEMeter.PKEMeterAPI.SetPKEBlueTooltip(() => "GEOFORM"); }
//////////////// public override void Load() { FMCMod.Instance = this; FMCWorld.InitializeSingleton(); FMCProjectile.InitializeSingleton(); }
//////////////// public override void PostSetupContent() { /*CustomHotkeys.BindActionToKey1( "Illuminate", () => { * var manaTileSingleton = ModContent.GetInstance<ManaCrystalShardTile>(); * foreach( (int tileX, IDictionary<int, float> tileYs) in manaTileSingleton.IlluminatedCrystals.ToArray() ) { * foreach( (int tileY, float illum) in tileYs.ToArray() ) { * manaTileSingleton.IlluminatedCrystals[tileX][tileY] = 1f; * } * } * Main.NewText("Lit!"); * } );*/ if (ModLoader.GetMod("PKEMeter") != null) { FMCMod.InitializePKE(); } }
public override void Unload() { FMCMod.Instance = null; }