コード例 #1
0
        /// <summary>
        /// Removes the world object based on the given key.
        /// </summary>
        /// <param name="Key">The key value of the object to remove.</param>
        /// <returns>Whether or not that object was succesfull removed.</returns>
        public virtual bool RemoveWorldObject(Type Type, int X, int Y)
        {
            GridWorldObject <SS, DS> GWO =
                this.WorldObjects.First(x => x.X == X && x.Y == Y &&
                                        x.GetType( ).Equals(Type));

            this.hash ^= GWO.GetHashCode( );
            return(this.WorldObjects.Remove(GWO));
        }
コード例 #2
0
 /// <summary>
 /// A method for comparision of two grid world objects.
 /// </summary>
 /// <param name="obj">The object to compare against.</param>
 /// <returns>Whether the two object have equality.</returns>
 public override bool Equals(object obj)
 {
     if (this.GetHashCode( ) == obj.GetHashCode( ) &&
         obj is GridWorldObject <SS, DS> )
     {
         GridWorldObject <SS, DS> o = obj as GridWorldObject <SS, DS>;
         return(this.UID == o.UID && o.X == this.X && o.Y == this.Y &&
                this.GetType( ).Equals(o.GetType( )));
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
 /// <summary>
 /// Adds the given world object to the world.
 /// </summary>
 /// <param name="GWO">The object to add.</param>
 public virtual void AddWorldObject(GridWorldObject <SS, DS> GWO)
 {
     this.hash ^= GWO.GetHashCode( );
     this.WorldObjects.Add(GWO);
 }