private KeyValuePair <long, List <MyCubeGrid> > CheckGroupsPcu(HashSetReader <MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Node> nodes, GridsBroadcastConfig config) { List <MyCubeGrid> gridsList = new List <MyCubeGrid>(); long pcu = 0; foreach (var groupNodes in nodes) { MyCubeGrid cubeGrid = groupNodes.NodeData; if (cubeGrid.Physics == null) { continue; } if (!IsGridInsideFilter(cubeGrid, config)) { continue; } gridsList.Add(cubeGrid); pcu += cubeGrid.BlocksPCU; } return(new KeyValuePair <long, List <MyCubeGrid> >(pcu, gridsList)); }
private KeyValuePair <long, List <MyCubeGrid> > CheckGroupsDays(HashSetReader <MyGroups <MyCubeGrid, MyGridMechanicalGroupData> .Node> nodes, bool checkFaction, DateTime today) { List <MyCubeGrid> gridsList = new List <MyCubeGrid>(); foreach (var groupNodes in nodes) { MyCubeGrid cubeGrid = groupNodes.NodeData; if (cubeGrid.Physics == null) { continue; } gridsList.Add(cubeGrid); } if (gridsList.Count == 0) { return(new KeyValuePair <long, List <MyCubeGrid> >(0, gridsList)); } MyCubeGrid biggestGrid = GridUtils.GetBiggestGridInGroup(gridsList); if (biggestGrid == null) { return(new KeyValuePair <long, List <MyCubeGrid> >(0, new List <MyCubeGrid>())); } long ownerId = OwnershipUtils.GetOwner(biggestGrid); long daysInactive = 0; if (ownerId != 0L && !PlayerUtils.IsNpc(ownerId)) { var identity = PlayerUtils.GetIdentityById(ownerId); var lastSeenDate = PlayerUtils.GetLastSeenDate(identity); daysInactive = (today - lastSeenDate).Days; if (checkFaction) { var faction = FactionUtils.GetPlayerFaction(ownerId); if (faction != null) { foreach (long member in faction.Members.Keys) { identity = PlayerUtils.GetIdentityById(member); lastSeenDate = PlayerUtils.GetLastSeenDate(identity); daysInactive = Math.Min(daysInactive, (today - lastSeenDate).Days); } } } } return(new KeyValuePair <long, List <MyCubeGrid> >(daysInactive, gridsList)); }
internal static void DebugDrawBlockGroups <TNode, TGroupData>(MyGroups <TNode, TGroupData> groups) where TNode : MySlimBlock where TGroupData : IGroupData <TNode>, new() { int num = 0; using (HashSet <MyGroups <TNode, TGroupData> .Group> .Enumerator enumerator = groups.Groups.GetEnumerator()) { while (enumerator.MoveNext()) { num++; Color colorFrom = new Vector3(((float)(num % 15)) / 15f, 1f, 1f).HSVtoColor(); HashSetReader <MyGroups <TNode, TGroupData> .Node> nodes = enumerator.Current.Nodes; foreach (MyGroups <TNode, TGroupData> .Node node in nodes) { try { BoundingBoxD xd; node.NodeData.GetWorldBoundingBox(out xd, false); SortedDictionaryValuesReader <long, MyGroups <TNode, TGroupData> .Node> children = node.Children; foreach (MyGroups <TNode, TGroupData> .Node node2 in children) { m_tmpBlocksDebugHelper.Add(node2); } foreach (object obj2 in m_tmpBlocksDebugHelper) { BoundingBoxD xd2; MyGroups <TNode, TGroupData> .Node node3 = null; int num2 = 0; children = node.Children; foreach (MyGroups <TNode, TGroupData> .Node node4 in children) { if (obj2 == node4) { node3 = node4; num2++; } } node3.NodeData.GetWorldBoundingBox(out xd2, false); MyRenderProxy.DebugDrawLine3D(xd.Center, xd2.Center, colorFrom, colorFrom, false, false); MyRenderProxy.DebugDrawText3D((xd.Center + xd2.Center) * 0.5, num2.ToString(), colorFrom, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } Color color = new Color(colorFrom.ToVector3() + 0.25f); MyRenderProxy.DebugDrawSphere(xd.Center, 0.2f, color.ToVector3(), 0.5f, false, true, true, false); MyRenderProxy.DebugDrawText3D(xd.Center, node.LinkCount.ToString(), color, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, -1, false); } finally { m_tmpBlocksDebugHelper.Clear(); } } } } }
private KeyValuePair <long, List <MyCubeGrid> > CheckGroupsDistance(Vector3D origin, HashSetReader <MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Node> nodes, GridsBroadcastConfig config) { List <MyCubeGrid> gridsList = new List <MyCubeGrid>(); double distance = 0; foreach (var groupNodes in nodes) { MyCubeGrid cubeGrid = groupNodes.NodeData; if (cubeGrid.Physics == null) { continue; } if (!IsGridInsideFilter(cubeGrid, config)) { continue; } gridsList.Add(cubeGrid); var gridPositon = cubeGrid.PositionComp.GetPosition(); double distanceSquared = Vector3D.DistanceSquared(origin, gridPositon); distance = Math.Max(distance, distanceSquared); } return(new KeyValuePair <long, List <MyCubeGrid> >((long)Math.Sqrt(distance), gridsList)); }