public void RemoveBuildingBlock(BuildingBlock ent) { if (ent == null) { return; } buildingBlocks.Remove(ent); if (!AI.nav_carve_use_building_optimization || navmeshCarvers == null) { return; } NavMeshObstacle component = ent.GetComponent <NavMeshObstacle>(); if (!(component != null)) { return; } navmeshCarvers.Remove(component); if (navmeshCarvers.Count == 0) { navmeshCarvers = null; } isNavMeshCarvingDirty = true; if (navmeshCarvers == null) { Building building = ent.GetBuilding(); if (building != null) { int ticks = 2; server.UpdateNavMeshCarver(building, ref ticks, 0); } } }
private static void DoProcessing(ListHashSet <IThinker> process, float budgetSeconds, ref int last) { float realtimeSinceStartup = Time.realtimeSinceStartup; while (last < process.Count && Time.realtimeSinceStartup < realtimeSinceStartup + budgetSeconds) { IThinker thinker = process[last]; if (thinker != null) { try { thinker.TryThink(); } catch (Exception message) { Debug.LogWarning(message); } } last++; } if (last >= process.Count) { last = 0; } }
public virtual void Dispose() { this.networkables = null; this.subscribers = null; this.manager = null; this.ID = 0; }
public void RemoveBuildingBlock(BuildingBlock ent) { if (ent == null) { return; } this.buildingBlocks.Remove(ent); if (AI.nav_carve_use_building_optimization && this.navmeshCarvers != null) { NavMeshObstacle component = ent.GetComponent <NavMeshObstacle>(); if (component != null) { this.navmeshCarvers.Remove(component); if (this.navmeshCarvers.Count == 0) { this.navmeshCarvers = null; } this.isNavMeshCarvingDirty = true; if (this.navmeshCarvers == null) { BuildingManager.Building building = ent.GetBuilding(); if (building != null) { int num = 2; BuildingManager.server.UpdateNavMeshCarver(building, ref num, 0); } } } } }
static AIThinkManager() { AIThinkManager._processQueue = new ListHashSet <IThinker>(8); AIThinkManager._removalQueue = new ListHashSet <IThinker>(8); AIThinkManager.framebudgetms = 2.5f; AIThinkManager.lastIndex = 0; }
public IEnumerator <T> GetEnumerator() { ListHashSet <T> ts = null; for (int i = 0; i < ts.vals.Count; i++) { yield return(ts.vals[i]); } }
void DestroyUIAll(bool force = false) { ListHashSet <BasePlayer> players = BasePlayer.activePlayerList; for (int i = 0; i < players.Count; i++) { DestroyUI(players[i], force); } }
public Anonymizer(ListHashSet <BasePlayer> activePlayers, Func <string> generateRandomName) { GenerateRandomName = generateRandomName; AnonymizedPlayers = new Dictionary <string, AnonymizedPlayer>(); foreach (BasePlayer activePlayer in activePlayers) { Anonymize(activePlayer.IPlayer); } }
public override void ServerInit() { base.ServerInit(); if (Stocking.stockings == null) { Stocking.stockings = new ListHashSet <Stocking>(8); } Stocking.stockings.Add(this); }
void CreateUIAll() { ListHashSet <BasePlayer> players = BasePlayer.activePlayerList; for (int i = 0; i < players.Count; i++) { CreateUI(players[i]); } }
private void RegisterPermissions() { _registeredPermissions = new ListHashSet <string>( ); for (var i = 1; i < 5; i++) { RegisterPermission(Name.ToLower() + "." + i); } RegisterPermission(Name.ToLower() + "." + "nores"); RegisterPermission(Name.ToLower() + "." + "all"); }
private static void DoRemoval(ListHashSet <IThinker> removal, ListHashSet <IThinker> process) { if (removal.Count <= 0) { return; } foreach (IThinker item in removal) { process.Remove(item); } removal.Clear(); }
private static IEnumerator LoadSkin(ulong workshopId) { int bundleIndex = WorkshopSkin.GetBundleIndex(workshopId); AssetBundle assetBundle = WorkshopSkin.bundles[bundleIndex]; TimeWarning.BeginSample("WorkshopSkin.LoadSkin"); TimeWarning.BeginSample("ItemCache.Get"); Item item = WorkshopSkin.ItemCache[workshopId]; TimeWarning.EndSample(); TimeWarning.BeginSample("SkinCache.Get"); Skin skin = WorkshopSkin.SkinCache[workshopId]; TimeWarning.EndSample(); if (skin.IconRequested && !skin.IconLoaded) { TimeWarning.EndSample(); yield return(Global.Runner.StartCoroutine(skin.LoadIcon(workshopId, item.Directory, assetBundle))); TimeWarning.BeginSample("WorkshopSkin.LoadSkin"); } if (skin.AssetsRequested && !skin.AssetsLoaded) { TimeWarning.EndSample(); yield return(Global.Runner.StartCoroutine(skin.LoadAssets(workshopId, item.Directory, assetBundle))); TimeWarning.BeginSample("WorkshopSkin.LoadAssets"); } if (!skin.AssetsRequested && skin.AssetsLoaded) { TimeWarning.BeginSample("Skin.UnloadAssets"); skin.UnloadAssets(); TimeWarning.EndSample(); } if (skin.AssetsLoaded && WorkshopSkin.RefreshQueue.Contains(workshopId)) { ListHashSet <WorkshopSkin> workshopSkins = WorkshopSkin.RefreshQueue[workshopId]; while (workshopSkins.Count > 0) { WorkshopSkin workshopSkin = workshopSkins[0]; workshopSkins.RemoveAt(0); workshopSkin.ApplySkin(skin, workshopId); TimeWarning.EndSample(); yield return(null); TimeWarning.BeginSample("WorkshopSkin.LoadAssets"); } WorkshopSkin.RefreshQueue.Remove(workshopId); workshopSkins = null; } TimeWarning.EndSample(); }
public static bool HasAnyPermission(this BasePlayer player, ListHashSet <string> perms) { foreach (var perm in perms) { if (!player.HasPermission(perm)) { continue; } return(true); } return(false); }
private void DequeueSkinRefresh(ulong workshopId) { if (workshopId == 0) { return; } ListHashSet <WorkshopSkin> workshopSkins = null; if (WorkshopSkin.RefreshQueue.TryGetValue(workshopId, out workshopSkins)) { workshopSkins.Remove(this); if (workshopSkins.Count == 0) { WorkshopSkin.RefreshQueue.Remove(workshopId); } } }
private void EnqueueSkinRefresh(ulong workshopId) { if (workshopId == 0) { return; } ListHashSet <WorkshopSkin> workshopSkins = null; if (!WorkshopSkin.RefreshQueue.TryGetValue(workshopId, out workshopSkins)) { ListDictionary <ulong, ListHashSet <WorkshopSkin> > refreshQueue = WorkshopSkin.RefreshQueue; ListHashSet <WorkshopSkin> workshopSkins1 = new ListHashSet <WorkshopSkin>(8); workshopSkins = workshopSkins1; refreshQueue.Add(workshopId, workshopSkins1); } workshopSkins.Add(this); WorkshopSkin.LoadFromWorkshop(workshopId); }
public void ListHashSetTest() { ListHashSet<string> set = new ListHashSet<string>(); Assert.AreEqual(set.Count(), 0); CollectionAssert.AreEqual(new string[] { }, set.ToArray()); Assert.IsFalse(set.Contains("a")); Assert.IsFalse(set.Contains("b")); set.Add("b"); Assert.AreEqual(set.Count(), 1); Assert.IsFalse(set.Contains("a")); Assert.IsTrue(set.Contains("b")); CollectionAssert.AreEqual(new string[] { "b" }, set.ToArray()); set.Add("a"); Assert.AreEqual(set.Count(), 2); Assert.IsTrue(set.Contains("a")); Assert.IsTrue(set.Contains("b")); CollectionAssert.AreEqual(new string[] { "b", "a" }, set.ToArray()); set.Add("b"); Assert.AreEqual(set.Count(), 2); Assert.IsTrue(set.Contains("a")); Assert.IsTrue(set.Contains("b")); CollectionAssert.AreEqual(new string[] { "b", "a" }, set.ToArray()); Assert.AreEqual(set[0], "b"); Assert.AreEqual(set[1], "a"); set.Remove("b"); CollectionAssert.AreEqual(new string[] { "a" }, set.ToArray()); Assert.IsTrue(set.Contains("a")); Assert.IsFalse(set.Contains("b")); set.Clear(); CollectionAssert.AreEqual(new string[] {}, set.ToArray()); Assert.IsFalse(set.Contains("a")); Assert.IsFalse(set.Contains("b")); }
public void AddBuildingBlock(BuildingBlock ent) { if (ent == null || buildingBlocks.Contains(ent)) { return; } buildingBlocks.Add(ent); if (!AI.nav_carve_use_building_optimization) { return; } NavMeshObstacle component = ent.GetComponent <NavMeshObstacle>(); if (component != null) { isNavMeshCarvingDirty = true; if (navmeshCarvers == null) { navmeshCarvers = new ListHashSet <NavMeshObstacle>(); } navmeshCarvers.Add(component); } }
public void AddBuildingBlock(BuildingBlock ent) { if (Object.op_Equality((Object)ent, (Object)null) || this.buildingBlocks.Contains(ent)) { return; } this.buildingBlocks.Add(ent); if (!ConVar.AI.nav_carve_use_building_optimization) { return; } NavMeshObstacle component = (NavMeshObstacle)((Component)ent).GetComponent <NavMeshObstacle>(); if (!Object.op_Inequality((Object)component, (Object)null)) { return; } this.isNavMeshCarvingDirty = true; if (this.navmeshCarvers == null) { this.navmeshCarvers = new ListHashSet <NavMeshObstacle>(8); } this.navmeshCarvers.Add(component); }
public void RemoveBuildingBlock(BuildingBlock ent) { if (Object.op_Equality((Object)ent, (Object)null)) { return; } this.buildingBlocks.Remove(ent); if (!ConVar.AI.nav_carve_use_building_optimization || this.navmeshCarvers == null) { return; } NavMeshObstacle component = (NavMeshObstacle)((Component)ent).GetComponent <NavMeshObstacle>(); if (!Object.op_Inequality((Object)component, (Object)null)) { return; } this.navmeshCarvers.Remove(component); if (this.navmeshCarvers.get_Count() == 0) { this.navmeshCarvers = (ListHashSet <NavMeshObstacle>)null; } this.isNavMeshCarvingDirty = true; if (this.navmeshCarvers != null) { return; } BuildingManager.Building building = ent.GetBuilding(); if (building == null) { return; } int ticks = 2; BuildingManager.server.UpdateNavMeshCarver(building, ref ticks, 0); }
public static string GetStatus() { StringBuilder stringBuilder = new StringBuilder(); int count = WorkshopSkin.ItemCache.Count; int num = WorkshopSkin.ItemQueue.Count; int count1 = WorkshopSkin.SkinCache.Count; int num1 = WorkshopSkin.SkinQueue.Count; float single = 0f; stringBuilder.Append("Items: "); stringBuilder.Append(count); stringBuilder.Append(" in cache + "); stringBuilder.Append(num); stringBuilder.Append(" in queue"); stringBuilder.AppendLine(); stringBuilder.Append("Skins: "); stringBuilder.Append(count1); stringBuilder.Append(" in cache + "); stringBuilder.Append(num1); stringBuilder.Append(" in queue"); stringBuilder.AppendLine(); stringBuilder.AppendLine(); if (WorkshopSkin.ItemCache.Count > 0) { TextTable textTable = new TextTable(); textTable.AddColumn("id"); textTable.AddColumn("item"); textTable.AddColumn("icon_requested"); textTable.AddColumn("icon_loaded"); textTable.AddColumn("assets_requested"); textTable.AddColumn("assets_loaded"); textTable.AddColumn("requests"); textTable.AddColumn("references"); textTable.AddColumn("memory"); foreach (KeyValuePair <ulong, Item> itemCache in WorkshopSkin.ItemCache) { ulong key = itemCache.Key; Item value = itemCache.Value; Skin skin = null; ListHashSet <WorkshopSkin> workshopSkins = null; WorkshopSkin.SkinCache.TryGetValue(key, out skin); WorkshopSkin.RefreshQueue.TryGetValue(key, out workshopSkins); float sizeInBytes = (float)skin.GetSizeInBytes() / 1048576f; string str = (value.IsInstalled ? "+" : "-"); string str1 = (skin == null || !skin.IconRequested ? "-" : "+"); string str2 = (skin == null || !skin.IconLoaded ? "-" : "+"); string str3 = (skin == null || !skin.AssetsRequested ? "-" : "+"); string str4 = (skin == null || !skin.AssetsLoaded ? "-" : "+"); string str5 = (workshopSkins != null ? workshopSkins.Count.ToString() : "0"); string str6 = (skin != null ? skin.references.ToString() : "0"); string str7 = (skin != null ? sizeInBytes.ToString("0.0 MB") : "0.0 MB"); textTable.AddRow(new string[] { key.ToString(), str, str1, str2, str3, str4, str5, str6, str7 }); single += sizeInBytes; } stringBuilder.Append(textTable.ToString()); stringBuilder.AppendLine(); } stringBuilder.Append(string.Concat("Total memory used: ", single.ToString("0.0 MB"))); stringBuilder.AppendLine(); return(stringBuilder.ToString()); }