예제 #1
0
        public void readFromNbt(NbtCompound tag)
        {
            NbtCompound tag1 = tag.getCompound("time");

            this.daysElapsed = tag.getInt("daysElapsed");
            this.currentTime = tag.getInt("currentTime");
        }
예제 #2
0
    /// <summary>
    /// Initializes the World and reads it from NBT.
    /// </summary>
    public void initialize(string saveName, NbtCompound rootTag)
    {
        this.saveName = saveName;

        this.preInitialization();

        this.readFromNbt(rootTag);

        // In the event of addition Layers being added in development,
        // there will be more layers in the MapGenerationData than
        // layers read.  Generate the new ones.
        for (int i = 0; i < this.storage.layerCount; i++)
        {
            if (this.storage.getLayer(i) == null)
            {
                this.mapGenerator.generateLayer(this, i);
            }
        }

        this.postInitialization();

        // Read Player:
        if (CameraController.instance != null)
        {
            CameraController.instance.readFromNbt(rootTag.getCompound("world").getCompound("player"));
        }
    }
예제 #3
0
 public virtual void readFromNbt(NbtCompound tag)
 {
     if (this.inventory != null)
     {
         this.inventory.readFromNbt(tag.getCompound("inventory"));
     }
 }
예제 #4
0
    public static Vector2Int getVector2Int(this NbtCompound tag, string name, Vector2Int?defaultValue = null)
    {
        if (defaultValue == null)
        {
            defaultValue = Vector2Int.zero;
        }

        NbtCompound compound = tag.getCompound(name);

        return(new Vector2Int(
                   compound.getInt("x", ((Vector2Int)defaultValue).x),
                   compound.getInt("y", ((Vector2Int)defaultValue).y)));
    }
예제 #5
0
        private void readFromNbt(NbtCompound root)
        {
            NbtCompound unlockedItems = root.getCompound("unlockedItems");

            this.foundYoke           = unlockedItems.getBool("foundYoke");
            this.foundPlayingCard    = unlockedItems.getBool("foundPlayingCard");
            this.foundHammer         = unlockedItems.getBool("foundHammer");
            this.foundReadingGlasses = unlockedItems.getBool("foundGlasses");
            this.foundKey            = unlockedItems.getBool("foundKey");

            this.townObstacleRemoved = root.getBool("townObstacleRemoved");
            this.seenCutscene        = root.getBool("seenCutscene");
        }
예제 #6
0
    public static Position getPosition(this NbtCompound tag, string name, Position?defaultValue = null)
    {
        if (defaultValue == null)
        {
            defaultValue = new Position(0, 0, 0);
        }

        NbtCompound compound = tag.getCompound(name);

        return(new Position(
                   compound.getInt("x", ((Position)defaultValue).x),
                   compound.getInt("y", ((Position)defaultValue).y),
                   compound.getInt("depth", ((Position)defaultValue).x)));
    }
예제 #7
0
    public static Vector3 getVector3(this NbtCompound tag, string name, Vector3?defaultValue = null)
    {
        if (defaultValue == null)
        {
            defaultValue = Vector3.zero;
        }

        NbtCompound compound = tag.getCompound(name);

        return(new Vector3(
                   compound.getFloat("x", ((Vector3)defaultValue).x),
                   compound.getFloat("y", ((Vector3)defaultValue).y),
                   compound.getFloat("z", ((Vector3)defaultValue).z)));
    }
예제 #8
0
    public void readFromNbt(NbtCompound rootTag)
    {
        NbtCompound tag = rootTag.getCompound("world");

        // Read general world info:
        this.seed           = tag.getInt("seed");
        this.stoneExcavated = tag.getInt("stoneExcavated");

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

        foreach (ISaveableState saveable in this.GetComponentsInChildren <ISaveableState>())
        {
            saveable.readFromNbt(tag.getCompound(saveable.tagName));
        }

        // Read level:
        NbtCompound tagStorage = tag.getCompound("storage");

        this.storage.readFromNbt(tagStorage);
    }
예제 #9
0
    public static Quaternion getQuaternion(this NbtCompound tag, string name, Quaternion?defaultValue = null)
    {
        if (defaultValue == null)
        {
            defaultValue = Quaternion.identity;
        }

        NbtCompound compound = tag.getCompound(name);

        return(new Quaternion(
                   compound.getFloat("w", ((Quaternion)defaultValue).w),
                   compound.getFloat("x", ((Quaternion)defaultValue).x),
                   compound.getFloat("y", ((Quaternion)defaultValue).y),
                   compound.getFloat("z", ((Quaternion)defaultValue).z)));
    }
예제 #10
0
    public void readFromNbt(NbtCompound tag)
    {
        NbtList list = tag.getList("candidates");

        for (int i = 0; i < list.Count; i++)
        {
            this.candidates.Add(new Candidate(list.Get <NbtCompound>(i)));
        }

        if (tag.hasKey("trainee"))
        {
            this.trainee             = new Trainee(tag.getCompound("trainee"));
            this.traineeTrainingTime = tag.getFloat("trainingTime");
        }
    }
예제 #11
0
        public void readFromNbt(NbtCompound tag)
        {
            this.generatorId = tag.getInt("generatorId");
            this.seed        = tag.getInt("seed");
            CameraMover.instance().setPostion(tag.getVector3("cameraPosition"));

            NbtCompound tagTeams = tag.getCompound("teams");

            foreach (Team team in Team.ALL_TEAMS)
            {
                team.readFromNbt(tagTeams);
            }

            this.dayNightCycle.readFromNbt(tag);
        }
