예제 #1
0
    public void readFromNbt(NbtCompound tag)
    {
        this.resources = tag.getIntArray("resources");

        foreach (NbtCompound compound in tag.getList("mapObjects"))
        {
            int id = compound.getInt("id");
            RegisteredObject registeredObject = Registry.getObjectFromRegistry(id);
            if (registeredObject != null)
            {
                SpawnInstructions <MapObject> instructions = this.spawnEntity <MapObject>(registeredObject, compound);
                instructions.getObj().map    = this;
                instructions.getObj().nbtTag = compound;
            }
            else
            {
                Logger.logError("MapObject with an unknown ID of " + id + " was found!  Ignoring!");
            }
        }

        // Now that every MapObject is loaded and their Guid is set, preform the normal reading from nbt.
        foreach (MapObject obj in this.mapObjects)
        {
            obj.readFromNbt(obj.nbtTag);
        }
    }
예제 #2
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");
    }
예제 #3
0
    public virtual void readFromNbt(NbtCompound tag)
    {
        MinedItemRegistry reg = Main.instance.itemRegistry;

        int[] ids = tag.getIntArray("itemIds");
        for (int i = 0; i < ids.Length; i++)
        {
            Item item = reg.getElement(ids[i]);
            if (item != null)
            {
                this.items[i] = item;
            }
        }
    }
예제 #4
0
    public void readFromNbt(NbtCompound tag)
    {
        // Read Plot costs:
        int[] costArray = tag.getIntArray("costs");
        for (int i = 0; i < Mathf.Min(this.plots.Length, costArray.Length); i++)
        {
            this.plots[i].cost = costArray[i];
        }

        // Read Plot isOwned state:
        byte[] isOwnedArray = tag.getByteArray("isOwned");
        for (int i = 0; i < Mathf.Min(this.plots.Length, isOwnedArray.Length); i++)
        {
            this.plots[i].isOwned = isOwnedArray[i] == 1;
        }
    }
예제 #5
0
 public void readFromNbt(NbtCompound tag)
 {
     int[] milestoneLockFlags = tag.getIntArray("milestoneUnlockFlags");
     for (int i = 0; i < this._milestoneData.Length; i++)
     {
         if (i >= milestoneLockFlags.Length)
         {
             // No data about this milestone, assume it's locked
             if (this._milestoneData[i] != null)  // Sometimes the array fields are left blank in the inspector
             {
                 this._milestoneData[i].isUnlocked = false;
             }
         }
         else
         {
             this._milestoneData[i].isUnlocked = milestoneLockFlags[i] == 1;
         }
     }
 }