Esempio n. 1
0
        public ArkCreature(IGameObject creature, IGameObject status, ISaveState saveState) : this()
        {
            _creature = creature;
            _status   = status;

            //Id = creature.Index;
            //Uuid = _creature.Uuid;
            Id1       = creature.GetPropertyValue <uint>(_dinoId1);
            Id2       = creature.GetPropertyValue <uint>(_dinoId2);
            ClassName = creature.ClassName.Name;
            IsBaby    = creature.GetPropertyValue <bool?>(_bIsBaby) ?? false;
            BabyAge   = creature.GetPropertyValue <float?>(_babyAge);
            Gender    = creature.GetPropertyValue <bool?>(_bIsFemale) == true ? ArkCreatureGender.Female : ArkCreatureGender.Male;
            for (var i = 0; i < Colors.Length; i++)
            {
                Colors[i] = creature.GetPropertyValue <sbyte?>(_colorSetIndices[i]) ?? 0;
            }
            if (status != null)
            {
                BaseLevel = status.GetPropertyValue <int?>(_baseCharacterLevel) ?? 1;
                for (var i = 0; i < BaseStats.Length; i++)
                {
                    BaseStats[i] = status.GetPropertyValue <byte?>(_numberOfLevelUpPointsApplied[i]) ?? 0;
                }
            }

            if (creature.Location != null)
            {
                Location = new ArkLocation(creature.Location, saveState);
            }
        }
    public void SaveState(ISaveState obj)
    {
        var id    = obj.SaveIdentifier;
        var state = obj.GetState();

        PlayerPrefs.SetString(id, state);
    }
Esempio n. 3
0
        public ArkLocation(LocationData locationData, ISaveState savedState)
        {
            X = locationData.X;
            Y = locationData.Y;
            Z = locationData.Z;

            if (savedState?.MapName != null)
            {
                MapName = savedState.MapName;

                Tuple <float, float, float, float> vals = null;
                if (_latlonCalcs.TryGetValue(savedState.MapName, out vals))
                {
                    Latitude  = vals.Item1 + Y / vals.Item2;
                    Longitude = vals.Item3 + X / vals.Item4;

                    Tuple <int, int, float, float, float, float> mapvals = null;
                    if (_topoMapCalcs.TryGetValue(savedState.MapName, out mapvals))
                    {
                        TopoMapX = (Longitude - mapvals.Item4) * mapvals.Item1 / (mapvals.Item5 - mapvals.Item4);
                        TopoMapY = (Latitude - mapvals.Item3) * mapvals.Item2 / (mapvals.Item6 - mapvals.Item3);
                    }
                }
            }
        }
Esempio n. 4
0
        public ArkCloudInventory(string steamId, IGameObject cloudinv, ISaveState saveState, ICloudInventoryDinoData[] dinoData) : this()
        {
            if (saveState == null)
            {
                throw new ApplicationException("Save state must be set in ArkCloudInventory::ArkCloudInventory");
            }

            _cloudinv = cloudinv;

            SteamId = steamId;
            var mydata     = cloudinv.GetPropertyValue <StructPropertyList>(_myArkData);
            var items      = mydata.GetPropertyValue <ArkArrayStruct>(_arkItems);
            var characters = mydata.GetPropertyValue <ArkArrayStruct>(_arkPlayerData);
            var dinos      = mydata.GetPropertyValue <ArkArrayStruct>(_arkTamedDinosData);

            if (items != null)
            {
                Items = items.OfType <StructPropertyList>().Select(x => new ArkCloudInventoryItem(x)).ToArray();
            }
            if (characters != null)
            {
                Characters = characters.OfType <StructPropertyList>().Select(x => new ArkCloudInventoryCharacter(x)).ToArray();
            }
            if (dinos != null)
            {
                Dinos = dinos.OfType <StructPropertyList>().Select((x, i) => new ArkCloudInventoryDino(x,
                                                                                                       dinoData?.ElementAtOrDefault(i)?.Creature,
                                                                                                       dinoData?.ElementAtOrDefault(i)?.Status,
                                                                                                       dinoData?.ElementAtOrDefault(i)?.Inventory,
                                                                                                       saveState)).ToArray();
            }

            SavedAt = saveState.SaveTime;
        }
