示例#1
0
        public override void RandomUpdate(int i, int j)
        {
            if (!Main.hardMode)
            {
                return;
            }
            WeightedRandom <(int, int)> rand = new WeightedRandom <(int, int)>();
            Tile current;

            for (int y = -3; y < 4; y++)
            {
                for (int x = -3; x < 4; x++)
                {
                    current = Main.tile[i + x, j + y];
                    if (OriginWorld.ConvertTileWeak(ref current.type, OriginWorld.evil_riven, false))
                    {
                        if (Main.tile[i + x, j + y - 1].type != TileID.Sunflower)
                        {
                            rand.Add((i + x, j + y));
                        }
                    }
                }
            }
            if (rand.elements.Count > 0)
            {
                (int x, int y)pos = rand.Get();
                OriginWorld.ConvertTileWeak(ref Main.tile[pos.x, pos.y].type, OriginWorld.evil_riven);
                WorldGen.SquareTileFrame(pos.x, pos.y);
                NetMessage.SendTileSquare(-1, pos.x, pos.y, 1);
            }
        }
示例#2
0
        public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
        {
            fail   = true;
            noItem = true;
            OriginWorld originWorld = ModContent.GetInstance <OriginWorld>();

            if (!(originWorld is null))
            {
                if (originWorld.defiledAltResurgenceTiles is null)
                {
                    originWorld.defiledAltResurgenceTiles = new List <(int, int, ushort)> {
                    }
                }
                ;
                originWorld.defiledAltResurgenceTiles.Add((i, j, Type));
            }
            bool half  = Main.tile[i, j].halfBrick();
            byte slope = Main.tile[i, j].slope();

            Main.tile[i, j].ResetToType(TileID.Dirt);
            WorldGen.SquareTileFrame(i, j);
            Main.tile[i, j].halfBrick(half);
            Main.tile[i, j].slope(slope);
            NetMessage.SendTileSquare(-1, i, j, 1);
        }
示例#3
0
        public override void Unload()
        {
            ExplosiveProjectiles = null;
            ExplosiveItems       = null;
            ExplosiveAmmo        = null;
            ExplosiveBaseDamage  = null;
            ExplosiveModOnHit    = null;
            VanillaElements      = null;
            celestineBoosters    = null;
            perlinFade0          = null;
            blackHoleShade       = null;
            solventShader        = null;
            rasterizeShader      = null;
            cellNoiseTexture     = null;
            OriginExtensions.drawPlayerItemPos = null;
            Tolruk.glowmasks     = null;
            HelmetGlowMasks      = null;
            BreastplateGlowMasks = null;
            LeggingGlowMasks     = null;
            instance             = null;
            Tiles.Defiled.Defiled_Tree.Unload();
            OriginExtensions.unInitExt();
            OriginTile.IDs = null;
            OriginWorld worldInstance = ModContent.GetInstance <OriginWorld>();

            if (!(worldInstance is null))
            {
                worldInstance.defiledResurgenceTiles    = null;
                worldInstance.defiledAltResurgenceTiles = null;
            }
            Bomboomstick.Unload();
            eyndumCoreUI        = null;
            eyndumCoreUITexture = null;
            eyndumCoreTexture   = null;
        }
示例#4
0
 private void WorldGen_CountTiles(On.Terraria.WorldGen.orig_CountTiles orig, int X)
 {
     if (X == 0)
     {
         OriginWorld.UpdateTotalEvilTiles();
     }
     orig(X);
 }
示例#5
0
 public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
 {
     if (Main.tile[i, j].active())
     {
         int adj = OriginWorld.GetAdjTileCount(i, j);
         if (adj < 4)
         {
             //Main.tile[i, j].active(false);
             GetInstance <OriginWorld>().QueueKillTile(i, j);
         }
         else if (adj > 7)
         {
             Main.tile[i, j].ResetToType((ushort)TileType <Riven_Flesh>());
         }
     }
     return(base.TileFrame(i, j, ref resetFrame, ref noBreak));
 }
