예제 #1
0
        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");
        }
        internal static void InitializeSingleton()
        {
            var myworld = ModContent.GetInstance <FMCWorld>();

            myworld.ManaCrystalShardPattern = new TilePattern(new TilePatternBuilder {
                HasSolidProperties = false,
                IsActuated         = false,
                IsPlatform         = false,
                HasLava            = false,
                HasWire1           = false,
                HasWire2           = false,
                HasWire3           = false,
                HasWire4           = false,
                MaximumBrightness  = 0.05f,
                CustomCheck        = (x, y) => {
                    if (Main.tile[x, y].type == ModContent.TileType <ManaCrystalShardTile>())
                    {
                        return(false);
                    }
                    return(ManaCrystalShardTile.PickFrameY(x, y) != -1);
                }
            });
        }