Esempio n. 5
0
        public ArkStructureCropPlot(IGameObject structure, ISaveState saveState) : base(structure, saveState)
        {
            FertilizerAmount = structure.GetPropertyValue <float?>(_cropPhaseFertilizerCache);
            WaterAmount      = structure.GetPropertyValue <float>(_waterAmount);

            var plantedCropBlueprintGeneratedClass = structure.GetPropertyValue <ObjectReference>(_plantedCrop)?.ObjectString?.Token;

            PlantedCropClassName = plantedCropBlueprintGeneratedClass?.SubstringAfterLast('.');
        }
    public void LoadState(ISaveState obj, out bool isDefault)
    {
        var id = obj.SaveIdentifier;

        if (PlayerPrefs.HasKey(id))
        {
            obj.LoadState(PlayerPrefs.GetString(id));
            isDefault = false;
            return;
        }

        obj.LoadDefaultState();
        isDefault = true;
    }
Esempio n. 7
0
        public ArkDeathCache(IGameObject deathCache, ISaveState saveState) : this()
        {
            _deathCache = deathCache;

            ClassName      = deathCache.ClassName.Name;
            OwnerName      = deathCache.GetPropertyValue <string>(_ownerName);
            TargetingTeam  = deathCache.GetPropertyValue <int?>(_targetingTeam);
            OwningPlayerId = deathCache.GetPropertyValue <int?>(_owningPlayerID);
            InventoryId    = deathCache.GetPropertyValue <ObjectReference>(_myInventoryComponent)?.ObjectId;

            if (deathCache?.Location != null)
            {
                Location = new ArkLocation(deathCache.Location, saveState);
            }
        }
 private void Awake()
 {
     var other = FindObjectOfType<SaveRestoreBehaviour>();
     if (other != null && other != this) {
         Debug.LogWarning("Second SaveRestoreBehaviour was created. Destroying it. Only one allowed");
         Destroy(this); // not the go. might be something else, important on it.
         return;
     }
     saveStateInstance = Activator.CreateInstance(Type.GetType(saveTypeImpl)) as ISaveState;
     if (saveStateInstance == null) {
         Debug.LogError(saveTypeImpl + " is not a valid ISaveState! Cannot save the game.");
     }
     else {
         EventDispatcher.Instance.Register<RequestSaveEvent>(OnSaveRequest);
         EventDispatcher.Instance.Register<RequestSaveLoadEvent>(OnSavegameLoad);
     }
     DontDestroyOnLoad(this.gameObject);
 }
Esempio n. 9
0
 public static ArkStructure AsStructure(this IGameObject self, ISaveState saveState)
 {
     if (self?.ClassName?.Token != null)
     {
         var className = self.ClassName.Token;
         if (className.Equals("CropPlotSmall_SM_C", StringComparison.Ordinal) ||
             className.Equals("CropPlotMedium_SM_C", StringComparison.Ordinal) ||
             className.Equals("CropPlotLarge_SM_C", StringComparison.Ordinal))
         {
             return(new ArkStructureCropPlot(self, saveState));
         }
         if (className.Equals("ElectricGenerator_C", StringComparison.Ordinal))
         {
             return(new ArkStructureElectricGenerator(self, saveState));
         }
     }
     return(new ArkStructure(self, saveState));
 }
Esempio n. 10
0
        public void LoadPreviousSate(ISaveState saver)
        {
            if (ReferenceEquals(saver, null))
            {
                var ex = new ArgumentNullException($"{nameof(saver)} is null");
                this.logger?.Error(ex, ex.Message);
                throw ex;
            }

            try
            {
                rwLockSlim.EnterReadLock();
                try
                {
                    this.storage = new HashSet <User>(saver.Load(), this.userEqualityComparer);
                }
                finally
                {
                    rwLockSlim.ExitReadLock();
                }

                this.logger?.Info($"Requested {this.storage.Count} users from storage");
            }
            catch (IOException exception)
            {
                var ex = new UserServiceException("Can't load Users", exception);
                this.logger?.Error(ex, ex.Message);
                throw ex;
            }
            catch (InvalidOperationException exception)
            {
                var ex = new UserServiceException("Can't load Users", exception);
                this.logger?.Error(ex, ex.Message);
                throw ex;
            }

            foreach (var user in storage)
            {
                Notify(new Message {
                    Action = Action.Add, User = user.Clone()
                });
            }
        }
