/// <summary> /// This method is called whenever an actor is activated. /// An actor is activated the first time any of its methods are invoked. /// </summary> protected override Task OnActivateAsync() { ActorEventSource.Current.ActorMessage(this, "WorldActor activated."); // The StateManager is this actor's private state store. // Data stored in the StateManager will be replicated for high-availability for actors that use volatile or persisted state storage. // Any serializable object can be saved in the StateManager. // For more information, see https://aka.ms/servicefabricactorsstateserialization var metaData = new WorldInfoMetaData() { stridePerChunks = 0, visiblityStridePerPlayer = 0, chunkCount = 0 }; return(this.StateManager.TryAddStateAsync("metaData", metaData)); }
public Task <GenericResponse> Create(Position beginPoint, Position endPoint, int chunkSize, int visibilityChunkCount) { var response = new GenericResponse(); var metaData = new WorldInfoMetaData() { maxLocation = endPoint, minLocation = beginPoint, stridePerChunks = chunkSize, visiblityStridePerPlayer = visibilityChunkCount, chunkCount = 0 }; this.StateManager.SetStateAsync <WorldInfoMetaData>("metaData", metaData); var chunkDictionary = new Dictionary <ActorId, Tracking>(); GenerateChunks(chunkDictionary, beginPoint, endPoint, chunkSize); AssociateChunks(chunkDictionary, visibilityChunkCount, chunkSize); return(Task.FromResult <GenericResponse>(response)); }