コード例 #1
0
        /// <summary>
        /// Determines, if this creature can be uniquely identified by Granger, when compared to other creature.
        /// </summary>
        /// <remarks>
        /// Wurm does not provide any unique ID of a creature.
        /// </remarks>
        public bool IsUniquelyIdentifiableWhenComparedTo(CreatureEntity otherCreature)
        {
            var hasSameName = this.Name == otherCreature.Name;

            if (hasSameName)
            {
                // if names are equal, might still be able to differentiate by server names
                if (string.IsNullOrWhiteSpace(this.ServerName) || string.IsNullOrWhiteSpace(otherCreature.ServerName))
                {
                    // if server is unknown for one or both of these creatures, creatures are not uniquely identifiable
                    return(false);
                }
                else
                {
                    // if both servers known and different, creatures can be differentiated when originating from different servers
                    return(!string.Equals(this.ServerName,
                                          otherCreature.ServerName,
                                          StringComparison.InvariantCultureIgnoreCase));
                }
            }
            else
            {
                // if names are different, creatures are uniquely identifiable
                return(true);
            }
        }
コード例 #2
0
 public void InsertCreature(CreatureEntity creature)
 {
     grangerSimpleDb.Creatures[creature.Id] = creature;
     grangerSimpleDb.Save();
     OnCreaturesModified?.Invoke(this, new EventArgs());
 }