Esempio n. 11
0
        ///<summary>
        /// Callback to call when a save operation has finished
        ///</summary>
        void SaveFileAsyncCallback(IAsyncResult ar)
        {
            ISaveState ss = (ISaveState)ar.AsyncState;

            if (ss.Result == ThreadedAsyncOperation.OperationResult.Finished)       // save went ok
            {
                string msg;
                if (ss.SavePath != ss.Buffer.Filename)
                {
                    msg = string.Format(Catalog.GetString("The file has been saved as '{0}'"), ss.SavePath);
                }
                else
                {
                    msg = string.Format(Catalog.GetString("The file '{0}' has been saved"), ss.SavePath);
                }

                Services.UI.Info.DisplayMessage(msg);
                // add to history
                History.Instance.Add(ss.SavePath);

                return;
            }
            else if (ss.Result == ThreadedAsyncOperation.OperationResult.Cancelled)       // save cancelled

            {
            }
            else if (ss.Result == ThreadedAsyncOperation.OperationResult.CaughtException)
            {
                // * UnauthorizedAccessException
                // * System.ArgumentException
                // * System.IO.IOException
                string     msg = string.Format(Catalog.GetString("Error saving file '{0}'"), ss.SavePath);
                ErrorAlert ea  = new ErrorAlert(msg, ss.ThreadException.Message, mainWindow);
                ea.Run();
                ea.Destroy();
            }

            {
                string msg = string.Format(Catalog.GetString("The file '{0}' has NOT been saved"), ss.SavePath);
                Services.UI.Info.DisplayMessage(msg);
            }
        }
        public ArkStructure(IGameObject structure, ISaveState saveState) : this()
        {
            _structure = structure;

            ClassName = structure.ClassName.Name;
            //Id = structure.Index;
            //Uuid = _structure.Uuid;
            OwnerName         = structure.GetPropertyValue <string>(_ownerName);
            TargetingTeam     = structure.GetPropertyValue <int?>(_targetingTeam);
            OwningPlayerId    = structure.GetPropertyValue <int?>(_owningPlayerID);
            OwningPlayerName  = structure.GetPropertyValue <string>(_owningPlayerName);
            InventoryId       = structure.GetPropertyValue <ObjectReference>(_myInventoryComponent)?.ObjectId;
            BoxName           = structure.GetPropertyValue <string>(_boxName);
            AttachedToDinoId1 = structure.GetPropertyValue <uint?>(_attachedToDinoId1);

            if (structure?.Location != null)
            {
                Location = new ArkLocation(structure.Location, saveState);
            }
        }
Esempio n. 13
0
        public void SaveCurrentState(ISaveState saver)
        {
            if (ReferenceEquals(saver, null))
            {
                var ex = new ArgumentNullException($"{nameof(saver)} is null");
                this.logger?.Error(ex, ex.Message);
                throw ex;
            }

            try
            {
                rwLockSlim.EnterReadLock();
                try
                {
                    saver.Save(this.storage);
                }
                finally
                {
                    rwLockSlim.ExitReadLock();
                }

                this.logger?.Info($"Saved {this.storage.Count} users");
            }
            catch (IOException exception)
            {
                var ex = new UserServiceException("Can't save Users", exception);
                this.logger?.Error(ex, ex.Message);
                throw ex;
            }
            catch (InvalidOperationException exception)
            {
                var ex = new UserServiceException("Can't save Users", exception);
                this.logger?.Error(ex, ex.Message);
                throw ex;
            }
        }
Esempio n. 14
0
 public static ArkCloudInventory AsCloudInventory(this IGameObject self, string steamId, ISaveState saveState, ICloudInventoryDinoData[] dinoData)
 {
     return(new ArkCloudInventory(steamId, self, saveState, dinoData));
 }
Esempio n. 15
0
 public static ArkPlayer AsPlayer(this IGameObject self, IGameObject player, DateTime profileSaveTime, ISaveState saveState)
 {
     return(new ArkPlayer(self, player, profileSaveTime, saveState));
 }
Esempio n. 16
0
 public static ArkItem AsItem(this IGameObject self, ISaveState saveState)
 {
     return(new ArkItem(self, saveState));
 }
Esempio n. 17
0
 public ArkWildCreature(IGameObject creature, IGameObject status, ISaveState savedState) : base(creature, status, savedState)
 {
     IsTameable = !(creature.GetPropertyValue <bool?>(_bForceDisablingTaming) ?? false);
 }
Esempio n. 18
0
 public static ArkWildCreature AsWildCreature(this IGameObject self, IGameObject status, ISaveState saveState)
 {
     return(new ArkWildCreature(self, status, saveState));
 }
Esempio n. 19
0
 public ArkStructureElectricGenerator(IGameObject structure, ISaveState saveState) : base(structure, saveState)
 {
     FuelTime  = structure.GetPropertyValue <double?>(_currentFuelTimeCache);
     Activated = structure.GetPropertyValue <bool?>(_bContainerActivated) ?? false;
 }
