mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 00:06:02 +00:00
更新RoomList,更新Entity类,更新Factory (#12)
This commit is contained in:
parent
c9a7ea88b2
commit
f2107ba530
@ -136,11 +136,13 @@ namespace Milimoe.FunGame.Core.Api.Utility
|
||||
{
|
||||
DataSet? DsRoom = DataSets[0];
|
||||
DataSet? DsUser = DataSets[1];
|
||||
object entity = General.HallInstance;
|
||||
list.Add((T)entity);
|
||||
if (DsRoom != null && DsRoom.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < DsRoom.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
object entity = GetRoom(DsRoom, DsUser, i);
|
||||
entity = GetRoom(DsRoom, DsUser, i);
|
||||
list.Add((T)entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,11 +10,5 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
public virtual string Name { get; set; } = "";
|
||||
|
||||
public abstract bool Equals(IBaseEntity? other);
|
||||
public abstract IEnumerator<IBaseEntity> GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,10 +10,5 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
public bool Active { get; set; }
|
||||
public bool Enable { get; set; }
|
||||
public Character? Character { get; set; } = null;
|
||||
|
||||
public override IEnumerator<IBaseEntity> GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,11 +50,6 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
return other.Id == Id;
|
||||
}
|
||||
|
||||
public override IEnumerator<Room> GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public override bool Equals(IBaseEntity? other)
|
||||
{
|
||||
return Equals(other);
|
||||
|
||||
@ -56,10 +56,5 @@ namespace Milimoe.FunGame.Core.Entity
|
||||
if (((User)other).Id == Id) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override IEnumerator<IBaseEntity> GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Milimoe.FunGame.Core.Interface.Entity
|
||||
{
|
||||
public interface IBaseEntity : IEquatable<IBaseEntity>, IEnumerable<IBaseEntity>
|
||||
public interface IBaseEntity : IEquatable<IBaseEntity>
|
||||
{
|
||||
public long Id { get; }
|
||||
public Guid Guid { get; }
|
||||
|
||||
@ -1,30 +1,26 @@
|
||||
using System.Collections;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Common.Network;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
{
|
||||
public class RoomList
|
||||
public class RoomList : IEnumerable
|
||||
{
|
||||
public ServerSocket Server => _Server;
|
||||
public int Count => _List.Count;
|
||||
|
||||
private readonly ServerSocket _Server;
|
||||
private readonly Hashtable _List = new();
|
||||
|
||||
public RoomList(ServerSocket Server)
|
||||
public int Count => _List.Count;
|
||||
|
||||
public List<Room> ListRoom => _List.Values.Cast<Room>().ToList();
|
||||
|
||||
public List<string> ListRoomID => _List.Keys.Cast<string>().ToList();
|
||||
|
||||
public RoomList()
|
||||
{
|
||||
_Server = Server;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Room? this[string RoomID] => GetRoom(RoomID);
|
||||
|
||||
public Hashtable GetHashTable => _List;
|
||||
|
||||
public List<Room> GetRoomList => _List.Values.Cast<Room>().ToList();
|
||||
|
||||
public List<string> GetRoomIDList => _List.Keys.Cast<string>().ToList();
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_List.Clear();
|
||||
@ -57,5 +53,30 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||
}
|
||||
return room;
|
||||
}
|
||||
|
||||
public bool IsExist(string RoomID)
|
||||
{
|
||||
return _List.ContainsKey(RoomID);
|
||||
}
|
||||
|
||||
public User GetRoomMaster(string RoomID)
|
||||
{
|
||||
foreach (Room room in ListRoom)
|
||||
{
|
||||
if (room.Roomid == RoomID && room.RoomMaster != null)
|
||||
{
|
||||
return room.RoomMaster;
|
||||
}
|
||||
}
|
||||
return General.UnknownUserInstance;
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
foreach(Room room in ListRoom)
|
||||
{
|
||||
yield return room;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
||||
{
|
||||
// Static Variable
|
||||
public static Empty EntityInstance { get; } = new();
|
||||
public static User UnknownUserInstance { get; } = new();
|
||||
public static Room HallInstance { get; } = Api.Utility.Factory.GetHall();
|
||||
public static Encoding DefaultEncoding { get; } = Encoding.Unicode;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user