Exemple #1
0
        public void Load()
        {
            if (!m_Loaded)
            {
                m_Loaded = true;
                Start();
                log.InfoFormat("PlayerShip LOad() [dy]");
                var workshop = (Workshop)GetComponent <CharacterObject>().workshop;
                var dropMgr  = DropManager.Get(nebulaObject.world.Resource());


                //ShipModelDocument document = GameApplication.Instance.Load(player.nebulaObject.Id, mCharacter.characterId, DatabaseDocumentType.ShipModel) as ShipModelDocument;

                var  app   = nebulaObject.mmoWorld().application;
                bool isNew = false;

                if (mCharacter == null)
                {
                    mCharacter = GetComponent <PlayerCharacterObject>();
                }
                if (string.IsNullOrEmpty(mCharacter.characterId))
                {
                    mCharacter.SetCharacterId((string)nebulaObject.Tag((byte)PlayerTags.CharacterId));
                }
                var dbModel = ShipModelDatabase.instance(app).LoadShipModel(mCharacter.characterId, resource as Res, out isNew);

                if (shipModel == null)
                {
                    SetModel(new ShipModel(resource));
                }

                if (isNew)
                {
                    GenerateNewShipModel(dropMgr);
                    ShipModelDatabase.instance(app).SaveShipModel(mCharacter.characterId, shipModel);
                }
                else
                {
                    shipModel.Replace(dbModel);
                }

                shipModel.Update();
                GetComponent <MmoActor>().EventOnShipModelUpdated();
                log.Info("PlayerShip.Load() completed");
            }
        }
        public void Save(bool forceSaveToDB)
        {
            if (mLoaded)
            {
                if (player == null)
                {
                    return;
                }
                var character = GetComponent <PlayerCharacterObject>();
                if (character == null)
                {
                    return;
                }

                try {
                    var app = nebulaObject.mmoWorld().application;
                    InventoryDatabase.instance(app).SaveInventory(character.characterId, player.Inventory);
                    StationDatabase.instance(app).SaveStation(character.characterId, player.Station);
                    CharacterDatabase.instance(app).SaveCharacter(character.characterId, player.GetPlayerCharacter());
                    ShipModelDatabase.instance(app).SaveShipModel(character.characterId, GetComponent <PlayerShip>().shipModel);
                    SkillDatabase.instance(app).SaveSkills(character.characterId, GetComponent <PlayerSkills>().GetSave());
                    WeaponDatabase.instance(app).SaveWeapon(character.characterId, player.GetComponent <ShipWeapon>().GetSave());
                    PassiveBonusesDatabase.instance(app).SavePassiveBonuses(character.characterId, player.GetComponent <PassiveBonusesComponent>().GetSave());
                    TimedEffectsDatabase.instance(app).SaveTimedEffects(character.characterId, player.GetComponent <PlayerTimedEffects>().GetInfo());
                    PetDatabase.instance(app).SavePets(character.characterId, player.GetComponent <PetManager>().pets);
                    ContractDatabase.instance(app).SaveContracts(character.characterId, player.GetComponent <ContractManager>().GetSave());
                    AchievmentDatabase.instance(app).SaveAchievment(character.characterId, player.GetComponent <AchievmentComponent>().GetSave());
                    QuestDatabase.instance(app).SaveQuests(character.characterId, player.GetComponent <QuestManager>().GetSave());
                    //QuestDatabase.instance(app).SaveQuests(character.characterId, player.GetComponent<QuestManager>().GetInfo());
                    //DialogDatabase.instance(app).SaveDialogs(character.characterId, player.GetComponent<DialogManager>().GetInfo());
                } catch (Exception exception) {
                    log.Error("handled exception at Player Loaded Object");
                    log.Error(exception.Message);
                    log.Error(exception.StackTrace);
                }
            }
        }