예제 #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)
    {
        NbtList entityTags = tag.getList("entities");

        foreach (NbtCompound tagEntity in entityTags)
        {
            EntityBase entity = this.spawn(tagEntity);
        }
    }
예제 #3
0
    public void readFromNbt(NbtCompound tag)
    {
        NbtList tagList = tag.getList("entries");

        foreach (NbtCompound compound in tagList)
        {
            this.entires.Add(new Entry(compound));
        }

        this.isPrimary        = tag.getBool("isPrimary");
        this.constructionTime = tag.getFloat("constructionTime");
    }
예제 #4
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.trainingProgress = tag.getFloat("trainingProgress");

        NbtList list = tag.getList("trainingQueue");

        foreach (NbtInt integer in list)
        {
            this.trainingQueue.Add(Registry.getObjectFromRegistry(integer.Value));
        }
    }
예제 #5
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");
        }
    }
예제 #6
0
 public static void readList(NbtCompound rootTag, string tagName, Map map)
 {
     foreach (NbtCompound compound in rootTag.getList(tagName))
     {
         int id = compound.getInt("id");
         RegisteredObject registeredObject = Registry.getObjectFromRegistry(id);
         if (registeredObject != null)
         {
             map.spawnEntity(registeredObject, compound);
         }
         else
         {
             Debug.Log("Error!  MapObject with an unknown ID of " + id + " was found!  Ignoring!");
         }
     }
 }
예제 #7
0
    public void readFromNbt(NbtCompound tag)
    {
        NbtList listTargetedTags = tag.getList("targetedTiles");

        foreach (NbtCompound targetedTag in listTargetedTags)
        {
            if (!targetedTag.Contains("x") || !targetedTag.Contains("y"))
            {
                Debug.LogWarning("Targeted Tile found with a position of -1.  Ignoring!");
                continue;
            }
            int  x        = targetedTag.getInt("x");
            int  y        = targetedTag.getInt("y");
            int  depth    = targetedTag.getInt("depth");
            bool priority = targetedTag.getBool("isPriority");
            this.startTargeting(new Position(x, y, depth), priority);
        }
    }
예제 #8
0
    public void readFromNbt(NbtCompound tag)
    {
        this.aboveGroundMap = tag.getByteArray("aboveGroundMap");

        this.workerSpawnPoint = tag.getPosition("workerSpawnPoint");

        // Read Layers:
        NbtList layers = tag.getList("layers");

        for (int i = 0; i < layers.Count; i++)
        {
            Layer       layer         = new Layer(this.world, i);
            NbtCompound layerCompound = layers.Get <NbtCompound>(i);
            layer.readFromNbt(layerCompound);
            this.layers[layer.depth] = layer;

            // Call onCreate method for all the behaviors, now that all Cell's
            // have been loaded.
            for (int x = 0; x < this.world.mapSize; x++)
            {
                for (int y = 0; y < this.world.mapSize; y++)
                {
                    CellState state = layer.getCellState(x, y);
                    if (state.behavior != null)
                    {
                        state.behavior.onCreate(this.world, state, new Position(x, y, layer.depth));
                    }
                }
            }

            // After onCreate is called for all of the behaviors, let them read their
            // state from NBT.
            NbtList listBehaviorTags = layerCompound.getList("meta");
            foreach (NbtCompound behaviorTag in listBehaviorTags)
            {
                CellBehavior meta = layer.getCellState(behaviorTag.getInt("xPos"), behaviorTag.getInt("yPos")).behavior;
                if (meta != null && meta is IHasData)
                {
                    ((IHasData)meta).readFromNbt(behaviorTag);
                }
            }
        }
    }