Example #1
0
        public override void writeToNbt(NbtCompound tag)
        {
            base.writeToNbt(tag);

            tag.setTag("damageDelt", this.damage);
            tag.setTag("shooter", Util.isAlive(this.shooter) ? this.shooter.getGuid() : Guid.Empty);
        }
Example #2
0
        public override void writeToNbt(NbtCompound tag)
        {
            base.writeToNbt(tag);

            tag.setTag("fireCooldown", this.fireCooldown);
            tag.setTag("targetGuid", this.target.getGuid());
        }
Example #3
0
    public NbtCompound writeToNbt()
    {
        NbtCompound tag = new NbtCompound("world");

        // Write general world info:
        tag.setTag("seed", this.seed);
        tag.setTag("stoneExcavated", this.stoneExcavated);

        if (this.money != null)
        {
            tag.setTag("money", this.money.value);
        }

        // Write level:
        NbtCompound tagStorage = new NbtCompound("storage");

        this.storage.writeToNbt(tagStorage);
        tag.Add(tagStorage);

        // Write Player:
        if (CameraController.instance != null)
        {
            tag.setTag("player", CameraController.instance.writeToNbt());
        }

        // Write all child componenets that implement ISaveableState to NBT
        foreach (ISaveableState saveable in this.GetComponentsInChildren <ISaveableState>())
        {
            NbtCompound compound = new NbtCompound();
            saveable.writeToNbt(compound);
            tag.setTag(saveable.tagName, compound);
        }

        return(tag);
    }
Example #4
0
        public override void writeToNbt(NbtCompound tag)
        {
            base.writeToNbt(tag);

            tag.setTag("produceTime", this.time);
            tag.setTag("heldResources", this.heldResources);
        }
Example #5
0
        /// <summary>
        /// Saves the game state to a file.
        /// </summary>
        public void saveToFile()
        {
            NbtCompound root = new NbtCompound("root");

            NbtCompound unlockedItems = new NbtCompound();

            unlockedItems.setTag("foundYoke", this.foundYoke);
            unlockedItems.setTag("foundPlayingCard", this.foundPlayingCard);
            unlockedItems.setTag("foundHammer", this.foundHammer);
            unlockedItems.setTag("foundGlasses", this.foundReadingGlasses);
            unlockedItems.setTag("foundKey", this.foundKey);

            root.setTag("townObstacleRemoved", this.townObstacleRemoved);
            root.setTag("seenCutscene", this.seenCutscene);

            NbtCompound levelsTag = new NbtCompound("levels");

            foreach (Level level in this.allLevels)
            {
                levelsTag.Add(level.writeToNbt());
            }
            root.Add(levelsTag);

            NbtFile file = new NbtFile(root);

            Directory.CreateDirectory(Main.SAVE_PATH);
            file.SaveToFile(Main.SAVE_PATH + FILE_NAME, NbtCompression.None);
        }
Example #6
0
 public virtual void writeToNbt(NbtCompound tag)
 {
     tag.setTag("id", this.id);
     tag.setTag("position", this.worldPos);
     tag.setTag("depth", this.depth);
     tag.setTag("facing", this.rotation.id);
     tag.setTag("guid", this.guid);
 }
Example #7
0
    /// <summary>
    /// Writes the passed Vector2Int to the passed tag.
    /// </summary>
    public static void setTag(this NbtCompound tag, string name, Vector2Int vector)
    {
        NbtCompound compound = new NbtCompound(name);

        compound.setTag("x", vector.x);
        compound.setTag("y", vector.y);
        tag.Add(compound);
    }
Example #8
0
        public override void writeToNbt(NbtCompound tag)
        {
            base.writeToNbt(tag);

            tag.setTag("isBuilding", this.constructing);
            tag.setTag("progress", this.buildProgress);
            tag.setTag("targetRotation", this.targetRotation);
        }
