public void CanSync() { try { var locations = new List <SimpleLocation>(); for (int i = 0; i < 10000; ++i) { locations.Add(new() { LocationName = "MyLocation" + i, Position = new UnityEngine.Vector3(i * 1.3f, i * 1.7f), ZonePosition = new Vector2i(i, i), }); } LocationManager.SetLocations(locations); var package = new SimpleLocationPackage(); var serialized = package.Pack(); // Reset stream head, to simulate transfer serialized.m_stream.Position = 0L; CompressedPackage.Unpack <SimpleLocationPackage>(serialized); Assert.IsNotNull(LocationManager.GetLocations()); } finally { } }
public void CanSync() { try { LocalSpawnerConfiguration configuration = new(); configuration.GetBuilder(new LocationIdentifier("Runestone_Boars", "Boar")) .SetPrefabName("Boar") .SetEnabled(true) .SetSpawnInterval(TimeSpan.FromSeconds(3)) .SetPatrolSpawn(true) .SetSpawnInPlayerBase(true) .SetMinLevel(1) .SetMaxLevel(3) .SetLevelUpChance(10) .SetSpawnDuringNight(true) .SetSpawnDuringDay(true) .SetConditionPlayerWithinDistance(60) .SetConditionPlayerNoise(0) .SetModifierFaction(Character.Faction.Boss) .SetModifierTamed(true) .SetModifierTamedCommandable(true); configuration.GetBuilder(new RoomIdentifier("Runestone_Boars", "Boar")) .SetPrefabName("Boar") .SetEnabled(true) .SetSpawnInterval(TimeSpan.FromSeconds(3)) .SetPatrolSpawn(true) .SetSpawnInPlayerBase(true) .SetMinLevel(1) .SetMaxLevel(3) .SetLevelUpChance(10) .SetSpawnDuringNight(true) .SetSpawnDuringDay(true) .SetConditionPlayerWithinDistance(60) .SetConditionPlayerNoise(0) .SetModifierFaction(Character.Faction.Boss) .SetModifierTamed(true) .SetModifierTamedCommandable(true); configuration.Build(); LocalSpawnerConfigPackage package = new(); var zpack = package.Pack(); zpack.m_stream.Position = 0L; LocalSpawnTemplateManager.TemplatesByLocation.Clear(); CompressedPackage.Unpack <LocalSpawnerConfigPackage>(zpack); Assert.IsTrue(LocalSpawnTemplateManager.TemplatesByLocation.Count > 0); } finally { LocalSpawnTemplateManager.TemplatesByLocation.Clear(); } }
private static void RPC_SpawnThat_ReceiveLocalSpawnerConfigs(ZRpc rpc, ZPackage pkg) { Log.LogTrace("Received local spawner config package."); try { CompressedPackage.Unpack <LocalSpawnerConfigPackage>(pkg); } catch (Exception e) { Log.LogError("Error while attempting to read received config package.", e); } }
private static void RPC_ReceiveConfigsDropThat(ZRpc rpc, ZPackage pkg) { Log.LogInfo("Received package."); try { CompressedPackage.Unpack(pkg); } catch (Exception e) { Log.LogError("Error while attempting to read received config package.", e); } }
private static void RPC_ReceiveLocationsSpawnThat(ZRpc rpc, ZPackage pkg) { Log.LogInfo("Received locations package."); try { CompressedPackage.Unpack <SimpleLocationPackage>(pkg); } catch (Exception e) { Log.LogError("Error while attempting to read received locations package.", e); } }
public void SyncShouldNotCrashIfConfigIsNull() { ConfigurationManager.GeneralConfig = null; var package = new GeneralConfigPackage(); var serialized = package.Pack(); // Reset stream head, to simulate transfer serialized.m_stream.Position = 0L; CompressedPackage.Unpack <GeneralConfigPackage>(serialized); }
private static void RPC_ReceiveLocationsDropThat(ZRpc rpc, ZPackage pkg) { Log.LogInfo("Received locations package."); try { if (HaveReceivedLocations) { Log.LogDebug("Already received locations previously. Skipping."); return; } CompressedPackage.Unpack(pkg); HaveReceivedLocations = true; Log.LogInfo("Successfully received and unpacked locations package."); } catch (Exception e) { Log.LogError("Error while attempting to read received locations package.", e); } }
public void CanSync() { try { ConfigurationManager.GeneralConfig = new GeneralConfiguration(); var package = new GeneralConfigPackage(); var serialized = package.Pack(); ConfigurationManager.GeneralConfig = null; // Reset stream head, to simulate transfer serialized.m_stream.Position = 0L; CompressedPackage.Unpack <GeneralConfigPackage>(serialized); Assert.IsNotNull(ConfigurationManager.GeneralConfig); } finally { ConfigurationManager.GeneralConfig = null; } }