コード例 #1
0
            public override void ClientInitialize()
            {
                Client.Characters.CurrentPlayerCharacterChanged += ClientTryRequestWorldResourcesAsync;

                ClientTryRequestWorldResourcesAsync();

                async void ClientTryRequestWorldResourcesAsync()
                {
                    if (Api.Client.Characters.CurrentPlayerCharacter == null)
                    {
                        return;
                    }

                    Logger.Important("World map resource marks requested from server");

                    var managerInstance = await Instance.CallServer(_ => _.ServerRemote_AcquireManagerInstance());

                    var marksList = WorldMapResourceMarksManager.GetPublicState(managerInstance)
                                    .Marks;

                    Logger.Important($"World map resource marks received from server: {marksList.Count} marks total");

                    //ClientWorldMapResourceMarksManager.SetAreas(list);
                    if (sharedResourceMarksList != null)
                    {
                        var onRemoved = ClientMarkRemoved;
                        if (onRemoved != null)
                        {
                            foreach (var mark in sharedResourceMarksList)
                            {
                                onRemoved.Invoke(mark);
                            }
                        }

                        sharedResourceMarksList.ClientElementInserted -= this.ClientMarksListElementInsertedHandler;
                        sharedResourceMarksList.ClientElementRemoved  -= this.ClientMarksListElementRemovedHandler;
                    }

                    sharedResourceMarksList = marksList;
                    sharedResourceMarksList.ClientElementInserted += this.ClientMarksListElementInsertedHandler;
                    sharedResourceMarksList.ClientElementRemoved  += this.ClientMarksListElementRemovedHandler;

                    var onAdded = ClientMarkAdded;

                    if (onAdded != null)
                    {
                        foreach (var mark in sharedResourceMarksList)
                        {
                            onAdded.Invoke(mark);
                        }
                    }
                }
            }
コード例 #2
0
            private static void ServerLoadSystem()
            {
                const string key = nameof(WorldMapResourceMarksManager);

                if (Server.Database.TryGet(key, key, out ILogicObject savedManager))
                {
                    Server.World.DestroyObject(savedManager);
                }

                serverManagerInstance = Server.World.CreateLogicObject <WorldMapResourceMarksManager>();
                Server.Database.Set(key, key, serverManagerInstance);

                var publicState = WorldMapResourceMarksManager.GetPublicState(serverManagerInstance);

                sharedResourceMarksList = new NetworkSyncList <WorldMapResourceMark>();
                publicState.Marks       = sharedResourceMarksList;
            }