예제 #12
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.energy.value      = tag.getFloat("energy");
        this.hunger.value      = tag.getFloat("hunger");
        this.temperature.value = tag.getFloat("temperature");
        this.happiness.value   = tag.getFloat("happiness");
        this.isDead            = tag.getBool("isDead");
        this.info = new WorkerInfo(tag.getCompound("workerInfo"));
        this.setType(Main.instance.workerTypeRegistry.getElement(tag.getInt("workerType")));

        // Read Ai Meta objects from NBT
        foreach (IAiMeta meta in this.GetComponentsInChildren <IAiMeta>())
        {
            meta.readFromNbt(tag);
        }
    }
예제 #13
0
    public void readFromNbt(NbtCompound tag)
    {
        // Read tiles:
        CellData[] tileArray = new CellData[this.size * this.size];

        int[] tileIds   = tag.getIntArray("tiles");
        int[] rotations = tag.getIntArray("rotations");

        int index = 0;

        for (int x = 0; x < this.size; x++)
        {
            for (int y = 0; y < this.size; y++)
            {
                int      i = this.size * x + y;
                CellData d = Main.instance.tileRegistry.getElement(tileIds[i]);
                this.setCell(
                    x,
                    y,
                    d == null ? Main.instance.tileRegistry.getAir() : d,
                    Rotation.ALL[rotations[i]],
                    false,
                    false);
                index++;
            }
        }

        // Read fog:
        if (this.hasFog())
        {
            this.fog.readFromNbt(tag.getCompound("fog"));
        }

        // Read temperatures:
        int[] tempArray = tag.getIntArray("temperature");
        for (int i = 0; i < Mathf.Min(this.temperatures.Length, tempArray.Length); i++)
        {
            this.temperatures[i] = tempArray[i] / 1_000_000f;
        }

        // Read hardness:
        this.hardness = tag.getIntArray("hardness");
    }
예제 #14
0
        public UnitStats(NbtCompound tag, EntityBaseStats baseStats) : this()
        {
            this.baseStats = baseStats;

            NbtCompound tag1 = tag.getCompound("stats");

            this.firstName      = tag1.getString("firstName");
            this.lastName       = tag1.getString("lastName");
            this.gender         = tag1.getByte("gender") == 1 ? EnumGender.MALE : EnumGender.FEMALE;
            this.characteristic = Characteristic.ALL[tag1.getInt("characteristicID")];

            this.distanceWalked.readFromNbt(tag1);
            this.timeAlive.readFromNbt(tag1);
            this.unitsKilled.readFromNbt(tag1);
            this.buildingsDestroyed.readFromNbt(tag1);
            this.damageDelt.readFromNbt(tag1);
            this.damageTaken.readFromNbt(tag1);
            this.resourcesCollected.readFromNbt(tag1);
            this.buildingsBuilt.readFromNbt(tag1);
            this.repairsDone.readFromNbt(tag1);
        }
예제 #15
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.lastPos   = tag.getVector3("lastPos");
        this.unitStats = new UnitStats(tag, this.unitData);

        bool flag = tag.getBool("hasMovementOverride");

        if (flag)
        {
            this.overrideMovementDestination = tag.getVector3("overrideMovementDestination");
            this.overrideMovementStopDis     = tag.getFloat("overrideMovementStopDis");
            this.moveHelper.setDestination((Vector3)this.overrideMovementDestination, this.overrideMovementStopDis);
        }

        NbtCompound tagTask = tag.getCompound("task");
        ITask       task    = (ITask)Activator.CreateInstance(TaskManager.getTaskFromId(tagTask.getInt("taskID")), new object[] { (UnitBase)this });

        task.readFromNbt(tagTask);
        this.setTask(task, true);
    }
예제 #16
0
    public UnitStats(NbtCompound tag, UnitData unitData) : this()
    {
        this.unitData = unitData;

        NbtCompound tag1 = tag.getCompound("stats");

        this.firstName = tag1.getString("firstName");
        this.lastName  = tag1.getString("lastName");
        this.gender    = tag1.getByte("gender") == 1 ? EnumGender.MALE : EnumGender.FEMALE;

        this.distanceWalked.readFromNbt(tag1);
        this.timeAlive.readFromNbt(tag1);
        this.unitsKilled.readFromNbt(tag1);
        this.buildingsDestroyed.readFromNbt(tag1);
        this.damageDelt.readFromNbt(tag1);
        this.damageTaken.readFromNbt(tag1);
        this.resourcesCollected.readFromNbt(tag1);
        this.buildingsBuilt.readFromNbt(tag1);
        this.repairsDone.readFromNbt(tag1);

        this.hunger = tag1.getFloat("hunger", 1f);
        this.sleep  = tag1.getFloat("sleep", 1f);
    }
예제 #17
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.inventory.readFromNbt(tag.getCompound("inventory"));
    }
예제 #18
0
        public void readFromNbt(NbtCompound tag)
        {
            NbtCompound tag1 = tag.getCompound(this.internalName);

            this.setResources(tag1.getInt("resources"));
        }
예제 #19
0
 public Trainee(NbtCompound tag)
 {
     this.info = new WorkerInfo(tag.getCompound("info"));
     this.type = Main.instance.workerTypeRegistry.getElement(tag.getInt("type"));
 }
예제 #20
0
 public Candidate(NbtCompound tag)
 {
     this.info = new WorkerInfo(tag.getCompound("info"));
     this.type = Main.instance.workerTypeRegistry.getElement(tag.getInt("type"));
     this.endAvailabilityTime = tag.getDouble("endAvailabilityTime");
 }