public override bool HandleCommand(ulong userId, string[] words) { GridLinkTypeEnum connectionType = GridLinkTypeEnum.Logical; if (words.FirstOrDefault(x => x.ToLower( ) == "physical") != null) { connectionType = GridLinkTypeEnum.Physical; } HashSet <GridGroup> groups = GridGroup.GetAllGroups(connectionType); int groupsCount = 0; int gridsCount = 0; foreach (GridGroup group in groups) { if (!group.CubeBlocks.Any(x => x?.FatBlock is IMyBeacon)) { groupsCount++; gridsCount += group.Grids.Count; group.Close( ); Communication.SendPrivateInformation(userId, $"Found group with parent {group.Parent.DisplayName} ({group.Parent.EntityId}) at {group.Parent.PositionComp.GetPosition( )} with no beacon."); } } Communication.SendPrivateInformation(userId, $"Removed {gridsCount} grids in {groupsCount} groups with no beacon."); return(true); }
public IEnumerator LoadItemList(System.Action LoadAction) { CocoMainController.Instance.TouchEnable = false; ScrollRect.enabled = false; RectTransform rectTrans = GridGroup.GetComponent <RectTransform>(); CCAction.MoveLocalY(GridGroup.gameObject, -768, 0.3f); yield return(new WaitForSeconds(0.3f)); Clear(); yield return(new WaitForEndOfFrame()); GridGroup.enabled = true; if (LoadAction != null) { LoadAction(); } yield return(new WaitForEndOfFrame()); CCAction.MoveLocalY(GridGroup.gameObject, 0, 0.3f); yield return(new WaitForSeconds(0.3f)); ScrollRect.enabled = true; CocoMainController.Instance.TouchEnable = true; }
private void InitView() { GameObject roomGO = Instantiate(Resources.Load("Prefabs/Room")) as GameObject; room = roomGO.GetComponent <Room>(); room.Init(roomSize); camera = Camera.main.GetComponent <RoomCamera>(); camera.Init(); camera.OnCameraRotate = HandleCameraRotate; camera.SetCameraTransform(); GameObject gridGO = Instantiate(Resources.Load("Prefabs/GridGroup")) as GameObject; gridGroup = gridGO.GetComponent <GridGroup>(); gridGroup.Init(); // TODO isRestricted = true; }
private void OnGUI() { GUILayout.Label("Queue:"); BattleLogic logic = BattleLogic.battleLogic; if (logic != null) { string s0 = " BattleQueue: "; for (int i = 0; i < logic.BattleQueue.Count; i++) { s0 += logic.BattleQueue[i].Method.Name; } GUILayout.Label(s0); string s1 = " MyTurnQueue: "; for (int i = 0; i < logic.MyturnQueue.Count; i++) { s1 += logic.MyturnQueue[i].unityAction.Method.Name; } GUILayout.Label(s1); string s2 = " NextTurnQueue: "; for (int i = 0; i < logic.NextTurnQueue.Count; i++) { s2 += logic.NextTurnQueue[i].unityAction.Method.Name; } GUILayout.Label(s2); } GUILayout.Label("Enemies:"); if (BattleControll.battleControll != null) { GridGroup gridGroup = BattleControll.battleControll.enemyUnitsParent; selectedPopup = EditorGUILayout.Popup("GridType", selectedPopup, new string[] { "UnitNames", "UnitAvailability", "MissChanse", "MissChanseOnMe", "CanAttack" }); for (int y = 0; y < gridGroup.units.GetLength(1); y++) { string s = ""; for (int x = 0; x < gridGroup.units.GetLength(0); x++) { if (selectedPopup == 0) { s += (gridGroup.units[x, y] != null) ? gridGroup.units[x, y].UnitName + " " : " _ "; } else if (selectedPopup == 1) { s += (gridGroup.units[x, y] != null) ? gridGroup.units[x, y].unitlogic.HasBlocked() + " " : " ___ "; } else if (selectedPopup == 2) { s += (gridGroup.units[x, y] != null) ? gridGroup.units[x, y].unitlogic.MissChanse(BattleControll.heroLogic.unitlogic) + " " : " _ "; } else if (selectedPopup == 3) { s += (gridGroup.units[x, y] != null) ? BattleControll.heroLogic.unitlogic.MissChanse(gridGroup.units[x, y].unitlogic) + " " : " _ "; } else { s += (gridGroup.units[x, y] != null) ? gridGroup.units[x, y].unitlogic.CanAttack(BattleControll.heroLogic) + " " : " ___ "; } } GUILayout.Label(" " + s); } } }
/// <summary> /// Creates the daigram /// </summary> /// <param name="businessType">Type of the List to be added</param> private void CreateDiagram(string businessType) { RectangleF rect = new RectangleF(10, 10, 1400, 60); TextNode nodeRectHeader = new TextNode("Safety", rect); nodeRectHeader.BackgroundStyle.Color = Color.FromArgb(84, 167, 167); nodeRectHeader.LineStyle.LineWidth = 1; nodeRectHeader.FontStyle.Size = 32; nodeRectHeader.FontStyle.Bold = true; nodeRectHeader.FontStyle.Italic = true; nodeRectHeader.FontColorStyle.Color = Color.White; nodeRectHeader.ReadOnly = true; nodeRectHeader.HorizontalAlignment = StringAlignment.Near; nodeRectHeader.VerticalAlignment = StringAlignment.Center; nodeRectHeader.EditStyle.AllowSelect = false; //FY10 goal is to provide a safe working environment for our employees.Achieve this through improvement in the key categorie of severity and frequency rates. EllipseRectGroup erg = new EllipseRectGroup(1, "Vision", "Vision-1", Color.Red, Color.Black, Color.LightBlue, Color.White); GridGroup gg = new GridGroup(); HeaderandEllipse he1 = new HeaderandEllipse(2, "Goals", Color.Red, Color.LightBlue, 13); HeaderandEllipse he2 = new HeaderandEllipse(3, "Objectives", Color.Red, Color.LightBlue, 13); HeaderandEllipse he3 = new HeaderandEllipse(4, "Key Tasks", Color.Red, Color.LightBlue, 12); SplitContent spc = new SplitContent("Who \n(leader)", "Resources Investor", Color.LightBlue, true, 12, true); GridGroupShapesandNumber ggsn = new GridGroupShapesandNumber("Schedule(Month)", Color.LightBlue); SplitContent spc2 = new SplitContent("Comments", "Cost Savings", Color.LightBlue, true, 12, true); int nameIndex = 0; List <HoshinKanriListItem> hoshinList = GenerateList(businessType); float contentPinPointY = 400, splitContentPinpointY = 400, gridSymbolPinpointY = 390, subContentPinPointY = 400; for (int i = 0; i < hoshinList.Count; i++) { ContentRectangle content = new ContentRectangle(hoshinList[i].Content, Color.Black, Color.LightGreen, false, 13, true); content.PinPoint = new PointF(10 + content.BoundingRectangle.Width / 2, contentPinPointY + content.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(content); ContentRectangle content1 = new ContentRectangle(hoshinList[i].Content1, Color.Black, Color.LightGreen, false, 10, true); content1.PinPoint = new PointF(230 + content1.BoundingRectangle.Width / 2, contentPinPointY + content1.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(content1); lineconnector = getLineConnectorOrdinary(content.PinPoint, content1.PinPoint); content.CentralPort.TryConnect(lineconnector.HeadEndPoint); content1.CentralPort.TryConnect(lineconnector.TailEndPoint); this.diagram1.Model.AppendChild(lineconnector); for (int j = 0; j < hoshinList[i].Leader.Count; j++) { SplitContent splitContent = new SplitContent(hoshinList[i].Leader[j], hoshinList[i].Resources[j], Color.Gray, false, 10, false); splitContent.Name = "splitContent" + (nameIndex + 1); splitContent.PinPoint = new PointF(690 + splitContent.BoundingRectangle.Width / 2, splitContentPinpointY + splitContent.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(splitContent); GridSymbols gridSymbol = new GridSymbols(hoshinList[i].Plan[j], hoshinList[i].Actual[j], hoshinList[i].ToolTip[j]); gridSymbol.Name = "gridSymbol" + (nameIndex + 1); gridSymbol.PinPoint = new PointF(920 + gridSymbol.BoundingRectangle.Width / 2, 2 + gridSymbolPinpointY + gridSymbol.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(gridSymbol); SplitContent splitContent1 = new SplitContent(hoshinList[i].Comments[j], hoshinList[i].CostSavings[j], Color.LightGray, false, 10, false); splitContent1.Name = "splitContent1" + (nameIndex + 1); splitContent1.PinPoint = new PointF(1160 + splitContent1.BoundingRectangle.Width / 2, splitContentPinpointY + splitContent1.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(splitContent1); if (!hoshinList[i].IsOuterRectangle[j]) { ContentRectangle subContent = new ContentRectangle(hoshinList[i].SubContent[j], Color.Black, Color.LightGreen, false, 10, true); subContent.PinPoint = new PointF(460 + subContent.BoundingRectangle.Width / 2, subContentPinPointY + subContent.BoundingRectangle.Height / 2); diagram1.Model.AppendChild(subContent); lineconnector = getLineConnectorOrdinary(content1.PinPoint, subContent.PinPoint); content1.CentralPort.TryConnect(lineconnector.TailEndPoint); subContent.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnectorOrdinary(subContent.PinPoint, splitContent.PinPoint); splitContent.CentralPort.TryConnect(lineconnector.TailEndPoint); subContent.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); } else { ContentWithOuterRectangle subContent1 = new ContentWithOuterRectangle(hoshinList[i].SubContent[j], "A3", Color.LightGreen, Color.Pink); subContent1.PinPoint = new PointF(460 + subContent1.BoundingRectangle.Width / 2, subContentPinPointY + subContent1.BoundingRectangle.Height / 2 - 20); diagram1.Model.AppendChild(subContent1); orthogoanlConnector = getOrthogonalConnector(content1.PinPoint, subContent1.PinPoint); content1.CentralPort.TryConnect(orthogoanlConnector.TailEndPoint); subContent1.CentralPort.TryConnect(orthogoanlConnector.HeadEndPoint); this.diagram1.Model.AppendChild(orthogoanlConnector); lineconnector = getLineConnectorOrdinary(subContent1.PinPoint, splitContent.PinPoint); splitContent.CentralPort.TryConnect(lineconnector.TailEndPoint); subContent1.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); } nameIndex++; //if (!hoshinList[i].IsOuterRectangle[j]) //{ // contentPinPointY += 65; // splitContentPinpointY += 65; gridSymbolPinpointY += 65; subContentPinPointY += 65; //} //else //{ //} contentPinPointY += 85; splitContentPinpointY += 85; gridSymbolPinpointY += 85; subContentPinPointY += 85; //if (j < hoshinList[i].Leader.Count) //{ // if (hoshinList[i].IsOuterRectangle[j]) // { // contentPinPointY += (120-85); // splitContentPinpointY += (130 - 85); gridSymbolPinpointY += (130 - 85); subContentPinPointY += (120 - 85); // } //} } } HeaderRectangleActual actualrect = new HeaderRectangleActual(); HeaderRectanglePlan planrect = new HeaderRectanglePlan(); erg.PinPoint = new PointF(10 + erg.BoundingRectangle.Width / 2, erg.BoundingRectangle.Height / 2 + 120); erg.CentralPort.OffsetX = he1.PinPoint.X; he1.PinPoint = new PointF(10 + he1.BoundingRectangle.Width / 2, 330 + he1.BoundingRectangle.Height / 2); he2.PinPoint = new PointF(230 + he2.BoundingRectangle.Width / 2, 330 + he2.BoundingRectangle.Height / 2); he3.PinPoint = new PointF(460 + he3.BoundingRectangle.Width / 2, 330 + he3.BoundingRectangle.Height / 2); spc.PinPoint = new PointF(690 + spc.BoundingRectangle.Width / 2, 330 + spc.BoundingRectangle.Height / 2); ggsn.PinPoint = new PointF(920 + ggsn.BoundingRectangle.Width / 2, 330 + ggsn.BoundingRectangle.Height / 2); spc2.PinPoint = new PointF(1160 + spc2.BoundingRectangle.Width / 2, 330 + spc2.BoundingRectangle.Height / 2); actualrect.PinPoint = new PointF(630 + actualrect.BoundingRectangle.Width / 2, actualrect.BoundingRectangle.Height / 2 + 103); planrect.PinPoint = new PointF(400 + planrect.BoundingRectangle.Width / 2, planrect.BoundingRectangle.Height / 2 + 103); gg.PinPoint = new PointF(900 + gg.BoundingRectangle.Width / 2, gg.BoundingRectangle.Height / 2 + 143); this.diagram1.Model.AppendChild(erg); this.diagram1.Model.AppendChild(gg); this.diagram1.Model.AppendChild(ggsn); this.diagram1.Model.AppendChild(he1); this.diagram1.Model.AppendChild(he2); this.diagram1.Model.AppendChild(he3); this.diagram1.Model.AppendChild(spc); this.diagram1.Model.AppendChild(spc2); this.diagram1.Model.AppendChild(planrect); this.diagram1.Model.AppendChild(actualrect); this.diagram1.Model.AppendChild(nodeRectHeader); lineconnector = getLineConnector(erg.PinPoint, he1.PinPoint); erg.CentralPort.TryConnect(lineconnector.TailEndPoint); he1.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnector(he1.PinPoint, he2.PinPoint); he1.CentralPort.TryConnect(lineconnector.TailEndPoint); he2.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnector(he2.PinPoint, he3.PinPoint); he2.CentralPort.TryConnect(lineconnector.TailEndPoint); he3.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); lineconnector = getLineConnector(he3.PinPoint, spc.PinPoint); he3.CentralPort.TryConnect(lineconnector.TailEndPoint); spc.CentralPort.TryConnect(lineconnector.HeadEndPoint); this.diagram1.Model.AppendChild(lineconnector); }
public override bool HandleCommand(ulong userId, string[] words) { bool showConcealed = !(words.Length > 0 && words[0].ToLower() == "revealed"); if (words.Length > 0 && words[0].ToLower( ) == "force") { EntityManagement.CheckAndConcealEntities( ); return(true); } /* * if ( words.Length > 0 && words[0].ToLower( ) == "dialog" ) * { * //TODO: present entity list in a dialog * return true; * } */ if (showConcealed) { HashSet <MyEntity> entities = new HashSet <MyEntity>(); Wrapper.GameAction(() => { entities = MyEntities.GetEntities(); }); Communication.SendPrivateInformation(userId, "==== Concealed Entities ==="); int count = 0; foreach (MyEntity entity in entities) { if (!EntityManagement.RemovedGrids.Contains(entity.EntityId)) { continue; } MyCubeGrid grid = (MyCubeGrid)entity; long ownerId = 0; string ownerName = ""; if (grid.BigOwners.Count > 0) { ownerId = grid.BigOwners.First(); ownerName = PlayerMap.Instance.GetPlayerNameFromPlayerId(ownerId); } Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.PositionComp.GetPosition()))); count++; } Communication.SendPrivateInformation(userId, string.Format("Total concealed entities: {0}", count)); } else { HashSet <IMyEntity> entities = new HashSet <IMyEntity>(); Wrapper.GameAction(() => { MyAPIGateway.Entities.GetEntities(entities); }); Communication.SendPrivateInformation(userId, "==== Revealed Entities ==="); Communication.SendPrivateInformation(userId, "==== Unconnected Entities ==="); HashSet <IMyEntity> entitiesFound = new HashSet <IMyEntity>(); //CubeGrids.GetGridsUnconnected(entitiesFound, entities); int count = 0; foreach (IMyEntity entity in entitiesFound) { if (!(entity is MyCubeGrid)) { continue; } if (!entity.InScene) { continue; } MyCubeGrid grid = (MyCubeGrid)entity; long ownerId = 0; string ownerName = ""; if (grid.BigOwners.Count > 0) { ownerId = grid.BigOwners.First(); ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name; } if (ownerName == "") { ownerName = "No one"; } Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4} BlockCount: {5}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.GetPosition()), grid.BlocksCount)); count++; } Communication.SendPrivateInformation(userId, string.Format("Total unconnected revealed entities: {0}", count)); Communication.SendPrivateInformation(userId, "==== Connected Entities ==="); var groups = GridGroup.GetAllGroups(GridLinkTypeEnum.Logical); //Console.WriteLine("Here: {0} : {1} {2}", connectedFound.Intersect(entitiesFound).Count(), entitiesFound.Count, connectedFound.Count); count = 0; foreach (var group in groups) { foreach (MyCubeGrid grid in group.Grids) { MyEntity entity = (MyEntity)grid; if (entitiesFound.Contains(entity)) { continue; } if (!entity.InScene) { continue; } if (group.Grids.Count < 2) { continue; } long ownerId = 0; string ownerName = ""; if (grid.BigOwners.Count > 0) { ownerId = grid.BigOwners.First( ); ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId(ownerId).Name; } if (ownerName == "") { ownerName = "No one"; } Communication.SendPrivateInformation(userId, $"Id: {entity.EntityId} Display: {entity.DisplayName} OwnerId: {ownerId} OwnerName: {ownerName} Position: {grid.PositionComp.GetPosition( )} BlockCount: {grid.BlocksCount} Connections: {@group.Grids.Count}"); //Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4} BlockCount: {5} Connections: {6}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.GetPosition()), slimBlocks.Count)); count++; } } Communication.SendPrivateInformation(userId, string.Format("Total connected revealed entities: {0}", count)); } return(true); }
//public static HashSet<MyEntity> UnregisteredEntities = new HashSet<MyEntity>(); public static void CheckAndConcealEntities( ) { if (_checkConceal) { return; } _checkConceal = true; try { List <MyPlayer> players; try { players = MySession.Static.Players.GetOnlinePlayers().ToList(); } catch (Exception ex) { Essentials.Log.Error(ex, "Error getting players list. Check and Conceal failed: {0}"); return; } foreach (GridGroup group in GridGroup.GetAllGroups(GridLinkTypeEnum.Logical)) { //we're using grid groups so that multi-part pirate ships don't lose pieces if (!PluginSettings.Instance.DynamicConcealPirates) { if (group.Parent.GetOwner() == "Space Pirates") { if (PluginSettings.Instance.DynamicShowMessages) { Essentials.Log.Info($"Not concealing pirate owned grid {group.Parent.EntityId} -> {group.Parent.DisplayName}."); } continue; } } foreach (MyCubeGrid grid in group.Grids) { if (grid.Physics == null) //projection { continue; } //if ( UnregisteredEntities.Contains( (MyEntity)grid ) ) // continue; if (RemovedGrids.Contains(grid.EntityId)) { continue; } if (grid.GridSizeEnum != MyCubeSize.Small) { if (grid.IsStatic && !PluginSettings.Instance.ConcealIncludeStations) { continue; } if (!PluginSettings.Instance.ConcealIncludeLargeGrids) { continue; } } if (players.Any(x => Vector3D.Distance(x.GetPosition(), grid.PositionComp.GetPosition()) < PluginSettings.Instance.DynamicConcealDistance)) { continue; } if (ProcessDockingZone.ZoneCache.Any(x => Vector3D.Distance(x.GetPosition(), grid.PositionComp.GetPosition()) < 100)) { continue; } if (CheckConcealBlockRules(grid)) { continue; } ConcealEntity(grid); } } } catch (Exception ex) { Essentials.Log.Error(ex); } finally { _checkConceal = false; } }