예제 #1
0
        ////////////////

        public override void MidUpdateDustTime()
        {
            if (this.IsSoulBarriersLoaded)
            {
                CursedBramblesMod.UpdateBarrierCollisionsIf_SoulBarriers_WeakRef();
            }
        }
        private static void UpdatePlayerBarrierCollisionsIf_SoulBarriers_WeakRef(Player plr, float barrierDmg)
        {
            SoulBarriers.Barriers.BarrierTypes.Barrier barrier = SoulBarriers.SoulBarriersAPI.GetPlayerBarrier(plr);
            if (barrier == null || !barrier.IsActive)
            {
                return;
            }

            int brambleType         = ModContent.TileType <CursedBrambleTile>();
            ISet <(int, int)> tiles = SoulBarriers.SoulBarriersAPI.GetTilesUponBarrier(barrier, 8f);

            foreach ((int x, int y) in tiles)
            {
//Dust.QuickDust( new Point(x, y), Color.Red );
                Tile tile = Main.tile[x, y];
                if (tile?.active() != true || tile.type != brambleType)
                {
                    continue;
                }

                if (!CursedBramblesMod.ApplyBarrierCollision_SoulBarriers_WeakRef(barrier, x, y, barrierDmg))
                {
                    break;
                }
            }
        }
        ////////////////

        public override void MidUpdateTimeWorld()           // <- use instead of ModWorld.PreUpdate
        {
            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                CursedBramblesMod.UpdateBrambleErode();
            }
        }
        private static void UpdateBarrierCollisionsIf_SoulBarriers_WeakRef()
        {
            var   config     = CursedBramblesConfig.Instance;
            float barrierDmg = config.Get <float>(nameof(config.DamageToPBGBarriers));

            if (barrierDmg == 0f)
            {
                return;
            }

            if (Main.netMode == NetmodeID.MultiplayerClient)                // Let the server handle other players
            {
                CursedBramblesMod.UpdatePlayerBarrierCollisionsIf_SoulBarriers_WeakRef(Main.LocalPlayer, barrierDmg);
            }
            else
            {
                int maxPlr = Main.player.Length;
                for (int i = 0; i < maxPlr; i++)
                {
                    Player plr = Main.player[i];
                    if (plr?.active == true)
                    {
                        CursedBramblesMod.UpdatePlayerBarrierCollisionsIf_SoulBarriers_WeakRef(plr, barrierDmg);
                    }
                }
            }
        }