/// <inheritdoc /> protected override void HandleEvent(PlayerSessionClaimedEventArgs args) { if (Logger.IsDebugEnabled) { Logger.Debug($"Dequeueing entity creation request for: {args.EntityGuid.EntityType}:{args.EntityGuid.EntityId}"); } //TODO: This is test data EntityFieldDataCollection <EntityDataFieldType> testData = new EntityFieldDataCollection <EntityDataFieldType>(); //TODO: Test values set testData.SetFieldValue(EntityDataFieldType.EntityCurrentHealth, 100); testData.SetFieldValue(EntityDataFieldType.EntityMaxHealth, 120); using (LockingPolicy.WriterLock(null, CancellationToken.None)) { //TODO: Time stamp //TODO: We should check if the result is valid? Maybe return a CreationResult? //We don't need to do anything with the returned object. GameObject playerGameObject = PlayerFactory.Create(new PlayerEntityCreationContext(args.EntityGuid, args.SessionContext, new PositionChangeMovementData(0, args.SpawnPosition, Vector2.zero), EntityPrefab.RemotePlayer, testData)); } if (Logger.IsDebugEnabled) { Logger.Debug($"Sending player spawn payload Id: {args.EntityGuid.EntityId}"); } OnPlayerWorldSessionCreated?.Invoke(this, new PlayerWorldSessionCreationEventArgs(args.EntityGuid)); //TODO: If we want to do anything post-creation with the provide gameobject we could. But we really don't want to at the moment. }
private static EntityFieldDataCollection <EntityDataFieldType> CreateEntityDataCollectionFromPayload(FieldValueUpdate fieldUpdateValues) { //TODO: We need better initial handling for entity data EntityFieldDataCollection <EntityDataFieldType> entityData = new EntityFieldDataCollection <EntityDataFieldType>(); int currentSentIndex = 0; foreach (var setIndex in fieldUpdateValues.FieldValueUpdateMask.EnumerateSetBitsByIndex()) { entityData.SetFieldValue(setIndex, fieldUpdateValues.FieldValueUpdates.ElementAt(currentSentIndex)); currentSentIndex++; } return(entityData); }