示例#6
0
        public override void RandomUpdate(int i, int j)
        {
            int retryCount = 0;

retry:
            if (retryCount++ > 100)
            {
                return;
            }
            switch (WorldGen.genRand.Next(Main.hardMode?3:2))
            {
            case 0:
                WeightedRandom <(int, int)> rand = new WeightedRandom <(int, int)>();
                Tile current;
                for (int y = -1; y < 2 && (j + y) < Main.worldSurface; y++)
                {
                    for (int x = -1; x < 2; x++)
                    {
                        current = Main.tile[i + x, j + y];
                        if (current.type == TileID.Grass)
                        {
                            if (Main.tile[i + x, j + y - 1].type != TileID.Sunflower)
                            {
                                rand.Add((i + x, j + y));
                            }
                        }
                        else if (current.type == TileID.Dirt)
                        {
                            if (!(Main.tile[i + x - 1, j + y].active() && Main.tile[i + x + 1, j + y].active() && Main.tile[i + x, j + y - 1].active() && Main.tile[i + x, j + y + 1].active()))
                            {
                                rand.Add((i + x, j + y));
                            }
                        }
                    }
                }
                if (rand.elements.Count > 0)
                {
                    (int x, int y)pos = rand.Get();
                    OriginWorld.ConvertTileWeak(ref Main.tile[pos.x, pos.y].type, OriginWorld.evil_wastelands);
                    OriginWorld.ConvertWall(ref Main.tile[pos.x, pos.y].wall, OriginWorld.evil_wastelands);
                    WorldGen.SquareTileFrame(pos.x, pos.y);
                    NetMessage.SendTileSquare(-1, pos.x, pos.y, 1);
                }
                else
                {
                    goto retry;
                }
                break;

            case 1:
                if (!Main.tile[i, j - 1].active() && !(Main.tile[i, j].slope() != 0 || Main.tile[i, j].halfBrick()))
                {
                    Main.tile[i, j - 1].ResetToType((ushort)ModContent.TileType <Defiled_Foliage>());
                }
                else
                {
                    goto retry;
                }
                break;

            case 2:
                base.RandomUpdate(i, j);
                break;
            }
        }
