From 5519ae7679261de5d3db48682c38afed8bded514 Mon Sep 17 00:00:00 2001 From: Edmand46 Date: Sun, 16 Oct 2022 18:00:32 +0400 Subject: [PATCH] wip --- Ragon/Sources/Entity/Entity.cs | 5 ++--- Ragon/Sources/Game/GameRoom.cs | 5 +++-- Ragon/Sources/Game/IGameRoom.cs | 2 ++ Ragon/Sources/Plugin/PluginBase.cs | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Ragon/Sources/Entity/Entity.cs b/Ragon/Sources/Entity/Entity.cs index 2494867..635a0ee 100644 --- a/Ragon/Sources/Entity/Entity.cs +++ b/Ragon/Sources/Entity/Entity.cs @@ -15,13 +15,12 @@ public class Entity public ushort StaticId { get; private set; } public ushort EntityType { get; private set; } public ushort OwnerId { get; private set; } + public byte[] Payload { get; private set; } public RagonAuthority Authority { get; private set; } private List _properties; private List _bufferedEvents; - public byte[] Payload { get; set; } - public Entity(GameRoom room, ushort ownerId, ushort entityType, ushort staticId, RagonAuthority eventAuthority) { OwnerId = ownerId; @@ -50,7 +49,7 @@ public class Entity { _properties.Add(property); } - + public void ReplicateEvent(ushort peerId, ushort eventId, ReadOnlySpan payload, RagonReplicationMode eventMode, RagonTarget targetMode) { if (Authority == RagonAuthority.OwnerOnly && OwnerId != peerId) diff --git a/Ragon/Sources/Game/GameRoom.cs b/Ragon/Sources/Game/GameRoom.cs index d642bca..d0269ff 100755 --- a/Ragon/Sources/Game/GameRoom.cs +++ b/Ragon/Sources/Game/GameRoom.cs @@ -36,7 +36,9 @@ namespace Ragon.Core private List _peersCache = new List(); private List _awaitingPeers = new List(); - 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]; @@ -280,7 +282,6 @@ namespace Ragon.Core public void Tick(float deltaTime) { _scheduler.Tick(deltaTime); - SendChanges(); } diff --git a/Ragon/Sources/Game/IGameRoom.cs b/Ragon/Sources/Game/IGameRoom.cs index f7ee3cf..0d7d3da 100644 --- a/Ragon/Sources/Game/IGameRoom.cs +++ b/Ragon/Sources/Game/IGameRoom.cs @@ -8,5 +8,7 @@ public interface IGameRoom public int PlayersMax { get; } public int PlayersCount { get; } + public Player GetPlayerById(string id); + public Player GetPlayerByPeer(ushort peerId); public Entity GetEntityById(int entityId); } \ No newline at end of file diff --git a/Ragon/Sources/Plugin/PluginBase.cs b/Ragon/Sources/Plugin/PluginBase.cs index f8b443e..e9d5dcb 100755 --- a/Ragon/Sources/Plugin/PluginBase.cs +++ b/Ragon/Sources/Plugin/PluginBase.cs @@ -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; } - public virtual bool OnEntityDestroyed(Player destoyer, Entity entity) + public virtual bool OnEntityDestroyed(Player player, Entity entity) { return false; }