private bool AddPotentialBlock(IMySlimBlock block, bool remote = false, NaniteAreaBeacon beacon = null) { if (TargetList.Contains(block)) { return(false); } if (!remote && block.FatBlock != null && block.FatBlock is IMyTerminalBlock && block.FatBlock.OwnerId != 0) { IMyTerminalBlock terminal = (IMyTerminalBlock)block.FatBlock; MyRelationsBetweenPlayerAndBlock relation = terminal.GetUserRelationToOwner(m_constructionBlock.ConstructionBlock.OwnerId); if (relation == MyRelationsBetweenPlayerAndBlock.Neutral || relation == MyRelationsBetweenPlayerAndBlock.Enemies) { return(false); } } else if (remote) { //if (block.CubeGrid.BigOwners.Count < 1) // return false; foreach (var item in block.CubeGrid.BigOwners) { MyRelationsBetweenPlayerAndBlock relation = m_constructionBlock.ConstructionBlock.GetUserRelationToOwner(item); if (relation == MyRelationsBetweenPlayerAndBlock.Neutral || relation == MyRelationsBetweenPlayerAndBlock.Enemies) { return(false); } } } if (!block.IsFullIntegrity || block.HasDeformation) { using (Lock.AcquireExclusiveUsing()) { if (beacon != null) { if (!m_areaTargetBlocks.ContainsKey(block)) { m_areaTargetBlocks.Add(block, beacon); } else { m_areaTargetBlocks[block] = beacon; } } PotentialTargetList.Add(block); return(true); } } return(false); }
public void showRange(float size) { Color colour; var relations = _tblock.GetUserRelationToOwner(MyAPIGateway.Session.Player.PlayerID); if (relations == MyRelationsBetweenPlayerAndBlock.Owner || relations == MyRelationsBetweenPlayerAndBlock.FactionShare) { colour = Color.FromNonPremultiplied(16, 255, 32, 64); } else { colour = Color.FromNonPremultiplied(255, 96, 16, 64); } MyStringId RangeGridResourceId = MyStringId.GetOrCompute("Build new"); var matrix = _tblock.WorldMatrix; MySimpleObjectDraw.DrawTransparentSphere(ref matrix, size, ref colour, MySimpleObjectRasterizer.Solid, 20, null, RangeGridResourceId, 0.25f, -1); }
private bool isHackable(IMyTerminalBlock block) { return(block.IsFunctional && block.GetUserRelationToOwner(thisBlock.OwnerId) == MyRelationsBetweenPlayerAndBlock.Enemies); }
public static Vector3D BubbleShieldCheck(Vector3D fromCoords, Vector3D toCoords, IMyTerminalBlock sourceWeapon, out string bubbleEntityIdString) { bubbleEntityIdString = ""; if (DefenseShieldModCheck == false) { DefenseShieldModCheck = true; var shieldBlockDefinitionId = new MyDefinitionId(typeof(MyObjectBuilder_UpgradeModule), "EmitterL"); var shieldBlockDefinition = MyDefinitionManager.Static.GetDefinition(shieldBlockDefinitionId); if (shieldBlockDefinition == null) { return(Vector3D.Zero); } DefenseShieldModActive = true; } if (DefenseShieldModActive == false) { return(Vector3D.Zero); } var entityList = new List <MyLineSegmentOverlapResult <MyEntity> >(); var line = new LineD(fromCoords, toCoords); MyGamePruningStructure.GetAllEntitiesInRay(ref line, entityList); foreach (var listItem in entityList) { if (listItem.Element.Physics == null && listItem.Element.DisplayName == "dShield") { if (listItem.Element.Render.Visible == false) { continue; } long targetGridEntityId = 0; IMyEntity targetGridEntity = null; if (string.IsNullOrEmpty(listItem.Element.Name) == true) { continue; } if (long.TryParse(listItem.Element.Name, out targetGridEntityId) == false) { continue; } if (MyAPIGateway.Entities.TryGetEntityById(targetGridEntityId, out targetGridEntity) == false) { continue; } var targetGrid = targetGridEntity as IMyCubeGrid; if (targetGrid == null) { continue; } bool hostile = false; foreach (var owner in targetGrid.BigOwners) { if (owner == 0) { continue; } var relation = sourceWeapon.GetUserRelationToOwner(owner); if (relation == MyRelationsBetweenPlayerAndBlock.Enemies || relation == MyRelationsBetweenPlayerAndBlock.Neutral || relation == MyRelationsBetweenPlayerAndBlock.NoOwnership) { hostile = true; break; } } if (hostile == false) { continue; } bubbleEntityIdString = listItem.Element.Name; Vector3D returnCoords = Vector3D.Normalize(toCoords - fromCoords) * listItem.Distance + fromCoords; var sphereHitCoords = DsRayCast(listItem.Element as IMyEntity, line, sourceWeapon.EntityId, 0, MyStringId.GetOrCompute("Laser")); if (sphereHitCoords != null) { returnCoords = (Vector3D)sphereHitCoords; } return(returnCoords); } } return(Vector3D.Zero); }