Esempio n. 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="profile">.arkprofile->PrimalPlayerData</param>
        /// <param name="player">savegame->PlayerPawnTest_Female/Male_C</param>
        public ArkPlayer(IGameObject profile, IGameObject player, DateTime profileSaveTime, ISaveState saveState) : this()
        {
            _profile = profile;
            _player  = player;

            var mydata = profile.GetPropertyValue <StructPropertyList>(_myData);
            var myPlayerCharacterConfig    = mydata.GetPropertyValue <StructPropertyList>(_myPlayerCharacterConfig);
            var myPersistentCharacterStats = mydata.GetPropertyValue <StructPropertyList>(_myPersistentCharacterStats);

            Id                  = (int)mydata.GetPropertyValue <ulong>(_playerDataID);
            SteamId             = mydata.GetPropertyValue <StructUniqueNetIdRepl>(_uniqueID)?.NetId;
            TribeId             = mydata.GetPropertyValue <int?>(_tribeID);
            Name                = mydata.GetPropertyValue <string>(_playerName);
            SavedNetworkAddress = mydata.GetPropertyValue <string>(_savedNetworkAddress);
            CharacterName       = myPlayerCharacterConfig.GetPropertyValue <string>(_playerCharacterName);
            Gender              = myPlayerCharacterConfig.GetPropertyValue <bool?>(_bIsFemale) == true ? ArkPlayerGender.Female : ArkPlayerGender.Male;
            TotalEngramPoints   = myPersistentCharacterStats.GetPropertyValue <int>(_playerState_TotalEngramPoints);
            ExperiencePoints    = myPersistentCharacterStats.GetPropertyValue <float>(_characterStatusComponent_ExperiencePoints);
            CharacterLevel      = (short)(myPersistentCharacterStats.GetPropertyValue <short>(_characterStatusComponent_ExtraCharacterLevel) + 1);
            for (var i = 0; i < Stats.Length; i++)
            {
                Stats[i] = myPersistentCharacterStats.GetPropertyValue <sbyte?>(_characterStatusComponent_NumberOfLevelUpPointsApplied[i]) ?? 0;
            }
            InventoryId = player?.GetPropertyValue <ObjectReference>(_myInventoryComponent)?.ObjectId;

            if (player?.Location != null)
            {
                Location = new ArkLocation(player.Location, saveState);
            }

            SavedAt = profileSaveTime;
        }
Esempio n. 21
0
        public static ArkDroppedItem AsDroppedItem(this IGameObject self, IGameObject linkedItem, ISaveState saveState)
        {
            ArkDroppedItem droppedItem = new ArkDroppedItem(self, linkedItem, saveState);

            return(droppedItem);
        }
Esempio n. 22
0
        public static ArkDeathCache AsDeathCache(this IGameObject self, ISaveState saveState)
        {
            ArkDeathCache deathCache = new ArkDeathCache(self, saveState);

            return(deathCache);
        }
