Пример #1
0
        public override TagCompound BuildTag()
        {
            TagList     tagSections = GenSectionsTag();
            TagList     tiles       = GenTileEntitiesTag();
            TagCompound level       = new TagCompound("Level")
            {
                tagSections,
                new TagInt("xPos", _coord.X),
                new TagInt("zPos", _coord.Z),
                new TagLong("LastUpdate", DateTime.Now.Ticks),
                new TagString("Status", _status.ToKeyString()),
                new TagIntArray("Biomes", _biomes),
                _entities.BuildTag(),
                tiles
            };

            TagCompound heightMaps = new TagCompound("Heightmaps");

            foreach (string key in _heightMaps.Keys)
            {
                heightMaps.Add(_heightMaps[key].BuildTag());
            }
            level.Add(heightMaps);

            if (_carvingMaskAir != null && _carvingMaskAir.Length > 0)
            {
                if (!level.ContainsKey("CarvingMasks"))
                {
                    level.Add(new TagCompound("CarvingMasks"));
                }
                ((TagCompound)level["CarvingMasks"]).Add("AIR", _carvingMaskAir);
            }
            if (_carvingMaskLiquid != null && _carvingMaskLiquid.Length > 0)
            {
                if (!level.ContainsKey("CarvingMasks"))
                {
                    level.Add(new TagCompound("CarvingMasks"));
                }
                ((TagCompound)level["CarvingMasks"]).Add("LIQUID", _carvingMaskLiquid);
            }

            foreach (string key in _lists.Keys)
            {
                level.Add(_lists[key]);
            }

            level.Add(_structures);

            return(new TagCompound()
            {
                new TagInt("DataVersion", _dataVersion),
                level
            });
        }
Пример #2
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("ETPLinksKeys"))
     {
         Keys = tag.GetList <Vector2>("ETPLinksKeys");
     }
     if (tag.ContainsKey("ETPLinksValues"))
     {
         Values = tag.GetList <Vector2>("ETPLinksValues");
     }
 }
Пример #3
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("Level"))
     {
         Level = tag.GetInt("Level");
     }
     if (tag.ContainsKey("Exp"))
     {
         Exp = tag.GetInt("Exp");
     }
     NextLevel();
 }
Пример #4
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("Starjinx Active?"))
     {
         StarjinxActive = tag.GetBool("Starjinx Active?");
     }
     if (tag.ContainsKey("Starjinx Defeated?"))
     {
         StarjinxDefeated = tag.GetBool("Starjinx Defeated?");
     }
     SpawnedStarjinx = false;
 }
        ////////////////

        public void Load(TagCompound tags)
        {
            if (tags.ContainsKey("uid"))
            {
                this.PrivateUID = tags.GetString("uid");
            }
            if (tags.ContainsKey("perma_buffs"))
            {
                var perma_buffs = tags.GetList <int>("perma_buffs");
                this.PermaBuffsById = new HashSet <int>(perma_buffs.ToArray());
            }

            this.HasUID = true;
        }
Пример #6
0
 public void Load(TagCompound tag)
 {
     x = (int)tag["x"];
     y = (int)tag["y"];
     if (tag.ContainsKey("npcID"))
     {
         id = (string)tag["npcID"];
     }
     else
     {
         id = (string)tag["id"];
     }
     isItem = tag.ContainsKey("isItem");
 }
Пример #7
0
        ////

        public override void Load(TagCompound tag)
        {
            if (tag.ContainsKey("anima_percent"))
            {
                this.AnimaPercent = MathHelper.Clamp(tag.GetFloat("anima_percent"), 0f, 1f);
            }

            if (tag.ContainsKey("ankh_offset_x"))
            {
                this.AnkhHUDDisplayOffset = new Vector2(
                    tag.GetInt("ankh_offset_x"),
                    tag.GetInt("ankh_offset_y")
                    );
            }
        }
