public NetworkPlayerSpawnContext(NetworkEntityGuid guid, INetPeer peer) { //TODO: Null tests NetworkGuid = guid; Peer = peer; }
public bool TryInteract(NetworkEntityGuid entityInteracting) { //Send the interaction request for the server to handle. SendRequest(new EntityInteractionRequestPayload(guidContainer.NetworkGuid), DeliveryMethod.ReliableOrdered, false, 0); return(true); }
public NetworkGameObjectPrefabSpawnContext(NetworkEntityGuid guid, GameObjectPrefab prefabId, INetPeer peer) { //TODO: Check refs PrefabId = prefabId; NetworkGuid = guid; NetworkPeer = peer; }
public EntityStateChangedEvent(byte state, NetworkEntityGuid entityGuid, float timeStamp) { //TODO: Check refs //TODO: Verify args State = state; EntityGuid = entityGuid; CurrentTimeStamp = timeStamp; }
public EntityPositionUpdateEvent(Vector3Surrogate position, NetworkEntityGuid entityGuid, float timeStamp) { //TODO: Check refs //TODO: Verify args EntityGuid = entityGuid; Position = position; CurrentTimeStamp = timeStamp; }
/// <summary> /// Creates a new <see cref="BoomaPayloadMessageType.PlayerSpawnResponse"/> payload. /// </summary> public PlayerSpawnResponsePayload(PlayerSpawnResponseCode code, Vector3Surrogate position, QuaternionSurrogate rotation, NetworkEntityGuid entityGuid) { //TODO: Check refs ResponseCode = code; EntityGuid = entityGuid; Position = position; Rotation = rotation; }
public GameObjectEntitySpawnEventPayload(NetworkEntityGuid entityGuid, Vector3Surrogate position, QuaternionSurrogate rotation, Vector3Surrogate scale, GameObjectPrefab prefabId, byte state) : base(entityGuid, position, rotation) { //TODO: Check values/refs Scale = scale; PrefabId = prefabId; CurrentState = state; }
/// <inheritdoc /> public void Unlock(NetworkEntityGuid entityInteracting) { if (entityInteracting == null) { Unlock(); } //TODO: Implement entity handling }
public bool TryInteract([NotNull] NetworkEntityGuid entityInteracting) { if (entityInteracting == null) { throw new ArgumentNullException(nameof(entityInteracting)); } //TODO: Distance checking. return(TryInteract()); }
protected override void OnIncomingHandlableMessage(IRequestMessage message, PlayerMoveRequestPayload payload, IMessageParameters parameters, InstanceClientSession peer) { NetworkEntityGuid guid = guidLookupService.Lookup(peer.PeerDetails.ConnectionID); if (guid == null) { throw new InvalidOperationException($"Couldn't find GUID for Connection ID: {peer.PeerDetails.ConnectionID}."); } entityCollection[guid].WorldObject.transform.position = payload.Position.ToVector3(); }
public static void Test_Can_Build_Empty_Guid_With_0_Id() { //arrange NetworkEntityGuidBuilder builder = new NetworkEntityGuidBuilder(); //act NetworkEntityGuid guid = builder.WithId(0).WithId(0).Build(); //assert Assert.NotNull(guid); Assert.IsTrue(guid.isEmpty); }
public EntityContainer([NotNull] NetworkEntityGuid networkGuid, [NotNull] GameObject worldObject) { if (networkGuid == null) { throw new ArgumentNullException(nameof(networkGuid)); } if (worldObject == null) { throw new ArgumentNullException(nameof(worldObject)); } NetworkGuid = networkGuid; WorldObject = worldObject; }
public static void Test_Can_Build_Guid_With_Provided_EntityType(EntityType type) { //arrange NetworkEntityGuidBuilder builder = new NetworkEntityGuidBuilder(); //act NetworkEntityGuid guid = builder.WithType(type).WithType(type).Build(); //assert Assert.NotNull(guid); //won't be empty with an entity type. Assert.AreEqual(type, guid.EntityType); }
public static void Test_Can_Build_Guid_With_Provided_Id(int id) { //arrange NetworkEntityGuidBuilder builder = new NetworkEntityGuidBuilder(); //act NetworkEntityGuid guid = builder.WithId(Math.Max(65, id - 5)).WithId(id).Build(); //assert Assert.NotNull(guid); Assert.IsFalse(guid.isEmpty); Assert.AreEqual(id, guid.EntityId); }
private void OnEntityLevelChanged([JetBrains.Annotations.NotNull] NetworkEntityGuid entity, [JetBrains.Annotations.NotNull] EntityDataChangedArgs <int> changeData) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (changeData == null) { throw new ArgumentNullException(nameof(changeData)); } IWorldObject worldObject = WorldObjectMappable.RetrieveEntity(entity); worldObject.SetLevel(changeData.NewValue); }
/// <summary> /// Creates a new payload for the <see cref="BoomaPayloadMessageType.EntitySpawnEvent"/> packet. /// </summary> /// <param name="entityGuid">The entity's GUID.</param> /// <param name="position">Position of the entity.</param> /// <param name="rotation">Rotation of the entity.</param> public EntitySpawnEventPayload(NetworkEntityGuid entityGuid, Vector3Surrogate position, QuaternionSurrogate rotation) { if (position == null) { throw new ArgumentNullException(nameof(position), $"Provided {nameof(Vector3Surrogate)} must not be null."); } if (rotation == null) { throw new ArgumentNullException(nameof(rotation), $"Provided {nameof(QuaternionSurrogate)} must not be null."); } EntityGuid = entityGuid; Position = position; Rotation = rotation; }
protected override void OnIncomingHandlableMessage(IRequestMessage message, PlayerSpawnRequestPayload payload, IMessageParameters parameters, InstanceClientSession peer) { //TODO: Right now we don't have a full handshake for entering an instance. So we need to make up a GUID for the entering player //Important to check if we've actually already created an entity for this connection //We don't have that implemenented though for the demo //rely on the factory implementation to handle placement details such as position and rotation NetworkEntityGuid guid = entityGuidFactory.Create(EntityType.Player); IEntitySpawnResults details = playerEntityFactory.SpawnPlayerEntity(new NetworkPlayerSpawnContext(guid, peer)); if (details.Result != SpawnResult.Success) { throw new InvalidOperationException($"Failed to create Entity for {peer.ToString()}. Failure: {details.Result.ToString()}"); } //TODO: This is temporary stuff for demo entityCollection.Add(guid, new EntityContainer(guid, details.EntityGameObject)); peerCollection.Add(peer); connectionRegistry.Register(peer.PeerDetails.ConnectionID, guid); //TODO: Clean this up Vector3Surrogate pos = details.EntityGameObject.transform.position.ToSurrogate(); QuaternionSurrogate rot = details.EntityGameObject.transform.rotation.ToSurrogate(); //Send the response to the player who requested to spawn peer.SendResponse(new PlayerSpawnResponsePayload(PlayerSpawnResponseCode.Success, pos, rot, guid), DeliveryMethod.ReliableUnordered, true, 0); //TODO: Remove this. This is demo code. foreach (var entity in entityCollection.Values.Where(e => e.NetworkGuid.EntityType == EntityType.GameObject)) { ITagProvider <GameObjectPrefab> prefabTag = entity.WorldObject.GetComponent <ITagProvider <GameObjectPrefab> >(); IEntityStateContainer state = entity.WorldObject.GetComponentInChildren <IEntityStateContainer>(); peer.SendEvent(new GameObjectEntitySpawnEventPayload(entity.NetworkGuid, entity.WorldObject.transform.position.ToSurrogate(), entity.WorldObject.transform.rotation.ToSurrogate(), entity.WorldObject.transform.localScale.ToSurrogate(), prefabTag.Tag, state.State), DeliveryMethod.ReliableOrdered, false, 0); } }
public void InitializeAvatar([NotNull] NetworkEntityGuid entityGuidOwner, [NotNull] Task <string> entityName) { if (entityGuidOwner == null) { throw new ArgumentNullException(nameof(entityGuidOwner)); } if (entityName == null) { throw new ArgumentNullException(nameof(entityName)); } //We can't really recover from this but we can log try { UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() => { try { string avatarName = await entityName .ConfigureAwaitFalse(); await InitializeAvatarRenderers(avatarName) .ConfigureAwaitFalseVoid(); } catch (Exception e) { Debug.LogError($"Failed to query GaiaOnline for avatar data. Reason: {e.ToString()}"); throw; } }); } catch (Exception e) { //TODO: Add username/id info Debug.LogError($"Encountered error when attempting to load the avatar: {e.Message}"); throw; } }
public EntityWorldObjectCreatedEventArgs([NotNull] NetworkEntityGuid entityGuid, [NotNull] IWorldObject worldReprensetation) { EntityGuid = entityGuid ?? throw new ArgumentNullException(nameof(entityGuid)); WorldReprensetation = worldReprensetation ?? throw new ArgumentNullException(nameof(worldReprensetation)); }
/// <summary> /// Creates a new <see cref="BoomaPayloadMessageType.PlayerMoveRequestPayload"/> payload. /// </summary> public EntityInteractionRequestPayload(NetworkEntityGuid guidOfEntityToInteractWith) { //TODO: Check refs NetworkGuid = guidOfEntityToInteractWith; }
TInstanceModelType IEntityGuidMappable <NetworkEntityGuid, TInstanceModelType> .this[NetworkEntityGuid key] { get => GetCreatureInstance(key);
public void Register(int connectionId, NetworkEntityGuid guid) { GuidToConnectionMap[guid] = connectionId; ConnectionToGuidMap[connectionId] = guid; }
public int Lookup(NetworkEntityGuid guid) { return(GuidToConnectionMap[guid]); }
public bool Contains(NetworkEntityGuid guid) { return(GuidToConnectionMap.ContainsKey(guid)); }
public PlayerEntitySpawnEventPayload(NetworkEntityGuid entityGuid, Vector3Surrogate position, QuaternionSurrogate rotation) : base(entityGuid, position, rotation) { //Nothing at the moment. Can extend for future use. }