Esempio n. 23
0
        public ArkDroppedItem(IGameObject droppedItem, IGameObject item, ISaveState saveState)
        {
            _droppedItem = droppedItem;
            _item        = item;
            _saveState   = saveState;


            //load dropped item properties
            DroppedByName     = droppedItem.GetPropertyValue <string>(_dropedByName);
            DroppedByPlayerId = droppedItem.GetPropertyValue <int>(_droppedByPlayerId);
            TargetingTeam     = droppedItem.GetPropertyValue <int>(_targetingTeam);

            Location = new ArkLocation(droppedItem.Location, saveState);

            //Id = item.Index;
            ClassName = item.ClassName.Name;
            var itemId = item.GetPropertyValue <StructPropertyList>(_itemId);

            //load item properties
            if (itemId != null)
            {
                Id1 = itemId.GetPropertyValue <uint>(_itemId1);
                Id2 = itemId.GetPropertyValue <uint>(_itemId2);
            }
            OwnerInventoryId         = item.GetPropertyValue <ObjectReference>(_ownerInventory)?.ObjectId;
            Quantity                 = item.GetPropertyValue <uint?>(_itemQuantity) ?? 1;
            IsBlueprint              = item.GetPropertyValue <bool?>(_bIsBlueprint) ?? false;
            IsEngram                 = item.GetPropertyValue <bool?>(_bIsEngram) ?? false;
            HideFromInventoryDisplay = item.GetPropertyValue <bool?>(_bHideFromInventoryDisplay) ?? false;
            CustomDescription        = item.GetPropertyValue <string>(_customItemDescription);
            CustomName               = item.GetPropertyValue <string>(_customItemName);
            Rating          = item.GetPropertyValue <float?>(_itemRating);
            SavedDurability = item.GetPropertyValue <float?>(_savedDurability);
            QualityIndex    = item.GetPropertyValue <sbyte?>(_itemQualityIndex);
            CreationTime    = item.GetPropertyValue <double?>(_creationTime);
            {
                var statValues = new short?[_itemStatValues.Length];
                var found      = 0;
                for (var i = 0; i < statValues.Length; i++)
                {
                    var statValue = item.GetPropertyValue <short?>(_itemStatValues[i]);
                    if (statValue == null)
                    {
                        continue;
                    }

                    found++;
                    statValues[i] = statValue.Value;
                }
                if (found > 0)
                {
                    StatValues = statValues;
                }
            }

            EggDinoAncestors     = ArkTamedCreatureAncestor.FromPropertyValue(item.GetPropertyValue <ArkArrayStruct>(_eggDinoAncestors));
            EggDinoAncestorsMale = ArkTamedCreatureAncestor.FromPropertyValue(item.GetPropertyValue <ArkArrayStruct>(_eggDinoAncestorsMale));

            {
                var colors = new sbyte[_eggColorSetIndices.Length];
                var found  = 0;
                for (var i = 0; i < colors.Length; i++)
                {
                    var color = item.GetPropertyValue <sbyte?>(_eggColorSetIndices[i]);
                    if (color == null)
                    {
                        continue;
                    }

                    found++;
                    colors[i] = color.Value;
                }
                if (found > 0)
                {
                    EggColors = colors;
                }
            }
            {
                var basestats = new sbyte[_eggNumberOfLevelUpPointsApplied.Length];
                var found     = 0;
                for (var i = 0; i < basestats.Length; i++)
                {
                    var basestat = item.GetPropertyValue <sbyte?>(_eggNumberOfLevelUpPointsApplied[i]);
                    if (basestat == null)
                    {
                        continue;
                    }

                    found++;
                    basestats[i] = basestat.Value;
                }
                if (found > 0)
                {
                    EggBaseStats = basestats;
                }
            }
            EggRandomMutationsMale   = item.GetPropertyValue <int?>(_eggRandomMutationsMale);
            EggRandomMutationsFemale = item.GetPropertyValue <int?>(_eggRandomMutationsFemale);
        }
Esempio n. 24
0
 /// <summary>
 /// Get the approximate date and time when an event in-game will occur
 /// </summary>
 public static DateTime?GetApproxDateTimeOf(this ISaveState self, double?gametime)
 {
     return(gametime.HasValue && self.SaveTime != DateTime.MinValue && self?.GameTime > 0 ? self.SaveTime.AddSeconds(gametime.Value - self.GameTime.Value) : (DateTime?)null);
 }