Пример #8
0
        public override void Load(TagCompound tag)
        {
            if (tag != null && tag.ContainsKey("EventCooldows"))
            {
                try
                {
                    //var arr = tag.Get<Dictionary<string, int>>("EventCooldows");

                    //I know it is shit, very slow shit, but it is terraria what you want? The whole terraria code is shit so shut up
                    foreach (WorldEvent it in TwitchChat.EventsPool)
                    {
                        foreach (KeyValuePair <string, object> tg in tag)
                        {
                            if (tg.Key == $"Event.Cooldown.{it.GetType()}")
                            {
                                it.Cd = (int)tg.Value;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    mod.Logger.Error($"Exception caught in {nameof(Load)} when reading events cooldown:\n" +
                                     $"{e.Message}\n" +
                                     $"{e.StackTrace}\n");
                }
            }
        }
Пример #9
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey(nameof(CorruptionSpreadDisabled)))
     {
         CorruptionSpreadDisabled = tag.GetBool(nameof(CorruptionSpreadDisabled));                 // using nameof (c#6) can help prevent spelling errors. Be aware that it will lose data if you rename the field.
     }
 }
Пример #10
0
        ////////////////

        public override void Load(TagCompound tags)
        {
            if (tags.ContainsKey("is_init"))
            {
                this.IsInitializedwithTrain = tags.GetBool("is_init");
            }
        }
Пример #11
0
        ////////////////

        public override void Load(TagCompound tags)
        {
            this.Initialize();
            var mymod = (StaminaMod)this.mod;

            int  max = mymod.Config.InitialStamina;
            bool has = true;

            if (tags.ContainsKey("max_stamina") && tags.ContainsKey("has_stamina"))
            {
                max = tags.GetInt("max_stamina");
                has = tags.GetBool("has_stamina");
            }

            this.Logic = new StaminaLogic(max, has);
        }
Пример #12
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("NPC"))
     {
         npcType = tag.GetInt("NPC");
     }
 }
Пример #13
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("time"))
     {
         time = tag.Get <float>("time");
     }
 }
Пример #14
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("target"))
     {
         target = tag.Get <int>("target");
     }
 }
Пример #15
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("coins"))
     {
         totalCoins = tag.GetInt("coins");
     }
 }
Пример #16
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("gemType"))
     {
         gemType = tag.GetInt("gemType");
     }
 }
Пример #17
0
        public override void Load(TagCompound tag)
        {
            if (!tag.ContainsKey("EmitterMode"))
            {
                return;
            }

            try {
                this.SetDefinition(new EmitterDefinition(
                                       isGoreMode: tag.GetBool("EmitterMode"),
                                       type: tag.GetInt("EmitterType"),
                                       scale: tag.GetFloat("EmitterScale"),
                                       delay: tag.GetInt("EmitterDelay"),
                                       speedX: tag.GetFloat("EmitterSpeedX"),
                                       speedY: tag.GetFloat("EmitterSpeedY"),
                                       color: new Color(
                                           tag.GetByte("EmitterColorR"),
                                           tag.GetByte("EmitterColorG"),
                                           tag.GetByte("EmitterColorB")
                                           ),
                                       transparency: tag.GetByte("EmitterAlpha"),
                                       scatter: tag.GetFloat("EmitterScatter"),
                                       hasGravity: tag.GetBool("EmitterHasGrav"),
                                       hasLight: tag.GetBool("EmitterHasLight"),
                                       isActivated: tag.GetBool("EmitterIsActivated")
                                       ));
            } catch { }
        }
Пример #18
0
 public override void Load(TagCompound tag)
 {
     if (tag.ContainsKey("Mod"))
     {
         mod = ModLoader.GetMod(tag.GetString("Mod"));
     }
 }