Example #9
0
    public void writeToNbt(NbtCompound tag)
    {
        // Write tiles:
        int[] idArray       = new int[this.tiles.Length];
        int[] rotationArray = new int[this.tiles.Length];
        for (int i = 0; i < this.tiles.Length; i++)
        {
            CellState state = this.tiles[i];
            idArray[i] = Main.instance.tileRegistry.getIdOfElement(state.data);
            if (state.rotation == null)
            {
                Debug.Log(state.data.name);
            }
            rotationArray[i] = state.rotation.id;
        }
        tag.setTag("tiles", idArray);
        tag.setTag("rotations", rotationArray);


        // Write tile meta:
        NbtList listTileMeta = new NbtList(NbtTagType.Compound);

        for (int x = 0; x < this.size; x++)
        {
            for (int y = 0; y < this.size; y++)
            {
                CellBehavior meta = this.getCellState(x, y).behavior;
                if (meta != null && meta is IHasData)
                {
                    NbtCompound behaviorTag = new NbtCompound();
                    behaviorTag.setTag("xPos", x);
                    behaviorTag.setTag("yPos", y);
                    ((IHasData)meta).writeToNbt(behaviorTag);
                    listTileMeta.Add(behaviorTag);
                }
            }
        }
        tag.setTag("meta", listTileMeta);

        // Write fog:
        if (this.hasFog())
        {
            NbtCompound fogTag = new NbtCompound();
            this.fog.writeToNbt(fogTag);
            tag.setTag("fog", fogTag);
        }

        // Write temperature:
        int[] tempArray = new int[this.temperatures.Length];
        for (int i = 0; i < this.temperatures.Length; i++)
        {
            tempArray[i] = (int)(this.temperatures[i] * 1_000_000f);
        }
        tag.setTag("temperature", tempArray);

        // Write hardness:
        tag.setTag("hardness", this.hardness);
    }
Example #10
0
 public void writeToNbt(NbtCompound tag)
 {
     if (this.risingItem != null)
     {
         tag.setTag("risingItemId", this.reg.getIdOfElement(this.risingItem.item));
         tag.setTag("risingCurveLength", this.risingItem.curveLength);
         tag.setTag("risingTimer", this.risingItem.timer);
     }
 }
Example #11
0
        public NbtCompound writeToNbt()
        {
            NbtCompound tag = new NbtCompound();

            tag.setTag("cellId", Main.instance.tileRegistry.getIdOfElement(this.cell));
            tag.setTag("offset", this.position.vec3Int);
            tag.setTag("addFog", this.addFogOnComplete);
            return(tag);
        }
Example #12
0
        public void writeToNbt(NbtCompound tag)
        {
            NbtCompound tag1 = new NbtCompound("time");

            tag1.setTag("daysElapsed", this.daysElapsed);
            tag1.setTag("currentTime", this.currentTime);

            tag.Add(tag1);
        }
Example #13
0
    public NbtCompound writeToNbt()
    {
        NbtCompound tag = new NbtCompound();

        tag.setTag("info", this.info.writeToNbt());
        tag.setTag("type", Main.instance.workerTypeRegistry.getIdOfElement(this.type));

        return(tag);
    }
Example #14
0
    public static void setTag(this NbtCompound tag, string name, Position pos)
    {
        NbtCompound compound = new NbtCompound(name);

        compound.setTag("x", pos.x);
        compound.setTag("y", pos.y);
        compound.setTag("depth", pos.depth);
        tag.Add(compound);
    }
Example #15
0
    public NbtCompound writeToNbt()
    {
        NbtCompound tag = new NbtCompound("data");

        tag.setTag("mapName", this.saveName);
        tag.setTag("seed", this.seed);

        return(tag);
    }
Example #16
0
    public override void writeToNbt(NbtCompound tag)
    {
        base.writeToNbt(tag);

        tag.setTag("cooldown", this.harvestCooldown);
        if (this.target != null)
        {
            tag.setTag("target", this.target.getGuid());
        }
    }
Example #17
0
    public NbtCompound writeToNbt()
    {
        NbtCompound tag = new NbtCompound();

        tag.setTag("info", this.info.writeToNbt());
        tag.setTag("type", Main.instance.workerTypeRegistry.getIdOfElement(this.type));
        tag.setTag("endAvailabilityTime", this.endAvailabilityTime); // TODO should this be a long, will there be an overflow?

        return(tag);
    }
Example #18
0
    /// <summary>
    /// Writes the passed Quaternion to the passed tag.
    /// </summary>
    public static void setTag(this NbtCompound tag, string name, Quaternion quaternion)
    {
        NbtCompound compound = new NbtCompound(name);

        compound.setTag("w", quaternion.w);
        compound.setTag("x", quaternion.x);
        compound.setTag("y", quaternion.y);
        compound.setTag("z", quaternion.z);
        tag.Add(compound);
    }
Example #19
0
    public override void writeToNbt(NbtCompound tag)
    {
        base.writeToNbt(tag);

        if (this.building != null)
        {
            tag.setTag("building", this.building.getGuid());
        }
        tag.setTag("timeWhacking", this.timeWhacking);
        tag.setTag("whackPoint", this.whackPoint);
    }
