This commit is contained in:
2022-10-16 18:00:32 +04:00
parent 1558b5eefb
commit 5519ae7679
4 changed files with 9 additions and 7 deletions
+2 -3
View File
@@ -15,13 +15,12 @@ public class Entity
public ushort StaticId { get; private set; } public ushort StaticId { get; private set; }
public ushort EntityType { get; private set; } public ushort EntityType { get; private set; }
public ushort OwnerId { get; private set; } public ushort OwnerId { get; private set; }
public byte[] Payload { get; private set; }
public RagonAuthority Authority { get; private set; } public RagonAuthority Authority { get; private set; }
private List<EntityProperty> _properties; private List<EntityProperty> _properties;
private List<EntityEvent> _bufferedEvents; private List<EntityEvent> _bufferedEvents;
public byte[] Payload { get; set; }
public Entity(GameRoom room, ushort ownerId, ushort entityType, ushort staticId, RagonAuthority eventAuthority) public Entity(GameRoom room, ushort ownerId, ushort entityType, ushort staticId, RagonAuthority eventAuthority)
{ {
OwnerId = ownerId; OwnerId = ownerId;
@@ -50,7 +49,7 @@ public class Entity
{ {
_properties.Add(property); _properties.Add(property);
} }
public void ReplicateEvent(ushort peerId, ushort eventId, ReadOnlySpan<byte> payload, RagonReplicationMode eventMode, RagonTarget targetMode) public void ReplicateEvent(ushort peerId, ushort eventId, ReadOnlySpan<byte> payload, RagonReplicationMode eventMode, RagonTarget targetMode)
{ {
if (Authority == RagonAuthority.OwnerOnly && OwnerId != peerId) if (Authority == RagonAuthority.OwnerOnly && OwnerId != peerId)
+3 -2
View File
@@ -36,7 +36,9 @@ namespace Ragon.Core
private List<ushort> _peersCache = new List<ushort>(); private List<ushort> _peersCache = new List<ushort>();
private List<ushort> _awaitingPeers = new List<ushort>(); private List<ushort> _awaitingPeers = new List<ushort>();
public Player GetPlayerById(ushort peerId) => _players[peerId]; public Player GetPlayerByPeer(ushort peerId) => _players[peerId];
public Player GetPlayerById(string id) => _players.Values.FirstOrDefault(p => p.Id == id)!;
public Entity GetEntityById(int entityId) => _entities[entityId]; public Entity GetEntityById(int entityId) => _entities[entityId];
@@ -280,7 +282,6 @@ namespace Ragon.Core
public void Tick(float deltaTime) public void Tick(float deltaTime)
{ {
_scheduler.Tick(deltaTime); _scheduler.Tick(deltaTime);
SendChanges(); SendChanges();
} }
+2
View File
@@ -8,5 +8,7 @@ public interface IGameRoom
public int PlayersMax { get; } public int PlayersMax { get; }
public int PlayersCount { get; } public int PlayersCount { get; }
public Player GetPlayerById(string id);
public Player GetPlayerByPeer(ushort peerId);
public Entity GetEntityById(int entityId); public Entity GetEntityById(int entityId);
} }
+2 -2
View File
@@ -183,12 +183,12 @@ namespace Ragon.Core
{ {
} }
public virtual bool OnEntityCreated(Player creator, Entity entity) public virtual bool OnEntityCreated(Player player, Entity entity)
{ {
return false; return false;
} }
public virtual bool OnEntityDestroyed(Player destoyer, Entity entity) public virtual bool OnEntityDestroyed(Player player, Entity entity)
{ {
return false; return false;
} }