Пример #19
0
        public override void Load(TagCompound tag)
        {
            if (tag.ContainsKey("count"))
            {
                IList <int> count = tag.GetList <int>("count");
                EyeCount       = count[0];
                SlimeCount     = count[1];
                EaterCount     = count[2];
                BrainCount     = count[3];
                BeeCount       = count[4];
                SkeletronCount = count[5];
                WallCount      = count[6];
                DestroyerCount = count[7];
                PrimeCount     = count[8];
                TwinsCount     = count[9];
                PlanteraCount  = count[10];
                GolemCount     = count[11];
                FishronCount   = count[12];
                CultistCount   = count[13];
                MoonlordCount  = count[14];
            }

            IList <string> downed = tag.GetList <string>("downed");

            _downedBetsy    = downed.Contains("betsy");
            _downedBoss     = downed.Contains("boss");
            MasochistMode   = downed.Contains("m*******t");
            downedFishronEX = downed.Contains("downedFishronEX");
            downedMutant    = downed.Contains("downedMutant");
            AngryMutant     = downed.Contains("AngryMutant");
            downedMM        = downed.Contains("downedMadhouse");
        }
 public override void Load(TagCompound tag)
 {
     eclipsePassed     = tag.GetBool("eclipsePassed");
     pumpkinMoonPassed = tag.GetBool("pumpkinMoonPassed");
     snowMoonPassed    = tag.GetBool("snowMoonPassed");
     downedPhantom     = tag.GetBool("downedPhantom");
     downedAbomination = tag.GetBool("downedAbomination");
     if (tag.ContainsKey("numPuriumGens"))
     {
         elementalUnleash = tag.GetBool("elementalUnleash");
         numPuriumGens    = tag.GetInt("numPuriumGens");
     }
     else
     {
         numPuriumGens    = tag.GetInt("elementalUnleash");
         elementalUnleash = numPuriumGens > 0;
     }
     downedPuritySpirit = tag.GetBool("downedPuritySpirit");
     downedChaosSpirit  = tag.GetBool("downedChaosSpirit");
     terraDeaths        = tag.GetInt("terraDeaths");
     terraCheckpoint1   = tag.GetInt("terraCheckpoint1");
     terraCheckpoint2   = tag.GetInt("terraCheckpoint2");
     terraCheckpoint3   = tag.GetInt("terraCheckpoint3");
     terraCheckpointS   = tag.GetInt("terraCheckpointS");
     downedTerraSpirit  = tag.GetBool("downedTerraSpirit");
     blushieCheckpoint  = tag.GetFloat("blushieCheckpoint");
     downedBlushie      = tag.GetBool("downedBlushie");
     FixCheckpoints();
 }
        ////////////////

        internal void Load(TagCompound tags)
        {
            var mymod    = ModHelpersMod.Instance;
            var modworld = mymod.GetModWorld <ModHelpersWorld>();

            if (tags.ContainsKey("world_mod_lock_count"))
            {
                int worldCount = tags.GetInt("world_mod_lock_count");

                for (int i = 0; i < worldCount; i++)
                {
                    string worldUid = tags.GetString("world_mod_lock_uid_" + i);
                    int    modCount = tags.GetInt("world_mod_lock_mods_" + i + "_count");

                    this.WorldModLocks[worldUid] = new HashSet <string>();

                    for (int j = 0; j < modCount; j++)
                    {
                        string modName = tags.GetString("world_mod_lock_mods_" + i + "_" + j);
//LogHelpers.Log( "Load world_mod_lock_mods_" + i + "_" + j +": "+modName );
                        this.WorldModLocks[worldUid].Add(modName);
                    }
                }
            }
        }
Пример #22
0
        public override void Load(TagCompound tag)
        {
            IList <string> downed = tag.GetList <string>("downed");

            downedBetsy          = downed.Contains("betsy");
            _downedBoss          = downed.Contains("boss");
            MasochistMode        = downed.Contains("m*******t");
            downedFishronEX      = downed.Contains("downedFishronEX");
            downedDevi           = downed.Contains("downedDevi");
            downedAbom           = downed.Contains("downedAbom");
            downedMutant         = downed.Contains("downedMutant");
            AngryMutant          = downed.Contains("AngryMutant");
            downedMM             = downed.Contains("downedMadhouse");
            firstGoblins         = downed.Contains("forceMeteor");
            NoMasoBossScaling    = downed.Contains("NoMasoBossScaling");
            ReceivedTerraStorage = downed.Contains("ReceivedTerraStorage");

            for (int i = 0; i < downedChampions.Length; i++)
            {
                downedChampions[i] = downed.Contains("downedChampion" + i.ToString());
            }

            if (tag.ContainsKey("mutantP1"))
            {
                skipMutantP1 = tag.GetAsInt("mutantP1");
            }
        }
Пример #23
0
        public override void LoadData(TagCompound tag)
        {
            if (tag.GetBool("initialized"))
            {
                level         = (ushort)tag.GetAsShort("level");
                currentXP     = (ulong)tag.GetAsLong("currentXP");
                neededXP      = CalculateNeededXP(level);
                statPoints    = (ushort)tag.GetAsShort("points");
                talents       = tag.Get <string>("talents");
                talentUnspent = (ushort)tag.GetAsShort("talentPoints");
                constitution  = (ushort)tag.GetAsShort("con");
                strength      = (ushort)tag.GetAsShort("str");
                intelligence  = (ushort)tag.GetAsShort("int");
                charisma      = (ushort)tag.GetAsShort("cha");
                dexterity     = (ushort)tag.GetAsShort("dex");
                mobility      = (ushort)tag.GetAsShort("mob");
                excavation    = (ushort)tag.GetAsShort("exc");
                animalia      = (ushort)tag.GetAsShort("ani");
                luck          = (ushort)(tag.ContainsKey("gra") ? tag.GetAsShort("gra") : tag.GetAsShort("luc"));
                mysticism     = (ushort)tag.GetAsShort("mys");

                if (currentXP > neededXP)
                {
                    LevelUp();
                }
            }
            else
            {
                initialize();
            }

            base.LoadData(tag);
        }
        public override void LoadWorldData(TagCompound tag)
        {
            IList <string> downed = tag.GetList <string>("downed");

            downedBetsy               = downed.Contains("betsy");
            ShouldBeEternityMode      = downed.Contains("shouldBeEternityMode");
            EternityMode              = downed.Contains("eternity") || downed.Contains("m*******t");
            CanPlayMaso               = downed.Contains("CanPlayMaso");
            MasochistModeReal         = downed.Contains("getReal");
            downedFishronEX           = downed.Contains("downedFishronEX");
            downedDevi                = downed.Contains("downedDevi");
            downedAbom                = downed.Contains("downedAbom");
            downedMutant              = downed.Contains("downedMutant");
            AngryMutant               = downed.Contains("AngryMutant");
            haveForcedAbomFromGoblins = downed.Contains("haveForcedAbomFromGoblins");
            ReceivedTerraStorage      = downed.Contains("ReceivedTerraStorage");
            spawnedDevi               = downed.Contains("spawnedDevi");

            for (int i = 0; i < downedBoss.Length; i++)
            {
                downedBoss[i] = downed.Contains($"downedBoss{i}") || downed.Contains($"downedChampion{i}");
            }

            if (tag.ContainsKey("mutantP1"))
            {
                skipMutantP1 = tag.GetAsInt("mutantP1");
            }
        }
