/// <summary> /// Move blocks in m_projectedBlocks to m_damagedBlocks if they are touching any real blocks /// </summary> private void ProjectedToDamaged() { foreach (IMySlimBlock block in m_projectedBlocks) { MyCubeGrid projected = (MyCubeGrid)block.CubeGrid; MyCubeGrid projectorGrid = projected.Projector.CubeGrid; if (projected.Closed || projected.Projector.Closed || !projected.Projector.IsWorking || projectorGrid.Closed) { Log.DebugLog("projection closed"); continue; } Vector3I min = projectorGrid.WorldToGridInteger(projected.GridIntegerToWorld(block.Min())); if (projectorGrid.GetCubeBlock(min) != null) { Log.DebugLog("space is occupied: " + min); m_projectedBlocks.Remove(block); continue; } IMyCubeBlock cubeBlock = block.FatBlock; if (cubeBlock != null) { Vector3I max = projectorGrid.WorldToGridInteger(projected.GridIntegerToWorld(block.Max())); MatrixD invOrient = projectorGrid.PositionComp.WorldMatrixNormalizedInv.GetOrientation(); Vector3 forward = Vector3D.Transform(cubeBlock.WorldMatrix.Forward, ref invOrient); Vector3 up = Vector3D.Transform(cubeBlock.WorldMatrix.Up, ref invOrient); MyBlockOrientation orient = new MyBlockOrientation(Base6Directions.GetClosestDirection(ref forward), Base6Directions.GetClosestDirection(ref up)); if (projectorGrid.CanPlaceBlock(min, max, orient, ((MyCubeBlock)cubeBlock).BlockDefinition)) { Log.DebugLog("can place fatblock: " + cubeBlock.DisplayNameText + ", position: " + min + ", world: " + projectorGrid.GridIntegerToWorld(min)); m_damagedBlocks.Add(block); m_projectedBlocks.Remove(block); } continue; } // no fatblock, cannot get definition if (projectorGrid.IsTouchingAnyNeighbor(min, min)) { Log.DebugLog("can place slimblock: " + block.ToString() + ", position: " + min + ", world: " + projectorGrid.GridIntegerToWorld(min)); m_damagedBlocks.Add(block); m_projectedBlocks.Remove(block); } } m_projectedBlocks.ApplyRemovals(); }
internal void Clean() { for (int j = 0; j < CleanUp.Count; j++) { var p = CleanUp[j]; for (int i = 0; i < p.VrPros.Count; i++) { var virtInfo = p.VrPros[i]; virtInfo.Info.Clean(Session.Tick); VirtInfoPool.Return(virtInfo.Info); } p.VrPros.Clear(); if (p.DynamicGuidance) { DynTrees.UnregisterProjectile(p); } p.PruningProxyId = -1; p.Info.Clean(Session.Tick); ProjectilePool.Push(p); ActiveProjetiles.Remove(p); } CleanUp.Clear(); }
private static void Update10() { foreach (TestRemoteTask task in m_tasks) { switch (task.CurrentStatus) { case Status.None: case Status.Started: break; default: Logger.DebugLog("Completed: " + task + ", Result: " + task.Result); m_tasks.Remove(task); break; } } m_tasks.ApplyRemovals(); if (m_tasks.Count < 10) { TestRemoteTask task = new TestRemoteTask(); task.Parameter = "Par"; m_tasks.Add(task); StartTask(task); } m_tasks.ApplyAdditions(); }
public void Unregister(EquiPlayerAttachmentComponent.Slot slot) { if (!MyMultiplayerModApi.Static.IsServer) { return; } _slots.Remove(slot); MarkDirty(); }
public void ProcessDirtyCells(Dictionary <MyEntity, MyEntityTracker> trackedEntities) { m_dirtyCells.ApplyAdditions(); if (m_dirtyCells.Count == 0) { return; } ProfilerShort.Begin("Find false possitive dirty cells"); foreach (var cell in m_dirtyCells) { foreach (var tracker in trackedEntities.Values) { var scaledBoundingVolume = tracker.BoundingVolume; scaledBoundingVolume.Radius *= SCALE; if (scaledBoundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint) { m_dirtyCells.Remove(cell); break; } } } m_dirtyCells.ApplyRemovals(); ProfilerShort.BeginNextBlock("Remove stuff"); foreach (var cell in m_dirtyCells) { cell.GetAll(m_tempObjectSeedList); foreach (var objectSeed in m_tempObjectSeedList) { if (objectSeed.Generated) { CloseObjectSeed(objectSeed); } } m_tempObjectSeedList.Clear(); } ProfilerShort.BeginNextBlock("Remove dirty cells"); foreach (var cell in m_dirtyCells) { m_cells.Remove(cell.CellId); m_cellsTree.RemoveProxy(cell.proxyId); } m_dirtyCells.Clear(); ProfilerShort.End(); }
/// <summary> /// Unloads all cells that have been marked to be unloaded. It will remove all objects inside the sphere from /// the world. It will not unload cells that are still in the tracking volume of a tracked entity. /// </summary> /// <param name="trackedEntities">List of tracked entities</param> public void UnloadCells(Dictionary <MyEntity, MyEntityTracker> trackedEntities) { m_toUnloadCells.ApplyAdditions(); if (m_toUnloadCells.Count == 0) { return; } List <MyObjectSeed> cellObjects = new List <MyObjectSeed>(); foreach (MyProceduralCell cell in m_toUnloadCells) { foreach (MyEntityTracker tracker in trackedEntities.Values) { BoundingSphereD boundingVolume = tracker.BoundingVolume; if (boundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint) { m_toUnloadCells.Remove(cell); break; } } } m_toUnloadCells.ApplyRemovals(); foreach (var cell in m_toUnloadCells) { cell.GetAll(cellObjects); foreach (MyObjectSeed obj in cellObjects) { if (obj.Params.Generated) { CloseObject(obj); } } cellObjects.Clear(); } foreach (MyProceduralCell cell in m_toUnloadCells) { m_cells.Remove(cell.CellId); m_cellsTree.RemoveProxy(cell.proxyId); } m_toUnloadCells.Clear(); }
public static void GenerateLuckyContent(this MyInventoryBase inventory, MyLootTableDefinition lootTableDefinition, LootContext context, HashSet <MyStringHash> blacklistedLootTables = null) { var cachingHashSet = new CachingHashSet <MyLootTableDefinition.Row>(); foreach (var item in lootTableDefinition.LootTable) { cachingHashSet.Add(item); } cachingHashSet.ApplyChanges(); var num = 0f; if (blacklistedLootTables == null) { blacklistedLootTables = new HashSet <MyStringHash>(); } blacklistedLootTables.Add(lootTableDefinition.Id.SubtypeId); foreach (var row in cachingHashSet) { if (row.AlwaysDrops && row.ItemDefinition != null) { if (row.ItemDefinition.Value.TypeId == typeof(MyObjectBuilder_LootTableDefinition)) { var nestedTable = MyDefinitionManager.Get <MyLootTableDefinition>(row.ItemDefinition.Value); if (nestedTable != null && !blacklistedLootTables.Contains(nestedTable.Id.SubtypeId)) { inventory.GenerateLuckyContent(nestedTable, context, blacklistedLootTables); } } else { AddItemsFuzzy(inventory, row.ItemDefinition.Value, row.Amount); } if (row.IsUnique) { cachingHashSet.Remove(row, false); continue; } } num += row.Weight; } var rollLucky = Math.Round(lootTableDefinition.Rolls * context.RollMultiplier + context.RollAdditive); for (var j = 0; j < rollLucky; j++) { var num2 = MyRandom.Instance.NextFloat(0f, num); cachingHashSet.ApplyChanges(); foreach (var row2 in cachingHashSet) { num2 -= row2.Weight; if (num2 > 0f || row2.ItemDefinition == null) { continue; } if (row2.ItemDefinition.Value.TypeId == typeof(MyObjectBuilder_LootTableDefinition)) { var nestedTable = MyDefinitionManager.Get <MyLootTableDefinition>(row2.ItemDefinition.Value); if (nestedTable != null) { inventory.GenerateLuckyContent(nestedTable, context); } } else { AddItemsFuzzy(inventory, row2.ItemDefinition.Value, row2.Amount); } if (row2.IsUnique) { cachingHashSet.Remove(row2, false); num -= row2.Weight; } break; } } blacklistedLootTables.Remove(lootTableDefinition.Id.SubtypeId); }