public object GetSaveData()
        {
            if (!enemy)
            {
                return(null);
            }

            // Get entity behaviour
            DaggerfallEntityBehaviour entityBehaviour = enemy.GetComponent <DaggerfallEntityBehaviour>();

            if (!entityBehaviour)
            {
                return(null);
            }

            // Create save data
            EnemyEntity          entity      = entityBehaviour.Entity as EnemyEntity;
            EnemyMotor           motor       = enemy.GetComponent <EnemyMotor>();
            EnemySenses          senses      = enemy.GetComponent <EnemySenses>();
            DaggerfallMobileUnit mobileEnemy = enemy.GetComponentInChildren <DaggerfallMobileUnit>();
            EnemyData_v1         data        = new EnemyData_v1();

            data.loadID               = LoadID;
            data.gameObjectName       = entityBehaviour.gameObject.name;
            data.currentPosition      = enemy.transform.position;
            data.localPosition        = enemy.transform.localPosition;
            data.currentRotation      = enemy.transform.rotation;
            data.worldContext         = entity.WorldContext;
            data.worldCompensation    = GameManager.Instance.StreamingWorld.WorldCompensation;
            data.entityType           = entity.EntityType;
            data.careerName           = entity.Career.Name;
            data.careerIndex          = entity.CareerIndex;
            data.startingHealth       = entity.MaxHealth;
            data.currentHealth        = entity.CurrentHealth;
            data.currentFatigue       = entity.CurrentFatigue;
            data.currentMagicka       = entity.CurrentMagicka;
            data.isHostile            = motor.IsHostile;
            data.hasEncounteredPlayer = senses.HasEncounteredPlayer;
            data.isDead               = (entity.CurrentHealth <= 0) ? true : false;
            data.questSpawn           = enemy.QuestSpawn;
            data.mobileGender         = mobileEnemy.Summary.Enemy.Gender;
            data.items                   = entity.Items.SerializeItems();
            data.equipTable              = entity.ItemEquipTable.SerializeEquipTable();
            data.instancedEffectBundles  = GetComponent <EntityEffectManager>().GetInstancedBundlesSaveData();
            data.alliedToPlayer          = mobileEnemy.Summary.Enemy.Team == MobileTeams.PlayerAlly;
            data.questFoeSpellQueueIndex = entity.QuestFoeSpellQueueIndex;
            data.questFoeItemQueueIndex  = entity.QuestFoeItemQueueIndex;
            data.wabbajackActive         = entity.WabbajackActive;
            data.team = (int)entity.Team + 1;

            // Add quest resource data if present
            QuestResourceBehaviour questResourceBehaviour = GetComponent <QuestResourceBehaviour>();

            if (questResourceBehaviour)
            {
                data.questResource = questResourceBehaviour.GetSaveData();
            }

            return(data);
        }
Exemple #2
0
        public object GetSaveData()
        {
            if (!enemy)
            {
                return(null);
            }

            // Get entity behaviour
            DaggerfallEntityBehaviour entityBehaviour = enemy.GetComponent <DaggerfallEntityBehaviour>();

            if (!entityBehaviour)
            {
                return(null);
            }

            // Create save data
            EnemyEntity          entity      = entityBehaviour.Entity as EnemyEntity;
            EnemyMotor           motor       = enemy.GetComponent <EnemyMotor>();
            EnemySenses          senses      = enemy.GetComponent <EnemySenses>();
            DaggerfallMobileUnit mobileEnemy = enemy.GetComponentInChildren <DaggerfallMobileUnit>();
            EnemyData_v1         data        = new EnemyData_v1();

            data.loadID               = LoadID;
            data.gameObjectName       = entityBehaviour.gameObject.name;
            data.currentPosition      = enemy.transform.position;
            data.currentRotation      = enemy.transform.rotation;
            data.entityType           = entity.EntityType;
            data.careerName           = entity.Career.Name;
            data.careerIndex          = entity.CareerIndex;
            data.startingHealth       = entity.MaxHealth;
            data.currentHealth        = entity.CurrentHealth;
            data.currentFatigue       = entity.CurrentFatigue;
            data.currentMagicka       = entity.CurrentMagicka;
            data.isHostile            = motor.IsHostile;
            data.hasEncounteredPlayer = senses.HasEncounteredPlayer;
            data.isDead               = (entity.CurrentHealth <= 0) ? true : false;
            data.questSpawn           = enemy.QuestSpawn;
            data.mobileGender         = mobileEnemy.Summary.Enemy.Gender;
            data.items      = entity.Items.SerializeItems();
            data.equipTable = entity.ItemEquipTable.SerializeEquipTable();

            // Add quest resource data if present
            QuestResourceBehaviour questResourceBehaviour = GetComponent <QuestResourceBehaviour>();

            if (questResourceBehaviour)
            {
                data.questResource = questResourceBehaviour.GetSaveData();
            }

            return(data);
        }