Пример #25
0
        public override void Load(TagCompound tag)
        {
            var dbKey = tag.GetInt("WorldDragonBallKey");

            WorldDragonBallKey = dbKey;
            var oneStarPoint   = new Point(tag.GetInt("OneStarDragonBallX"), tag.GetInt("OneStarDragonBallY"));
            var twoStarPoint   = new Point(tag.GetInt("TwoStarDragonBallX"), tag.GetInt("TwoStarDragonBallY"));
            var threeStarPoint = new Point(tag.GetInt("ThreeStarDragonBallX"), tag.GetInt("ThreeStarDragonBallY"));
            var fourStarPoint  = new Point(tag.GetInt("FourStarDragonBallX"), tag.GetInt("FourStarDragonBallY"));
            var fiveStarPoint  = new Point(tag.GetInt("FiveStarDragonBallX"), tag.GetInt("FiveStarDragonBallY"));
            var sixStarPoint   = new Point(tag.GetInt("SixStarDragonBallX"), tag.GetInt("SixStarDragonBallY"));
            var sevenStarPoint = new Point(tag.GetInt("SevenStarDragonBallX"), tag.GetInt("SevenStarDragonBallY"));

            SetDragonBallLocation(1, oneStarPoint, false);
            SetDragonBallLocation(2, twoStarPoint, false);
            SetDragonBallLocation(3, threeStarPoint, false);
            SetDragonBallLocation(4, fourStarPoint, false);
            SetDragonBallLocation(5, fiveStarPoint, false);
            SetDragonBallLocation(6, sixStarPoint, false);
            SetDragonBallLocation(7, sevenStarPoint, false);
            KiBeacons = tag.ContainsKey("KiBeacons") ? (List <Vector2>)tag.GetList <Vector2>("KiBeacons") : new List <Vector2>();

            // cleanup ki beacon list, not sure why this is necessary.
            CleanupKiBeaconList();

            base.Load(tag);
        }
Пример #26
0
        public override void Load(TagCompound tag)
        {
            try
            {
                Tier = (DuctTier)tag.GetInt("Tier");
                switch (Tier)
                {
                case DuctTier.Basic:
                    Speed = 20;
                    break;

                case DuctTier.Advanced:
                    Speed = 12;
                    break;

                case DuctTier.Elite:
                    Speed = 5;
                    break;
                }

                if (tag.ContainsKey("Module"))
                {
                    TagCompound module = tag.GetCompound("Module");
                    Module        = (BaseModule)Activator.CreateInstance(Type.GetType(module.GetString("Type")));
                    Module.Parent = this;
                    Module.Load(module.GetCompound("Data"));
                }
            }
            catch
            {
            }
        }
Пример #27
0
        ////////////////

        public override void Load(TagCompound tags)
        {
            if (tags.ContainsKey("world_id"))
            {
                this._ID = tags.GetString("world_id");
            }
        }
Пример #28
0
 public void LoadFrom(TagCompound tags)
 {
     if (tags.ContainsKey("tile_data"))
     {
         this.DowsedTiles = JsonConfig <IDictionary <int, DowsedTiles> > .Deserialize(tags.GetString("tile_data"));
     }
 }