Esempio n. 25
0
        public ArkItem(IGameObject item, ISaveState saveState) : this()
        {
            _item      = item;
            _saveState = saveState;

            //Id = item.Index;
            ClassName = item.ClassName.Name;
            var itemId = item.GetPropertyValue <StructPropertyList>(_itemId);

            //todo: Scorched Earth store buff data as items that have no id. There may be other cases.
            //Do we want missing item ids to be set to 0 or do we need to change the Id-properties to be nullable?

            if (itemId != null)
            {
                Id1 = itemId.GetPropertyValue <uint>(_itemId1);
                Id2 = itemId.GetPropertyValue <uint>(_itemId2);
            }
            OwnerInventoryId = item.GetPropertyValue <ObjectReference>(_ownerInventory)?.ObjectId;
            //OwnerContainerId
            Quantity    = item.GetPropertyValue <uint?>(_itemQuantity) ?? 1;
            IsBlueprint = item.GetPropertyValue <bool?>(_bIsBlueprint) ?? false;
            IsEngram    = item.GetPropertyValue <bool?>(_bIsEngram) ?? false;
            HideFromInventoryDisplay = item.GetPropertyValue <bool?>(_bHideFromInventoryDisplay) ?? false;
            CustomDescription        = item.GetPropertyValue <string>(_customItemDescription);
            CustomName      = item.GetPropertyValue <string>(_customItemName);
            Rating          = item.GetPropertyValue <float?>(_itemRating);
            SavedDurability = item.GetPropertyValue <float?>(_savedDurability);
            QualityIndex    = item.GetPropertyValue <sbyte?>(_itemQualityIndex);
            CreationTime    = item.GetPropertyValue <double?>(_creationTime);
            {
                var statValues = new short?[_itemStatValues.Length];
                var found      = 0;
                for (var i = 0; i < statValues.Length; i++)
                {
                    var statValue = item.GetPropertyValue <short?>(_itemStatValues[i]);
                    if (statValue == null)
                    {
                        continue;
                    }

                    found++;
                    statValues[i] = statValue.Value;
                }
                if (found > 0)
                {
                    StatValues = statValues;
                }
            }

            EggDinoAncestors     = ArkTamedCreatureAncestor.FromPropertyValue(item.GetPropertyValue <ArkArrayStruct>(_eggDinoAncestors));
            EggDinoAncestorsMale = ArkTamedCreatureAncestor.FromPropertyValue(item.GetPropertyValue <ArkArrayStruct>(_eggDinoAncestorsMale));

            {
                var colors = new sbyte[_eggColorSetIndices.Length];
                var found  = 0;
                for (var i = 0; i < colors.Length; i++)
                {
                    var color = item.GetPropertyValue <sbyte?>(_eggColorSetIndices[i]);
                    if (color == null)
                    {
                        continue;
                    }

                    found++;
                    colors[i] = color.Value;
                }
                if (found > 0)
                {
                    EggColors = colors;
                }
            }
            {
                var basestats = new sbyte[_eggNumberOfLevelUpPointsApplied.Length];
                var found     = 0;
                for (var i = 0; i < basestats.Length; i++)
                {
                    var basestat = item.GetPropertyValue <sbyte?>(_eggNumberOfLevelUpPointsApplied[i]);
                    if (basestat == null)
                    {
                        continue;
                    }

                    found++;
                    basestats[i] = basestat.Value;
                }
                if (found > 0)
                {
                    EggBaseStats = basestats;
                }
            }
            EggRandomMutationsMale   = item.GetPropertyValue <int?>(_eggRandomMutationsMale);
            EggRandomMutationsFemale = item.GetPropertyValue <int?>(_eggRandomMutationsFemale);

            //todo: LocationData should be replaced since drop-locations do not have pitch, roll and yaw
            var dropLocation = item.GetPropertyValue <StructVector>(_originalItemDropLocation);

            if (dropLocation != null)
            {
                Location = new ArkLocation(new LocationData {
                    X = dropLocation.X, Y = dropLocation.Y, Z = dropLocation.Z
                }, saveState);
            }
        }
