Exemple #1
0
            private static void ServerLoadSystem()
            {
                const string key = nameof(LandClaimAreaManager);

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

                serverLandClaimManagerInstance = Server.World.CreateLogicObject <LandClaimAreaManager>();
                var publicState = LandClaimAreaManager.GetPublicState(serverLandClaimManagerInstance);

                publicState.LandClaimAreas = new NetworkSyncList <ILogicObject>();

                Server.Database.Set(key, key, serverLandClaimManagerInstance);

                sharedLandClaimAreas = LandClaimAreaManager.GetPublicState(serverLandClaimManagerInstance)
                                       .LandClaimAreas;

                foreach (var area in sharedLandClaimAreas)
                {
                    var areaPrivateState = LandClaimArea.GetPrivateState(area);
                    var areaPublicState  = LandClaimArea.GetPublicState(area);
                    areaPublicState.SetupAreaProperties(areaPrivateState);
                }
            }
Exemple #2
0
            public override void ClientInitialize()
            {
                Client.Characters.CurrentPlayerCharacterChanged += ClientTryRequestAreasAsync;

                ClientTryRequestAreasAsync();

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

                    Logger.Important("Land claim areas requested from server");

                    var landClaimManagerInstance = await Instance.CallServer(
                        _ => _.ServerRemote_AcquireLandClaimManager());

                    var areas = LandClaimAreaManager.GetPublicState(landClaimManagerInstance)
                                .LandClaimAreas;

                    Logger.Important($"Land claim areas received from server: {areas.Count} areas total");

                    ClientLandClaimAreaManager.SetAreas(areas);
                    sharedLandClaimAreas = areas;
                }
            }