Пример #29
0
        public override void Load(TagCompound tag)
        {
            if (tag.ContainsKey("count"))
            {
                IList <int> count = tag.GetList <int>("count");
                EyeCount       = count[0];
                SlimeCount     = count[1];
                EaterCount     = count[2];
                BrainCount     = count[3];
                BeeCount       = count[4];
                SkeletronCount = count[5];
                WallCount      = count[6];
                DestroyerCount = count[7];
                PrimeCount     = count[8];
                TwinsCount     = count[9];
                PlanteraCount  = count[10];
                GolemCount     = count[11];
                FishronCount   = count[12];
                CultistCount   = count[13];
                MoonlordCount  = count[14];
            }

            IList <string> downed = tag.GetList <string>("downed");

            downedBetsy          = downed.Contains("betsy");
            _downedBoss          = downed.Contains("boss");
            MasochistMode        = downed.Contains("m*******t");
            downedFishronEX      = downed.Contains("downedFishronEX");
            downedDevi           = downed.Contains("downedDevi");
            downedAbom           = downed.Contains("downedAbom");
            downedMutant         = downed.Contains("downedMutant");
            AngryMutant          = downed.Contains("AngryMutant");
            downedMM             = downed.Contains("downedMadhouse");
            forceMeteor          = downed.Contains("forceMeteor");
            NoMasoBossScaling    = downed.Contains("NoMasoBossScaling");
            ReceivedTerraStorage = downed.Contains("ReceivedTerraStorage");

            for (int i = 0; i < downedChampions.Length; i++)
            {
                downedChampions[i] = downed.Contains("downedChampion" + i.ToString());
            }

            if (tag.ContainsKey("mutantP1"))
            {
                skipMutantP1 = tag.GetAsInt("mutantP1");
            }
        }
Пример #30
0
        /////////////////

        public bool Load(WormholesMod mymod, TagCompound tags)
        {
            if (mymod.Config.Data.DisableNaturalWormholes)
            {
                return(false);
            }
            if (!tags.ContainsKey("wormhole_count"))
            {
                return(false);
            }

            int holes = tags.GetInt("wormhole_count");

            if (holes == 0)
            {
                return(false);
            }

            if (mymod.IsDebugInfoMode())
            {
                LogHelpers.Log("Loading world ids (" + Main.netMode + "): " + holes);
            }

            int[] worm_l_x = tags.GetIntArray("wormhole_left_x");
            int[] worm_l_y = tags.GetIntArray("wormhole_left_y");
            int[] worm_r_x = tags.GetIntArray("wormhole_right_x");
            int[] worm_r_y = tags.GetIntArray("wormhole_right_y");

            for (int i = 0; i < holes && i < worm_l_x.Length && i < WormholeManager.PortalCount; i++)
            {
                if (i < this.Links.Count && this.Links[i] != null)
                {
                    this.Links[i].Close();
                }

                string id = tags.GetString("wormhole_id_" + i);
                if (mymod.IsDebugInfoMode())
                {
                    LogHelpers.Log("  world load id: " + id + " (" + i + ")");
                }

                Vector2 pos_l = new Vector2(worm_l_x[i], worm_l_y[i]);
                Vector2 pos_r = new Vector2(worm_r_x[i], worm_r_y[i]);

                var link = new WormholeLink(id, WormholeLink.GetColor(i), pos_l, pos_r);

                // Failsafe against glitched portals
                if (link.IsMisplaced)
                {
                    ErrorLogger.Log("Found bad portal. " + i + " " + worm_l_x[i] + "," + worm_l_y[i]
                                    + " : " + worm_r_x[i] + "," + worm_r_y[i]);
                    WormholeManager.ForceRegenWormholes = true;
                    break;
                }

                this.Links.Insert(i, link);
            }
            return(true);
        }
Пример #31
0
            Type INbtTypeResolver.Resolve(TagCompound tag)
            {
                if (!tag.ContainsKey("Id"))
                    return null;

                string id = tag["Id"] as TagString;
                switch (id) {
                    case "Tile":
                        return typeof(TileLayer);
                    case "Object":
                        return typeof(ObjectLayer);
                    default:
                        return null;
                }
            }
Пример #32
0
        public static CompoundDiff Diff(TagCompound first, TagCompound second)
        {
            CompoundDiff diff = new CompoundDiff();

            foreach (var kv in first) {
                Tag firstValue = kv.Value;
                Tag secondValue = second.ContainsKey(kv.Key) ? second[kv.Key] : null;

                DiffOperation op = DiffValue(firstValue, secondValue);
                if (op != null)
                    diff.Operations[kv.Key] = op;
            }

            foreach (var kv in second) {
                if (!first.ContainsKey(kv.Key))
                    diff.Operations[kv.Key] = new ChangeOperation(kv.Value);
            }

            return diff;
        }