예제 #1
0
 public void readFromNbt(NbtCompound tag)
 {
     if (tag.hasKey("risingItemId"))
     {
         this.risingItem = new RisingItem(
             this.reg.getElement(tag.getInt("risingItemId")),
             tag.getFloat("risingCurveLength"));
         this.risingItem.timer = tag.getFloat("risingTimer");
     }
 }
예제 #2
0
    public static Vector2 getVector2(this NbtCompound tag, string name, Vector2?defaultValue = null)
    {
        if (defaultValue == null)
        {
            defaultValue = Vector2.zero;
        }

        NbtCompound compound = tag.getCompound(name);

        return(new Vector2(
                   compound.getFloat("x", ((Vector2)defaultValue).x),
                   compound.getFloat("y", ((Vector2)defaultValue).y)));
    }
예제 #3
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)));
    }
예제 #4
0
        public override void readFromNbt(NbtCompound tag)
        {
            base.readFromNbt(tag);

            this.time          = tag.getFloat("produceTime");
            this.heldResources = tag.getInt("heldResources");
        }
예제 #5
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.harvestCooldown = tag.getFloat("cooldown");
        this.target          = this.unit.map.findMapObjectFromGuid <HarvestableObject>(tag.getGuid("target"));
    }
예제 #6
0
        public override void readFromNbt(NbtCompound tag)
        {
            base.readFromNbt(tag);

            this.constructing   = tag.getBool("isBuilding");
            this.buildProgress  = tag.getFloat("progress");
            this.targetRotation = tag.getInt("targetRotation");
        }
예제 #7
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);
        }
    }
예제 #8
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");
    }
예제 #9
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));
        }
    }
예제 #10
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.timeWhacking = tag.getFloat("timeWhacking");
        this.whackPoint   = tag.getVector3("whackPoint");
        this.moveHelper.setDestination(this.whackPoint);
        BuildingBase b = this.unit.map.findMapObjectFromGuid <BuildingBase>(tag.getGuid("building"));

        if (b != null)
        {
            this.setBuilding(b);
        }
    }
예제 #11
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);
    }
예제 #12
0
        public override void readFromNbt(NbtCompound tag)
        {
            base.readFromNbt(tag);

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

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

            if (flag)
            {
                this.overrideMovementDestination = tag.getVector3("overrideMovementDestination");
                this.overrideMovementStopDis     = tag.getFloat("overrideMovementStopDis");
            }
        }
예제 #13
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");
        }
    }
예제 #14
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.fireCooldown = tag.getFloat("fireCooldown");
        MapObject obj = this.map.findMapObjectFromGuid <MapObject>(tag.getGuid("targetGuid"));

        if (obj is UnitBase)
        {
            this.target = (UnitBase)obj;
        }
        else
        {
            this.target = null;
        }
    }
예제 #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 override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.timeRemaining = tag.getFloat("fireTime");
    }
예제 #17
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.transferTimer = tag.getFloat("transferTimer");
    }
예제 #18
0
    public override void readFromNbt(NbtCompound tag)
    {
        base.readFromNbt(tag);

        this.time = tag.getFloat("produceTime");
    }
예제 #19
0
 public void readFromNbt(NbtCompound tag)
 {
     this.pullTimer = tag.getFloat("conveyorPullTimer");
 }
예제 #20
0
 public override void readFromNbt(NbtCompound tag)
 {
     this.value = tag.getFloat(this.saveName);
 }