示例#7
0
        public override void Load()
        {
            ExplosiveBaseDamage = new Dictionary <int, int>();
            //Explosive item types
            NonFishItem.ResizeItemArrays += () => {
                ExplosiveItems = ItemID.Sets.ItemsThatCountAsBombsForDemolitionistToSpawn.ToArray();
                ExplosiveItems[ItemID.BouncyBomb]       = true;
                ExplosiveItems[ItemID.HellfireArrow]    = true;
                ExplosiveItems[ItemID.BombFish]         = true;
                ExplosiveItems[ItemID.PartyGirlGrenade] = true;
                ExplosiveItems[ItemID.Beenade]          = true;
                ExplosiveItems[ItemID.MolotovCocktail]  = true;
            };
            //Explosive projectile & ammo types
            NonFishItem.ResizeOtherArrays += () => {
                ExplosiveProjectiles = new bool[ProjectileID.Sets.CanDistortWater.Length];
                ExplosiveProjectiles[ProjectileID.Grenade]          = true;
                ExplosiveProjectiles[ProjectileID.StickyGrenade]    = true;
                ExplosiveProjectiles[ProjectileID.BouncyGrenade]    = true;
                ExplosiveProjectiles[ProjectileID.Bomb]             = true;
                ExplosiveProjectiles[ProjectileID.StickyBomb]       = true;
                ExplosiveProjectiles[ProjectileID.BouncyBomb]       = true;
                ExplosiveProjectiles[ProjectileID.Dynamite]         = true;
                ExplosiveProjectiles[ProjectileID.StickyDynamite]   = true;
                ExplosiveProjectiles[ProjectileID.BouncyDynamite]   = true;
                ExplosiveProjectiles[ProjectileID.HellfireArrow]    = true;
                ExplosiveProjectiles[ProjectileID.BombFish]         = true;
                ExplosiveProjectiles[ProjectileID.PartyGirlGrenade] = true;
                ExplosiveProjectiles[ProjectileID.Beenade]          = true;
                ExplosiveProjectiles[ProjectileID.MolotovCocktail]  = true;
                ExplosiveProjectiles[ProjectileID.RocketI]          = true;
                ExplosiveProjectiles[ProjectileID.RocketII]         = true;
                ExplosiveProjectiles[ProjectileID.RocketIII]        = true;
                ExplosiveProjectiles[ProjectileID.RocketIV]         = true;
                ExplosiveProjectiles[ProjectileID.GrenadeI]         = true;
                ExplosiveProjectiles[ProjectileID.GrenadeII]        = true;
                ExplosiveProjectiles[ProjectileID.GrenadeIII]       = true;
                ExplosiveProjectiles[ProjectileID.GrenadeIV]        = true;
                ExplosiveProjectiles[ProjectileID.ProximityMineI]   = true;
                ExplosiveProjectiles[ProjectileID.ProximityMineII]  = true;
                ExplosiveProjectiles[ProjectileID.ProximityMineIII] = true;
                ExplosiveProjectiles[ProjectileID.ProximityMineIV]  = true;

                ExplosiveModOnHit = new bool[ProjectileID.Sets.CanDistortWater.Length];
                ExplosiveModOnHit[ProjectileID.Bomb]           = true;
                ExplosiveModOnHit[ProjectileID.StickyBomb]     = true;
                ExplosiveModOnHit[ProjectileID.BouncyBomb]     = true;
                ExplosiveModOnHit[ProjectileID.BombFish]       = true;
                ExplosiveModOnHit[ProjectileID.Dynamite]       = true;
                ExplosiveModOnHit[ProjectileID.StickyDynamite] = true;
                ExplosiveModOnHit[ProjectileID.BouncyDynamite] = true;

                ExplosiveAmmo = ExplosiveItems.ToArray();
                ExplosiveAmmo[AmmoID.Rocket]      = true;
                ExplosiveAmmo[AmmoID.StyngerBolt] = true;
            };
            #region vanilla weapon elements
            VanillaElements = ItemID.Sets.Factory.CreateUshortSet(0,
                                                                  #region fire
                                                                  (ushort)ItemID.FlamingArrow, Elements.Fire,
                                                                  (ushort)ItemID.FlareGun, Elements.Fire,
                                                                  (ushort)ItemID.WandofSparking, Elements.Fire,
                                                                  (ushort)ItemID.FieryGreatsword, Elements.Fire,
                                                                  (ushort)ItemID.MoltenPickaxe, Elements.Fire,
                                                                  (ushort)ItemID.MoltenHamaxe, Elements.Fire,
                                                                  (ushort)ItemID.ImpStaff, Elements.Fire,
                                                                  (ushort)ItemID.FlowerofFire, Elements.Fire,
                                                                  (ushort)ItemID.Flamelash, Elements.Fire,
                                                                  (ushort)ItemID.Sunfury, Elements.Fire,
                                                                  (ushort)ItemID.Flamethrower, Elements.Fire,
                                                                  (ushort)ItemID.EldMelter, Elements.Fire,
                                                                  (ushort)ItemID.InfernoFork, Elements.Fire,
                                                                  (ushort)ItemID.Cascade, Elements.Fire,
                                                                  (ushort)ItemID.HelFire, Elements.Fire,
                                                                  (ushort)ItemID.HellwingBow, Elements.Fire,
                                                                  (ushort)ItemID.PhoenixBlaster, Elements.Fire,
                                                                  (ushort)ItemID.MoltenFury, Elements.Fire,
                                                                  (ushort)ItemID.DD2FlameburstTowerT1Popper, Elements.Fire,
                                                                  (ushort)ItemID.DD2FlameburstTowerT2Popper, Elements.Fire,
                                                                  (ushort)ItemID.DD2FlameburstTowerT3Popper, Elements.Fire,
                                                                  (ushort)ItemID.DD2PhoenixBow, Elements.Fire,
                                                                  (ushort)ItemID.FrostburnArrow, Elements.Fire | Elements.Ice,
                                                                  (ushort)ItemID.FlowerofFrost, Elements.Fire | Elements.Ice,
                                                                  (ushort)ItemID.Amarok, Elements.Fire | Elements.Ice,
                                                                  (ushort)ItemID.CursedArrow, Elements.Fire | Elements.Acid,
                                                                  (ushort)ItemID.CursedBullet, Elements.Fire | Elements.Acid,
                                                                  (ushort)ItemID.CursedFlames, Elements.Fire | Elements.Acid,
                                                                  (ushort)ItemID.CursedDart, Elements.Fire | Elements.Acid,
                                                                  (ushort)ItemID.ClingerStaff, Elements.Fire | Elements.Acid,
                                                                  (ushort)ItemID.ShadowFlameBow, Elements.Fire,
                                                                  (ushort)ItemID.ShadowFlameHexDoll, Elements.Fire,
                                                                  (ushort)ItemID.ShadowFlameKnife, Elements.Fire,
                                                                  (ushort)ItemID.SolarFlareAxe, Elements.Fire,
                                                                  (ushort)ItemID.SolarFlareChainsaw, Elements.Fire,
                                                                  (ushort)ItemID.SolarFlareDrill, Elements.Fire,
                                                                  (ushort)ItemID.SolarFlareHammer, Elements.Fire,
                                                                  (ushort)ItemID.SolarFlarePickaxe, Elements.Fire,
                                                                  (ushort)ItemID.DayBreak, Elements.Fire,
                                                                  (ushort)ItemID.SolarEruption, Elements.Fire,
                                                                  #endregion fire
                                                                  #region ice
                                                                  (ushort)ItemID.IceBlade, Elements.Ice,
                                                                  (ushort)ItemID.IceBoomerang, Elements.Ice,
                                                                  (ushort)ItemID.IceRod, Elements.Ice,
                                                                  (ushort)ItemID.IceBow, Elements.Ice,
                                                                  (ushort)ItemID.IceSickle, Elements.Ice,
                                                                  (ushort)ItemID.FrostDaggerfish, Elements.Ice,
                                                                  (ushort)ItemID.FrostStaff, Elements.Ice,
                                                                  (ushort)ItemID.Frostbrand, Elements.Ice,
                                                                  (ushort)ItemID.StaffoftheFrostHydra, Elements.Ice,
                                                                  (ushort)ItemID.NorthPole, Elements.Ice,
                                                                  (ushort)ItemID.BlizzardStaff, Elements.Ice,
                                                                  (ushort)ItemID.SnowballCannon, Elements.Ice,
                                                                  (ushort)ItemID.SnowmanCannon, Elements.Ice,
                                                                  #endregion ice
                                                                  #region earth
                                                                  (ushort)ItemID.CrystalBullet, Elements.Earth,
                                                                  (ushort)ItemID.CrystalDart, Elements.Earth,
                                                                  (ushort)ItemID.CrystalSerpent, Elements.Earth,
                                                                  (ushort)ItemID.CrystalStorm, Elements.Earth,
                                                                  (ushort)ItemID.CrystalVileShard, Elements.Earth,
                                                                  (ushort)ItemID.MeteorStaff, Elements.Earth,
                                                                  (ushort)ItemID.Seedler, Elements.Earth,
                                                                  (ushort)ItemID.MushroomSpear, Elements.Earth,
                                                                  (ushort)ItemID.Hammush, Elements.Earth,
                                                                  (ushort)ItemID.StaffofEarth, Elements.Earth,
                                                                  (ushort)ItemID.BladeofGrass, Elements.Earth,
                                                                  (ushort)ItemID.ThornChakram, Elements.Earth,
                                                                  (ushort)ItemID.PoisonStaff, Elements.Earth,
                                                                  (ushort)ItemID.Toxikarp, Elements.Earth,
                                                                  (ushort)ItemID.VenomArrow, Elements.Earth,
                                                                  (ushort)ItemID.VenomBullet, Elements.Earth,
                                                                  (ushort)ItemID.VenomStaff, Elements.Earth,
                                                                  (ushort)ItemID.SpiderStaff, Elements.Earth,
                                                                  (ushort)ItemID.QueenSpiderStaff, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteArrow, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteBullet, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteChainsaw, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteClaymore, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteDrill, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteGreataxe, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteJackhammer, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophytePartisan, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophytePickaxe, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteSaber, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteShotbow, Elements.Earth,
                                                                  (ushort)ItemID.ChlorophyteWarhammer, Elements.Earth);
            #endregion earth
            #endregion vanilla weapon elements
            HelmetGlowMasks      = new Dictionary <int, Texture2D> {
            };
            BreastplateGlowMasks = new Dictionary <int, Texture2D> {
            };
            LeggingGlowMasks     = new Dictionary <int, Texture2D> {
            };
            if (!Main.dedServ)
            {
                OriginExtensions.drawPlayerItemPos = (Func <float, int, Vector2>) typeof(Main).GetMethod("DrawPlayerItemPos", BindingFlags.NonPublic | BindingFlags.Instance).CreateDelegate(typeof(Func <float, int, Vector2>), Main.instance);
                perlinFade0 = new MiscShaderData(new Ref <Effect>(GetEffect("Effects/PerlinFade")), "RedFade");
                //perlinFade0.UseImage("Images/Misc/Perlin");
                perlinFade0.Shader.Parameters["uThreshold0"].SetValue(0.6f);
                perlinFade0.Shader.Parameters["uThreshold1"].SetValue(0.6f);
                blackHoleShade = new MiscShaderData(new Ref <Effect>(GetEffect("Effects/BlackHole")), "BlackHole");

                Filters.Scene["Origins:ZoneDusk"]    = new Filter(new ScreenShaderData(new Ref <Effect>(GetEffect("Effects/BiomeShade")), "VoidShade"), EffectPriority.High);
                Filters.Scene["Origins:ZoneDefiled"] = new Filter(new ScreenShaderData(new Ref <Effect>(GetEffect("Effects/BiomeShade")), "DefiledShade"), EffectPriority.High);
                Filters.Scene["Origins:ZoneRiven"]   = new Filter(new ScreenShaderData(new Ref <Effect>(GetEffect("Effects/BiomeShade")), "RivenShade"), EffectPriority.High);

                solventShader = new MiscShaderData(new Ref <Effect>(GetEffect("Effects/Solvent")), "Dissolve");
                GameShaders.Misc["Origins:Solvent"] = solventShader;
                cellNoiseTexture = GetTexture("Textures/Cell_Noise_Pixel");

                rasterizeShader = new MiscShaderData(new Ref <Effect>(GetEffect("Effects/Rasterize")), "Rasterize");
                GameShaders.Misc["Origins:Rasterize"] = rasterizeShader;
                //Filters.Scene["Origins:ZoneDusk"].GetShader().UseOpacity(0.35f);
                //Ref<Effect> screenRef = new Ref<Effect>(GetEffect("Effects/ScreenDistort")); // The path to the compiled shader file.
                //Filters.Scene["BlackHole"] = new Filter(new ScreenShaderData(screenRef, "BlackHole"), EffectPriority.VeryHigh);
                //Filters.Scene["BlackHole"].Load();
                eyndumCoreUI        = new UserInterface();
                eyndumCoreUITexture = GetTexture("UI/CoreSlot");
                eyndumCoreTexture   = GetTexture("Items/Armor/Eyndum/Eyndum_Breastplate_Body_Core");
            }
            Sounds.Krunch       = AddSound("Sounds/Custom/BurstCannon", SoundType.Item);
            Sounds.HeavyCannon  = AddSound("Sounds/Custom/HeavyCannon", SoundType.Item);
            Sounds.EnergyRipple = AddSound("Sounds/Custom/EnergyRipple", SoundType.Item);
            //OriginExtensions.initClone();
            Music.Dusk                       = MusicID.Eerie;
            Music.Defiled                    = MusicID.Corruption;
            Music.UndergroundDefiled         = MusicID.UndergroundCorruption;
            On.Terraria.NPC.UpdateCollision += (orig, self) => {
                int realID = self.type;
                if (self.modNPC is ISandsharkNPC shark)
                {
                    self.type = NPCID.SandShark;
                    try {
                        shark.PreUpdateCollision();
                        orig(self);
                    } finally {
                        shark.PostUpdateCollision();
                    }
                    self.type = realID;
                    return;
                }
                ITileCollideNPC tcnpc = self.modNPC as ITileCollideNPC;
                self.type = tcnpc?.CollisionType ?? realID;
                orig(self);
                self.type = realID;
            };
            On.Terraria.NPC.GetMeleeCollisionData += NPC_GetMeleeCollisionData;
            On.Terraria.WorldGen.GERunner         += OriginWorld.GERunnerHook;
            On.Terraria.WorldGen.Convert          += OriginWorld.ConvertHook;
            On.Terraria.Item.NewItem_int_int_int_int_int_int_bool_int_bool_bool += OriginGlobalItem.NewItemHook;
            Mod blockSwap = ModLoader.GetMod("BlockSwap");
            if (!(blockSwap is null || blockSwap.Version > new Version(1, 0, 1)))
            {
                On.Terraria.TileObject.CanPlace += (On.Terraria.TileObject.orig_CanPlace orig, int x, int y, int type, int style, int dir, out TileObject objectData, bool onlyCheck, bool checkStay) => {
                    if (type == 20)
                    {
                        Tile soil = Main.tile[x, y + 1];
                        if (soil.active())
                        {
                            TileLoader.SaplingGrowthType(soil.type, ref type, ref style);
                        }
                    }
                    return(orig(x, y, type, style, dir, out objectData, onlyCheck, checkStay));
                }
            }
            ;
            Tiles.Defiled.Defiled_Tree.Load();
            OriginWorld worldInstance = ModContent.GetInstance <OriginWorld>();
            if (!(worldInstance is null))
            {
                worldInstance.defiledResurgenceTiles    = new List <(int, int)> {
                };
                worldInstance.defiledAltResurgenceTiles = new List <(int, int, ushort)> {
                };
            }
            //IL.Terraria.WorldGen.GERunner+=OriginWorld.GERunnerHook;
            On.Terraria.Main.DrawInterface_Resources_Breath += FixedDrawBreath;
            On.Terraria.WorldGen.CountTiles           += WorldGen_CountTiles;
            On.Terraria.WorldGen.AddUpAlignmentCounts += WorldGen_AddUpAlignmentCounts;
            Terraria.IO.WorldFile.OnWorldLoad         += () => {
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    for (int i = 0; i < Main.maxTilesX; i++)
                    {
                        WorldGen.CountTiles(i);
                    }
                }
            };
            On.Terraria.Lang.GetDryadWorldStatusDialog += Lang_GetDryadWorldStatusDialog;
            HookEndpointManager.Add(typeof(TileLoader).GetMethod("MineDamage", BindingFlags.Public | BindingFlags.Static), (hook_MinePower)MineDamage);
            On.Terraria.Main.DrawPlayer_DrawAllLayers += Main_DrawPlayer_DrawAllLayers;
        }