private bool GridOwnsController() { var notTime = _tick != 0 && _tick % 600 != 0; if (notTime && !DsState.State.ControllerGridAccess) { return(false); } if (notTime) { return(true); } var myGridBigOwners = MyGrid.BigOwners; if (myGridBigOwners.Count == 0) { DsState.State.ControllerGridAccess = false; return(false); } if (MyCube.OwnerId == 0) { MyCube.ChangeOwner(myGridBigOwners[0], MyOwnershipShareModeEnum.Faction); } var controlToGridRelataion = MyCube.GetUserRelationToOwner(myGridBigOwners[0]); DsState.State.InFaction = controlToGridRelataion == MyRelationsBetweenPlayerAndBlock.FactionShare; DsState.State.IsOwner = controlToGridRelataion == MyRelationsBetweenPlayerAndBlock.Owner; if (controlToGridRelataion != MyRelationsBetweenPlayerAndBlock.Owner && controlToGridRelataion != MyRelationsBetweenPlayerAndBlock.FactionShare) { if (DsState.State.ControllerGridAccess) { DsState.State.ControllerGridAccess = false; Shield.RefreshCustomInfo(); if (Session.Enforced.Debug == 4) { Log.Line($"GridOwner: controller is not owned: {ShieldMode} - ShieldId [{Shield.EntityId}]"); } } DsState.State.ControllerGridAccess = false; return(false); } if (!DsState.State.ControllerGridAccess) { DsState.State.ControllerGridAccess = true; Shield.RefreshCustomInfo(); if (Session.Enforced.Debug == 4) { Log.Line($"GridOwner: controller is owned: {ShieldMode} - ShieldId [{Shield.EntityId}]"); } } DsState.State.ControllerGridAccess = true; return(true); }
public bool GridEnemy(MyCubeGrid grid, List <long> owners = null) { if (owners == null) { owners = grid.BigOwners; } if (owners.Count == 0) { return(true); } var relationship = MyCube.GetUserRelationToOwner(owners[0]); var enemy = relationship != MyRelationsBetweenPlayerAndBlock.Owner && relationship != MyRelationsBetweenPlayerAndBlock.FactionShare; return(enemy); }
private void GridOwnsController() { if (MyGrid.BigOwners.Count == 0) { DsState.State.ControllerGridAccess = false; return; } _gridOwnerId = MyGrid.BigOwners[0]; _controllerOwnerId = MyCube.OwnerId; if (_controllerOwnerId == 0) { MyCube.ChangeOwner(_gridOwnerId, MyOwnershipShareModeEnum.Faction); } var controlToGridRelataion = MyCube.GetUserRelationToOwner(_gridOwnerId); DsState.State.InFaction = controlToGridRelataion == MyRelationsBetweenPlayerAndBlock.FactionShare; DsState.State.IsOwner = controlToGridRelataion == MyRelationsBetweenPlayerAndBlock.Owner; if (controlToGridRelataion != MyRelationsBetweenPlayerAndBlock.Owner && controlToGridRelataion != MyRelationsBetweenPlayerAndBlock.FactionShare) { if (DsState.State.ControllerGridAccess) { DsState.State.ControllerGridAccess = false; Shield.RefreshCustomInfo(); if (Session.Enforced.Debug == 4) { Log.Line($"GridOwner: controller is not owned: {ShieldMode} - ShieldId [{Shield.EntityId}]"); } } DsState.State.ControllerGridAccess = false; return; } if (!DsState.State.ControllerGridAccess) { DsState.State.ControllerGridAccess = true; Shield.RefreshCustomInfo(); if (Session.Enforced.Debug == 4) { Log.Line($"GridOwner: controller is owned: {ShieldMode} - ShieldId [{Shield.EntityId}]"); } } DsState.State.ControllerGridAccess = true; }
public Ent EntType(MyEntity ent) { if (ent is IMyFloatingObject) { if (CustomCollision.AllAabbInShield(ent.PositionComp.WorldAABB, DetectMatrixOutsideInv, _obbCorners)) { return(Ent.Ignore); } return(Ent.Floater); } var voxel = ent as MyVoxelBase; if (voxel != null && (Session.Enforced.DisableVoxelSupport == 1 || ShieldComp.Modulator == null || ShieldComp.Modulator.ModSet.Settings.ModulateVoxels || !GridIsMobile)) { return(Ent.Ignore); } if (EntityBypass.Contains(ent)) { return(Ent.Ignore); } var character = ent as IMyCharacter; if (character != null) { var dude = MyAPIGateway.Players.GetPlayerControllingEntity(ent)?.IdentityId; if (dude == null) { return(Ent.Ignore); } var playerrelationship = MyCube.GetUserRelationToOwner((long)dude); if (playerrelationship == MyRelationsBetweenPlayerAndBlock.Owner || playerrelationship == MyRelationsBetweenPlayerAndBlock.FactionShare) { var playerInShield = CustomCollision.PointInShield(ent.PositionComp.WorldAABB.Center, DetectMatrixOutsideInv); return(playerInShield ? Ent.Protected : Ent.Friendly); } if (character.IsDead) { return(Ent.Ignore); } if (CustomCollision.NewObbPointsInShield(ent, DetectMatrixOutsideInv, _obbPoints) == 9) { return(Ent.EnemyInside); } return(Ent.EnemyPlayer); } var grid = ent as MyCubeGrid; if (grid != null) { ModulateGrids = (ShieldComp.Modulator != null && ShieldComp.Modulator.ModSet.Settings.ModulateGrids) || Session.Enforced.DisableEntityBarrier == 1; ModulatorGridComponent modComp; grid.Components.TryGet(out modComp); if (!string.IsNullOrEmpty(modComp?.ModulationPassword) && modComp.ModulationPassword == Shield.CustomData) { var modShield = modComp.Modulator?.ShieldComp?.DefenseShields; if (modShield != null) { lock (modShield.SubLock) { foreach (var subGrid in modShield.ShieldComp.SubGrids) { if (ShieldEnt.PositionComp.WorldVolume.Intersects(grid.PositionComp.WorldVolume)) { if (CustomCollision.CornerOrCenterInShield(grid, DetectMatrixOutsideInv, _resetEntCorners) > 0) { return(Ent.Protected); } AuthenticatedCache.Add(subGrid); } else { AuthenticatedCache.Add(subGrid); } } } return(Ent.Authenticated); } foreach (var subGrid in modComp.SubGrids) { if (ShieldEnt.PositionComp.WorldVolume.Intersects(grid.PositionComp.WorldVolume)) { if (CustomCollision.CornerOrCenterInShield(grid, DetectMatrixOutsideInv, _resetEntCorners) > 0) { return(Ent.Protected); } AuthenticatedCache.Add(subGrid); } else { AuthenticatedCache.Add(subGrid); } } } var bigOwners = grid.BigOwners; var bigOwnersCnt = bigOwners.Count; if (CustomCollision.AllAabbInShield(ent.PositionComp.WorldAABB, DetectMatrixOutsideInv, _obbCorners)) { return(Ent.Protected); } if (!ModulateGrids && bigOwnersCnt == 0) { return(Ent.NobodyGrid); } var enemy = !ModulateGrids && GridEnemy(grid, bigOwners); if (!enemy) { lock (SubLock) if (ShieldComp.SubGrids.Contains(grid)) { return(Ent.Protected); } var pointsInShield = CustomCollision.NewObbPointsInShield(grid, DetectMatrixOutsideInv, _obbPoints); return(pointsInShield > 0 ? Ent.Protected : Ent.Friendly); } ShieldGridComponent shieldComponent; grid.Components.TryGet(out shieldComponent); if (shieldComponent?.DefenseShields?.ShieldComp != null && shieldComponent.DefenseShields.NotFailed) { var dsComp = shieldComponent.DefenseShields; var shieldEntity = MyCube.Parent; dsComp.EnemyShields.Add(shieldEntity); return(Ent.Shielded); } return(Ent.EnemyGrid); } if (ent is IMyMeteor || (ent.DefinitionId.HasValue && ent.DefinitionId.Value.TypeId == Session.Instance.MissileObj)) { return(Ent.Other); } if (voxel != null && GridIsMobile) { return(Ent.VoxelBase); } return(0); }