protected override void OnIncomingHandlableMessage(IEventMessage message, EntityPositionUpdateEvent payload, IMessageParameters parameters, InstanceClientPeer peer) { //logger.Info($"Recieved position event for ID: {payload.EntityGuid.EntityId}."); if (entityCollection.ContainsKey(payload.EntityGuid)) { entityCollection[payload.EntityGuid].WorldObject.transform.position = payload.Position.ToVector3(); } else { Debug.Log($"Recieved position update event from Type: {payload.EntityGuid.EntityType} Id: {payload.EntityGuid.EntityId} but we've not spawned an entity with that GUID."); } }
protected override void OnIncomingHandlableMessage(IRequestMessage message, EntityInteractionRequestPayload payload, IMessageParameters parameters, InstanceClientSession peer) { logger.Debug($"Recieved interaction request for {payload.NetworkGuid.EntityId}."); if (entityCollection.ContainsKey(payload.NetworkGuid)) { IWorldInteractable interactable = entityCollection[payload.NetworkGuid]?.WorldObject?.GetComponent <IWorldInteractable>(); if (interactable == null) { logger.Warn($"Recieved interaction request for entity that can't be interacted with ID: {payload.NetworkGuid.EntityId} Type: {payload.NetworkGuid.EntityType} from NetId: {peer.PeerDetails.ConnectionID}."); } else { interactable.TryInteract(guidLookupService.Lookup(peer.PeerDetails.ConnectionID)); } } else { logger.Warn($"Recieved interaction request for unknown entity ID: {payload.NetworkGuid.EntityId} Type: {payload.NetworkGuid.EntityType} from NetId: {peer.PeerDetails.ConnectionID}."); } }
protected override void OnIncomingHandlableMessage(IEventMessage message, EntityStateChangedEvent payload, IMessageParameters parameters, InstanceClientPeer peer) { logger.Debug($"Recieved state change from Entity Id: {payload.EntityGuid.EntityId} with new state Value: {payload.State}."); if (entityCollection.ContainsKey(payload.EntityGuid)) { var entityChunk = entityCollection[payload.EntityGuid]; IEntityStateContainer state = entityChunk.WorldObject.GetComponent <IEntityStateContainer>(); if (state == null) { throw new InvalidOperationException($"Failed to find {nameof(IEntityStateContainer)} component on GameObject: {entityChunk.WorldObject.name} with Entity Id: {payload.EntityGuid.EntityId}."); } //Just straight set the state from the payload. state.State = payload.State; } else { logger.Warn($"Recieved state change from UNKNOWN Entity Id: {payload.EntityGuid.EntityId} with new state Value: {payload.State}."); } }