public void readFromNbt(NbtCompound tag) { NbtCompound tag1 = tag.getCompound("time"); this.daysElapsed = tag.getInt("daysElapsed"); this.currentTime = tag.getInt("currentTime"); }
/// <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")); } }
public virtual void readFromNbt(NbtCompound tag) { if (this.inventory != null) { this.inventory.readFromNbt(tag.getCompound("inventory")); } }
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))); }
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"); }
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))); }
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))); }
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); }
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))); }
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"); } }
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); }
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); } }
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"); }
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); }
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); }
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); }
public override void readFromNbt(NbtCompound tag) { base.readFromNbt(tag); this.inventory.readFromNbt(tag.getCompound("inventory")); }
public void readFromNbt(NbtCompound tag) { NbtCompound tag1 = tag.getCompound(this.internalName); this.setResources(tag1.getInt("resources")); }
public Trainee(NbtCompound tag) { this.info = new WorkerInfo(tag.getCompound("info")); this.type = Main.instance.workerTypeRegistry.getElement(tag.getInt("type")); }
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"); }