Esempio n. 26
0
        public ArkTamedCreature(IGameObject creature, IGameObject status, ISaveState saveState) : base(creature, status, saveState)
        {
            Construct();

            _saveState = saveState;

            OwningPlayerId             = creature.GetPropertyValue <int?>(_owningPlayerID);
            OwningPlayerName           = creature.GetPropertyValue <string>(_owningPlayerName);
            Name                       = creature.GetPropertyValue <string>(_tamedName);
            TamedOnServerName          = creature.GetPropertyValue <string>(_tamedOnServerName);
            TamerName                  = creature.GetPropertyValue <string>(_tamerString);
            TargetingTeam              = creature.GetPropertyValue <int>(_targetingTeam);
            TribeName                  = creature.GetPropertyValue <string>(_tribeName);
            RandomMutationsMale        = creature.GetPropertyValue <int?>(_randomMutationsMale) ?? 0;
            RandomMutationsFemale      = creature.GetPropertyValue <int?>(_randomMutationsFemale) ?? 0;
            TamedAtTime                = creature.GetPropertyValue <double?>(_tamedAtTime);
            LastUpdatedGestationAtTime = creature.GetPropertyValue <double?>(_lastUpdatedGestationAtTime);
            LastUpdatedMatingAtTime    = creature.GetPropertyValue <double?>(_lastUpdatedMatingAtTime);

            BabyGestationProgress = creature.GetPropertyValue <float?>(_babyGestationProgress);
            BabyNextCuddleTime    = creature.GetPropertyValue <double?>(_babyNextCuddleTime);
            IsNeutered            = creature.GetPropertyValue <bool?>(_bNeutered) ?? false;
            DinoAncestors         = ArkTamedCreatureAncestor.FromPropertyValue(creature.GetPropertyValue <ArkArrayStruct>(_dinoAncestors));
            DinoAncestorsMale     = ArkTamedCreatureAncestor.FromPropertyValue(creature.GetPropertyValue <ArkArrayStruct>(_dinoAncestorsMale));

            {
                var colors = new sbyte[_gestationEggColorSetIndices.Length];
                var found  = 0;
                for (var i = 0; i < colors.Length; i++)
                {
                    var color = creature.GetPropertyValue <sbyte?>(_gestationEggColorSetIndices[i]);
                    if (color == null)
                    {
                        continue;
                    }

                    found++;
                    colors[i] = color.Value;
                }
                if (found > 0)
                {
                    GestationEggColors = colors;
                }
            }
            {
                var basestats = new sbyte[_gestationEggNumberOfLevelUpPointsApplied.Length];
                var found     = 0;
                for (var i = 0; i < basestats.Length; i++)
                {
                    var basestat = creature.GetPropertyValue <sbyte?>(_gestationEggNumberOfLevelUpPointsApplied[i]);
                    if (basestat == null)
                    {
                        continue;
                    }

                    found++;
                    basestats[i] = basestat.Value;
                }
                if (found > 0)
                {
                    GestationEggBaseStats = basestats;
                }
            }
            GestationEggRandomMutationsMale   = creature.GetPropertyValue <int?>(_gestationEggRandomMutationsMale);
            GestationEggRandomMutationsFemale = creature.GetPropertyValue <int?>(_gestationEggRandomMutationsFemale);
            ImprinterName             = creature.GetPropertyValue <string>(_imprinterName);
            ImprinterPlayerDataId     = creature.GetPropertyValue <long?>(_imprinterPlayerDataID);
            NextAllowedMatingTime     = creature.GetPropertyValue <double?>(_nextAllowedMatingTime);
            NextBabyDinoAncestors     = ArkTamedCreatureAncestor.FromPropertyValue(creature.GetPropertyValue <ArkArrayStruct>(_nextBabyDinoAncestors));
            NextBabyDinoAncestorsMale = ArkTamedCreatureAncestor.FromPropertyValue(creature.GetPropertyValue <ArkArrayStruct>(_nextBabyDinoAncestorsMale));
            InventoryId = creature.GetPropertyValue <ObjectReference>(_myInventoryComponent)?.ObjectId;

            TamedStats = new sbyte[_numberOfLevelUpPointsAppliedTamed.Length];
            if (status != null)
            {
                for (var i = 0; i < TamedStats.Length; i++)
                {
                    TamedStats[i] = status.GetPropertyValue <sbyte?>(_numberOfLevelUpPointsAppliedTamed[i]) ?? 0;
                }
                DinoImprintingQuality        = status.GetPropertyValue <float?>(_dinoImprintingQuality);
                ExperiencePoints             = status.GetPropertyValue <float?>(_experiencePoints);
                ExtraCharacterLevel          = status.GetPropertyValue <short?>(_extraCharacterLevel) ?? 0;
                TamedIneffectivenessModifier = status.GetPropertyValue <float?>(_tamedIneffectivenessModifier);
                CurrentStatusValues          = new float?[_currentStatusValues.Length];
                for (var i = 0; i < CurrentStatusValues.Length; i++)
                {
                    CurrentStatusValues[i] = status.GetPropertyValue <float?>(_currentStatusValues[i]);
                }
            }
        }