Example #20
0
    public void writeToNbt(NbtCompound tag)
    {
        NbtList entriesTagList = new NbtList(NbtTagType.Compound);

        foreach (Entry e in this.entires)
        {
            entriesTagList.Add(e.writeToNbt());
        }
        tag.setTag("entries", entriesTagList);

        tag.setTag("isPrimary", this.isPrimary);
        tag.setTag("constructionTime", this.constructionTime);
    }
Example #21
0
    public NbtCompound writeToNbt()
    {
        NbtCompound tag = new NbtCompound();

        tag.setTag("layer", this.currentLayer);
        tag.setTag("zoomLevel", this.currentZoom);
        Transform camTrans = this.mainCam.transform;

        tag.setTag("cameraPos", new Vector2(camTrans.position.x, camTrans.position.y));
        tag.setTag("inCreativeMode", this.inCreativeMode);

        return(tag);
    }
Example #22
0
        public override void writeToNbt(NbtCompound tag)
        {
            base.writeToNbt(tag);

            tag.setTag("lastPos", this.lastPos);
            this.unitStats.writeToNBT(tag);

            tag.setTag("hasMovementOverride", this.overrideMovementDestination != null);
            if (this.overrideMovementDestination != null)
            {
                tag.setTag("overrideMovementDestination", (Vector3)this.overrideMovementDestination);
                tag.setTag("overrideMovementStopDis", this.overrideMovementStopDis);
            }
        }
Example #23
0
    public void writeToNbt(NbtCompound tag)
    {
        NbtList targetedTilesList = new NbtList(NbtTagType.Compound);

        foreach (TargetedSquare square in this.list)
        {
            NbtCompound compound = new NbtCompound();
            compound.setTag("x", square.pos.x);
            compound.setTag("y", square.pos.y);
            compound.setTag("depth", square.pos.depth);
            compound.setTag("isPriority", square.isPriority);
            targetedTilesList.Add(compound);
        }
        tag.setTag("targetedTiles", targetedTilesList);
    }
Example #24
0
 public virtual void writeToNbt(NbtCompound tag)
 {
     if (this.inventory != null)
     {
         tag.setTag("inventory", this.inventory.writeToNbt());
     }
 }
Example #25
0
        public NbtCompound writeToNbt()
        {
            NbtCompound tag = new NbtCompound(this.sceneName);

            tag.setTag("unlocked", this.unlocked);
            return(tag);
        }
Example #26
0
        public void writeToNbt(NbtCompound tag)
        {
            tag.setTag("generatorId", this.generatorId);
            tag.setTag("seed", this.seed);
            tag.setTag("cameraPosition", CameraMover.instance().transform.parent.position);

            // Write all the Teams to NBT.
            NbtCompound tagTeams = new NbtCompound("teams");

            foreach (Team team in Team.ALL_TEAMS)
            {
                team.writeToNbt(tagTeams);
            }
            tag.Add(tagTeams);

            this.dayNightCycle.writeToNbt(tag);
        }
Example #27
0
        public void writeToNbt(NbtCompound tag)
        {
            NbtCompound tag1 = new NbtCompound(this.internalName);

            tag1.setTag("resources", this.resources);

            tag.Add(tag1);
        }
Example #28
0
 public void writeToNbt(NbtCompound tag)
 {
     byte[] array = new byte[this.fogMap.Length];
     for (int i = 0; i < this.fogMap.Length; i++)
     {
         array[i] = this.fogMap[i] ? (byte)1 : (byte)0;
     }
     tag.setTag("fog", array);
 }
Example #29
0
 public void writeToNbt(NbtCompound tag)
 {
     int[] lockFlags = new int[this._milestoneData.Length];
     for (int i = 0; i < this._milestoneData.Length; i++)
     {
         lockFlags[i] = this._milestoneData[i].isUnlocked ? 1 : 0;
     }
     tag.setTag("milestoneUnlockFlags", lockFlags);
 }
Example #30
0
    public void writeToNbt(NbtCompound tag)
    {
        // Write Plot costs:
        int[] costArray = new int[this.plots.Length];
        for (int i = 0; i < this.plots.Length; i++)
        {
            costArray[i] = this.plots[i].cost;
        }
        tag.setTag("costs", costArray);

        // Write Plot isOwned state:
        byte[] isOwnedArray = new byte[this.plots.Length];
        for (int i = 0; i < this.plots.Length; i++)
        {
            isOwnedArray[i] = this.plots[i].isOwned ? (byte)1 : (byte)0;
        }
        tag.setTag("isOwned", isOwnedArray);
    }