Esempio n. 27
0
        private Sprite DeserializeModel(string objKey, ISaveState objSave)
        {
            // Add base sprite models here, (AnimatedSprite namespace, not Model namespace)
            Sprite         sp = null;
            OnGroundState  ogs;
            ShipState      ss;
            NpcState       npcs;
            StructureState sts;

            switch (objKey)
            {
            // TODO: Should I save fired ammo state?

            case "baseShip":
                ss = (ShipState)objSave;
                BaseShip bs = new BaseShip(ss.team, ss.region, ss.location, _content, _graphics);
                bs.health          = ss.health;
                bs.actionInventory = DeserializeInventory(ss.actionInventory);
                //bs.shipInterior = DeserializeInterior(ss.interiorState); we do this after models are created
                bs.playerAboard = ss.playerAboard;
                bs.SetInteriorForId(ss.shipId);
                if (bs.playerAboard)
                {
                    bs.shipSail.playerAboard = true;
                }
                return(bs);

            case "baseTribal":
                npcs = (NpcState)objSave;
                BaseTribal bt = new BaseTribal(npcs.team, npcs.region, npcs.location, _content, _graphics);
                bt.health    = npcs.health;
                bt.inventory = DeserializeInventory(npcs.inventory);
                return(bt);

            case "baseCat":
                npcs = (NpcState)objSave;
                BaseCat bct = new BaseCat(npcs.team, npcs.region, npcs.location, _content, _graphics);
                bct.health    = npcs.health;
                bct.inventory = DeserializeInventory(npcs.inventory);
                return(bct);

            case "chicken":
                npcs = (NpcState)objSave;
                Chicken chk = new Chicken(npcs.team, npcs.region, npcs.location, _content, _graphics);
                chk.health    = npcs.health;
                chk.inventory = DeserializeInventory(npcs.inventory);
                return(chk);

            case "blueBird":
                npcs = (NpcState)objSave;
                BlueBird bbr = new BlueBird(npcs.team, npcs.region, npcs.location, _content, _graphics);
                bbr.health    = npcs.health;
                bbr.inventory = DeserializeInventory(npcs.inventory);
                return(bbr);

            case "snake":
                npcs = (NpcState)objSave;
                Snake snk = new Snake(npcs.team, npcs.region, npcs.location, _content, _graphics);
                snk.health    = npcs.health;
                snk.inventory = DeserializeInventory(npcs.inventory);
                return(snk);

            case "teePee":
                sts = (StructureState)objSave;
                TeePee tp = new TeePee(sts.team, sts.region, sts.location, _content, _graphics);
                return(tp);

            case "baseBarrel":
                ogs = (OnGroundState)objSave;
                BaseBarrel bb = new BaseBarrel(ogs.team, ogs.region, ogs.location, _content, _graphics);
                bb.drops = DeserializeInventory(ogs.inventory);
                return(bb);

            case "baseChest":
                ogs = (OnGroundState)objSave;
                BaseChest bc = new BaseChest(ogs.team, ogs.region, ogs.location, _content, _graphics);
                bc.inventory = DeserializeInventory(ogs.inventory);
                return(bc);

            case "clayFurnace":
                ogs = (OnGroundState)objSave;
                ClayFurnace cf = new ClayFurnace(ogs.team, ogs.region, ogs.location, _content, _graphics);
                return(cf);

            case "campFire":
                ogs = (OnGroundState)objSave;
                CampFire caf = new CampFire(ogs.team, ogs.region, ogs.location, _content, _graphics);
                return(caf);

            case "craftingAnvil":
                ogs = (OnGroundState)objSave;
                CraftingAnvil ca = new CraftingAnvil(ogs.team, ogs.region, ogs.location, _content, _graphics);
                return(ca);
            }
            return(sp);
        }
Esempio n. 28
0
        /// <summary>
        /// Get the approximate time span since an event in-game.
        /// </summary>
        public static TimeSpan?GetApproxTimeElapsedSince(this ISaveState self, double?gametime)
        {
            var dss = GetApproxTimeSpanSinceSave(self);

            return(gametime.HasValue && dss.HasValue && self?.GameTime > 0 ? TimeSpan.FromSeconds(self.GameTime.Value - gametime.Value) + dss.Value : (TimeSpan?)null);
        }
Esempio n. 29
0
 public void LoadState(ISaveState obj)
 {
     LoadState(obj, out _);
 }
        public ArkCloudInventoryDino(IPropertyContainer dino, IGameObject creature, IGameObject status, IGameObject inventory, ISaveState saveState) : base(creature, status, saveState)
        {
            _dino = dino;

            //Id1 = dino.GetPropertyValue<uint>(_dinoId1);
            //Id2 = dino.GetPropertyValue<uint>(_dinoId2);
            //CloudName = dino.GetPropertyValue<string>(_dinoName);
            //if (CloudName != null)
            //{
            //    var m = _r_nameLevelSpecies.Match(CloudName);
            //    if (m.Success)
            //    {
            //        Name = m.Groups["name"].Value;
            //        Level = int.Parse(m.Groups["level"].Value);
            //        Species = m.Groups["species"].Value;
            //    }
            //}
            //ExperiencePoints = dino.GetPropertyValue<float?>(_dinoExperiencePoints);
            //CloudClassName = dino.GetPropertyValue<ObjectReference>(_dinoClass)?.ObjectString?.Name;
            //if (CloudClassName != null)
            //{
            //    var index = CloudClassName.LastIndexOf('.');
            //    if (index != -1 && index < CloudClassName.Length - 1)
            //    {
            //        ClassName = CloudClassName.Substring(index + 1);
            //    }
            //}
            //for (var i = 0; i < Stats.Length; i++) Stats[i] = dino.GetPropertyValue<string>(_dinoStats[i]);
        }
Esempio n. 31
0
 private static TimeSpan?GetApproxTimeSpanSinceSave(this ISaveState self)
 {
     return(self?.SaveTime != DateTime.MinValue ? DateTime.UtcNow - self.SaveTime : (TimeSpan?)null);
 }