├── .gitignore ├── CHANGELOG.md ├── Concealment.Tests ├── Concealment.Tests.csproj ├── Properties │ └── AssemblyInfo.cs ├── ReflectionTestManager.cs ├── TestUtils.cs ├── TorchReflectionTest.cs └── packages.config ├── Concealment.sln ├── Concealment ├── Commands.cs ├── ConcealGroup.cs ├── Concealment.csproj ├── ConcealmentControl.xaml ├── ConcealmentControl.xaml.cs ├── ConcealmentPlugin.cs ├── DynamicConcealmentEditor.xaml ├── DynamicConcealmentEditor.xaml.cs ├── DynamicConcealmentManager.cs ├── Properties │ └── AssemblyInfo.cs ├── Settings.cs └── packages.config ├── Jenkins ├── PluginPush.exe ├── jenkins-grab-se.ps1 └── release.ps1 ├── Jenkinsfile ├── README.md ├── Setup (run before opening solution).bat ├── Versioning ├── AssemblyVersion.cs └── version.ps1 └── manifest.xml /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | 254 | GameBinaries 255 | TorchBinaries -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Concealment 1.2.1 2 | * Fixes 3 | - Fixed off-by-one crash in RevealGrids() 4 | 5 | # Concealment 1.2 6 | * Features 7 | - Added option to exempt pirate-owned grids 8 | - Added action to RC block so scripts can keep active drones from being concealed 9 | - Added commands to enable and disable concealment 10 | * Fixes 11 | - Fixed crashes when deleting concealed entities -------------------------------------------------------------------------------- /Concealment.Tests/Concealment.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {53EFDFD0-9BCA-4E67-ABB2-628715E3F74B} 6 | Library 7 | Properties 8 | Concealment.Tests 9 | Concealment.Tests 10 | v4.6.1 11 | 512 12 | 13 | 14 | 15 | 1591,0649 16 | 17 | 18 | true 19 | $(SolutionDir)\bin-test\x64\Debug\ 20 | DEBUG;TRACE 21 | full 22 | x64 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | $(SolutionDir)\bin-test\x64\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | x64 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | $(SolutionDir)\bin-test\x64\Release\Concealment.Tests.xml 35 | 36 | 37 | 38 | ..\packages\NLog.4.4.12\lib\net45\NLog.dll 39 | True 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | ..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll 51 | 52 | 53 | ..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll 54 | 55 | 56 | ..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll 57 | 58 | 59 | ..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll 60 | 61 | 62 | $(SolutionDir)\TorchBinaries\Torch.dll 63 | True 64 | 65 | 66 | $(SolutionDir)\TorchBinaries\Torch.API.dll 67 | True 68 | 69 | 70 | 71 | 72 | Properties\AssemblyVersion.cs 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | {E5C0184B-7DC4-43D8-872E-2F71162748AA} 82 | Concealment 83 | True 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /Concealment.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Torch Tests")] 5 | [assembly: AssemblyDescription("")] 6 | [assembly: AssemblyCompany("")] 7 | [assembly: AssemblyProduct("Torch")] 8 | [assembly: AssemblyCopyright("Copyright © Torch API 2017")] 9 | [assembly: AssemblyTrademark("")] 10 | [assembly: AssemblyCulture("")] 11 | [assembly: ComVisible(false)] 12 | 13 | #if DEBUG 14 | [assembly: AssemblyConfiguration("Debug")] 15 | #else 16 | [assembly: AssemblyConfiguration("Release")] 17 | #endif -------------------------------------------------------------------------------- /Concealment.Tests/ReflectionTestManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using Torch.Utils; 5 | 6 | namespace Torch.Tests 7 | { 8 | public class ReflectionTestManager 9 | { 10 | #region FieldProvider 11 | public struct FieldRef 12 | { 13 | public FieldInfo Field; 14 | 15 | public FieldRef(FieldInfo f) 16 | { 17 | Field = f; 18 | } 19 | 20 | public override string ToString() 21 | { 22 | if (Field == null) 23 | return "Ignored"; 24 | return Field.DeclaringType?.FullName + "." + Field.Name; 25 | } 26 | } 27 | 28 | private readonly HashSet _getters = new HashSet(); 29 | private readonly HashSet _setters = new HashSet(); 30 | private readonly HashSet _invokers = new HashSet(); 31 | 32 | public ReflectionTestManager() 33 | { 34 | _getters.Add(new object[] { new FieldRef(null) }); 35 | _setters.Add(new object[] { new FieldRef(null) }); 36 | _invokers.Add(new object[] { new FieldRef(null) }); 37 | } 38 | 39 | public ReflectionTestManager Init(Assembly asm) 40 | { 41 | foreach (Type type in asm.GetTypes()) 42 | Init(type); 43 | return this; 44 | } 45 | 46 | public ReflectionTestManager Init(Type type) 47 | { 48 | foreach (FieldInfo field in type.GetFields(BindingFlags.Static | 49 | BindingFlags.Instance | 50 | BindingFlags.Public | 51 | BindingFlags.NonPublic)) 52 | { 53 | if (field.GetCustomAttribute() != null) 54 | _invokers.Add(new object[] { new FieldRef(field) }); 55 | if (field.GetCustomAttribute() != null) 56 | _getters.Add(new object[] { new FieldRef(field) }); 57 | if (field.GetCustomAttribute() != null) 58 | _setters.Add(new object[] { new FieldRef(field) }); 59 | } 60 | return this; 61 | } 62 | 63 | public IEnumerable Getters => _getters; 64 | 65 | public IEnumerable Setters => _setters; 66 | 67 | public IEnumerable Invokers => _invokers; 68 | 69 | #endregion 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Concealment.Tests/TestUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Torch.Utils; 8 | 9 | namespace Torch.Tests 10 | { 11 | public sealed class TestUtils 12 | { 13 | public static void Init() 14 | { 15 | if (_torchResolver == null) 16 | _torchResolver = new TorchAssemblyResolver(GetGameBinaries()); 17 | } 18 | 19 | private static string GetGameBinaries() 20 | { 21 | string dir = Environment.CurrentDirectory; 22 | while (!string.IsNullOrWhiteSpace(dir)) 23 | { 24 | string gameBin = Path.Combine(dir, "GameBinaries"); 25 | if (Directory.Exists(gameBin)) 26 | return gameBin; 27 | 28 | dir = Path.GetDirectoryName(dir); 29 | } 30 | throw new Exception("GetGameBinaries failed to find a folder named GameBinaries in the directory tree"); 31 | } 32 | 33 | private static TorchAssemblyResolver _torchResolver; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Concealment.Tests/TorchReflectionTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Runtime.CompilerServices; 7 | using System.Runtime.InteropServices; 8 | using Torch.Tests; 9 | using Torch.Utils; 10 | using Xunit; 11 | 12 | namespace Concealment.Tests 13 | { 14 | public class TorchReflectionTest 15 | { 16 | static TorchReflectionTest() 17 | { 18 | TestUtils.Init(); 19 | } 20 | 21 | private static ReflectionTestManager _manager; 22 | 23 | private static ReflectionTestManager Manager() 24 | { 25 | TestUtils.Init(); 26 | if (_manager != null) 27 | return _manager; 28 | return _manager = new ReflectionTestManager().Init(typeof(ConcealmentPlugin).Assembly); 29 | } 30 | 31 | public static IEnumerable Getters => Manager().Getters; 32 | 33 | public static IEnumerable Setters => Manager().Setters; 34 | 35 | public static IEnumerable Invokers => Manager().Invokers; 36 | 37 | #region Binding 38 | [Theory] 39 | [MemberData(nameof(Getters))] 40 | public void TestBindingGetter(ReflectionTestManager.FieldRef field) 41 | { 42 | if (field.Field == null) 43 | return; 44 | Assert.True(ReflectedManager.Process(field.Field)); 45 | if (field.Field.IsStatic) 46 | Assert.NotNull(field.Field.GetValue(null)); 47 | } 48 | 49 | [Theory] 50 | [MemberData(nameof(Setters))] 51 | public void TestBindingSetter(ReflectionTestManager.FieldRef field) 52 | { 53 | if (field.Field == null) 54 | return; 55 | Assert.True(ReflectedManager.Process(field.Field)); 56 | if (field.Field.IsStatic) 57 | Assert.NotNull(field.Field.GetValue(null)); 58 | } 59 | 60 | [Theory] 61 | [MemberData(nameof(Invokers))] 62 | public void TestBindingInvoker(ReflectionTestManager.FieldRef field) 63 | { 64 | if (field.Field == null) 65 | return; 66 | Assert.True(ReflectedManager.Process(field.Field)); 67 | if (field.Field.IsStatic) 68 | Assert.NotNull(field.Field.GetValue(null)); 69 | } 70 | #endregion 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Concealment.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Concealment.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.15 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concealment", "Concealment\Concealment.csproj", "{E5C0184B-7DC4-43D8-872E-2F71162748AA}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{57BAE926-D9EB-40F2-AC36-007A1E2ED296}" 9 | ProjectSection(SolutionItems) = preProject 10 | Versioning\AssemblyVersion.cs = Versioning\AssemblyVersion.cs 11 | EndProjectSection 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concealment.Tests", "Concealment.Tests\Concealment.Tests.csproj", "{53EFDFD0-9BCA-4E67-ABB2-628715E3F74B}" 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C6C2FDC8-9D1B-4A13-B586-7DAD7F9BE7BB}" 16 | ProjectSection(SolutionItems) = preProject 17 | manifest.xml = manifest.xml 18 | EndProjectSection 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|x64 = Debug|x64 23 | Release|x64 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|x64.ActiveCfg = Debug|x64 27 | {E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|x64.Build.0 = Debug|x64 28 | {E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|x64.ActiveCfg = Release|x64 29 | {E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|x64.Build.0 = Release|x64 30 | {53EFDFD0-9BCA-4E67-ABB2-628715E3F74B}.Debug|x64.ActiveCfg = Debug|x64 31 | {53EFDFD0-9BCA-4E67-ABB2-628715E3F74B}.Debug|x64.Build.0 = Debug|x64 32 | {53EFDFD0-9BCA-4E67-ABB2-628715E3F74B}.Release|x64.ActiveCfg = Release|x64 33 | {53EFDFD0-9BCA-4E67-ABB2-628715E3F74B}.Release|x64.Build.0 = Release|x64 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {E12ECB82-E5CA-4599-B2D4-FE455DC8ED54} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /Concealment/Commands.cs: -------------------------------------------------------------------------------- 1 | using Torch.Commands; 2 | using Torch.Commands.Permissions; 3 | using VRage.Game.ModAPI; 4 | using VRageMath; 5 | 6 | namespace Concealment 7 | { 8 | public class Commands : CommandModule 9 | { 10 | public ConcealmentPlugin Plugin => (ConcealmentPlugin)Context.Plugin; 11 | 12 | [Command("conceal", "Conceal grids x distance from players."), Permission(MyPromoteLevel.SpaceMaster)] 13 | public void Conceal(double distance = 0) 14 | { 15 | if (distance == 0) 16 | { 17 | distance = Plugin.Settings.Data.ConcealDistance; 18 | } 19 | var num = Plugin.ConcealGrids(distance); 20 | Context.Respond($"{num} grids concealed."); 21 | } 22 | 23 | [Command("reveal", "Reveal all grids within the given distance"), Permission(MyPromoteLevel.SpaceMaster)] 24 | public void Reveal(double distance = 1000) 25 | { 26 | var pos = Context.Player?.Controller.ControlledEntity?.Entity.GetPosition(); 27 | if (!pos.HasValue) 28 | { 29 | Context.Respond("You must be controlling an entity."); 30 | return; 31 | } 32 | 33 | var sphere = new BoundingSphereD(pos.Value, distance); 34 | var num = Plugin.RevealGridsInSphere(sphere); 35 | Context.Respond($"{num} grids revealed."); 36 | } 37 | 38 | [Command("reveal all", "Reveal all grids"), Permission(MyPromoteLevel.SpaceMaster)] 39 | public void RevealAll() 40 | { 41 | int num = Plugin.RevealAll(); 42 | Context.Respond($"{num} grids revealed."); 43 | } 44 | 45 | [Command("conceal on", "Enable concealment.")] 46 | public void Enable() 47 | { 48 | Plugin.Settings.Data.Enabled = true; 49 | Plugin.ConcealGrids(Plugin.Settings.Data.ConcealDistance); 50 | } 51 | 52 | [Command("conceal off", "Disable concealment.")] 53 | public void Disable() 54 | { 55 | Plugin.Settings.Data.Enabled = false; 56 | Plugin.RevealAll(); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Concealment/ConcealGroup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Havok; 6 | using NLog; 7 | using Sandbox.Engine.Physics; 8 | using Sandbox.Game.Entities; 9 | using Sandbox.Game.Entities.Blocks; 10 | using Sandbox.Game.World; 11 | using SpaceEngineers.Game.Entities.Blocks; 12 | using VRage.Audio; 13 | using VRage.Game.Entity; 14 | using VRage.Game.Entity.EntityComponents.Interfaces; 15 | using VRage.Groups; 16 | using VRage.ModAPI; 17 | using VRageMath; 18 | 19 | namespace Concealment 20 | { 21 | public class ConcealGroup 22 | { 23 | private static readonly Logger _log = LogManager.GetCurrentClassLogger(); 24 | /// 25 | /// Entity ID of the first grid in the group. 26 | /// 27 | public long Id { get; } 28 | public bool IsConcealed { get; private set; } 29 | public BoundingBoxD WorldAABB { get; private set; } 30 | public List Grids { get; } 31 | public List MedicalRooms { get; } = new List(); 32 | public List CryoChambers { get; } = new List(); 33 | //private Dictionary _unstatic = new Dictionary(); 34 | public event Action Closing; 35 | internal volatile int ProxyId = -1; 36 | 37 | public ConcealGroup(MyGroups.Group group) 38 | { 39 | Grids = group.Nodes.Select(n => n.NodeData).ToList(); 40 | Id = Grids.First().EntityId; 41 | } 42 | 43 | public string GridNames 44 | { 45 | get { return string.Join(", ", Grids.Select(g => g.DisplayName)); } 46 | set { } 47 | } 48 | 49 | public void UpdatePostConceal() 50 | { 51 | IsConcealed = true; 52 | UpdateAABB(); 53 | CacheSpawns(); 54 | HookOnClosing(); 55 | } 56 | 57 | public void UpdatePostReveal() 58 | { 59 | IsConcealed = false; 60 | UnhookOnClosing(); 61 | } 62 | 63 | private void HookOnClosing() 64 | { 65 | foreach (var grid in Grids) 66 | grid.OnMarkForClose += Grid_OnMarkForClose; 67 | } 68 | 69 | private void UnhookOnClosing() 70 | { 71 | foreach (var grid in Grids) 72 | grid.OnMarkForClose -= Grid_OnMarkForClose; 73 | } 74 | 75 | private void Grid_OnMarkForClose(MyEntity obj) 76 | { 77 | _log.Debug($"Grid group '{GridNames}' was marked for close."); 78 | EnableProjectors(); 79 | UnhookOnClosing(); 80 | Closing?.Invoke(this); 81 | } 82 | 83 | public void UpdateAABB() 84 | { 85 | var startPos = Grids.First().PositionComp.GetPosition(); 86 | var box = new BoundingBoxD(startPos, startPos); 87 | 88 | foreach (var aabb in Grids.Select(g => g.PositionComp.WorldAABB)) 89 | box.Include(aabb); 90 | 91 | WorldAABB = box; 92 | } 93 | 94 | private void CacheSpawns() 95 | { 96 | MedicalRooms.Clear(); 97 | CryoChambers.Clear(); 98 | 99 | foreach (var block in Grids.SelectMany(x => x.GetFatBlocks())) 100 | { 101 | if (block is MyMedicalRoom medical) 102 | MedicalRooms.Add(medical); 103 | else if (block is MyCryoChamber cryo) 104 | CryoChambers.Add(cryo); 105 | } 106 | } 107 | 108 | public bool IsMedicalRoomAvailable(long identityId) 109 | { 110 | foreach (var room in MedicalRooms) 111 | { 112 | if (room.HasPlayerAccess(identityId) && room.IsWorking) 113 | return true; 114 | } 115 | 116 | return false; 117 | } 118 | 119 | public bool IsCryoOccupied(ulong steamId) 120 | { 121 | var currentIdField = typeof(MyCryoChamber).GetField("m_currentPlayerId", BindingFlags.NonPublic | BindingFlags.Instance); 122 | 123 | foreach (var chamber in CryoChambers) 124 | { 125 | var value = (MyPlayer.PlayerId?)currentIdField.GetValue(chamber); 126 | if (value?.SteamId == steamId) 127 | return true; 128 | } 129 | 130 | return false; 131 | } 132 | 133 | private readonly HashSet _projectors = new HashSet(); 134 | private void DisableProjectors(MyCubeGrid grid) 135 | { 136 | foreach (var projector in grid.GetFatBlocks()) 137 | { 138 | if (projector.ProjectedGrid == null) 139 | continue; 140 | 141 | projector.Enabled = false; 142 | _projectors.Add(projector.EntityId); 143 | } 144 | } 145 | 146 | public void EnableProjectors() 147 | { 148 | foreach (var projector in _projectors.Select(x => MyEntities.GetEntityById(x) as MyProjectorBase)) 149 | { 150 | if (projector == null) 151 | continue; 152 | 153 | projector.Enabled = true; 154 | } 155 | _projectors.Clear(); 156 | } 157 | 158 | /// 159 | /// Conceals this group from game and physics logic. 160 | /// 161 | public void Conceal() 162 | { 163 | foreach (var grid in Grids) 164 | { 165 | DisableProjectors(grid); 166 | 167 | if (grid.Parent == null) 168 | UnregisterRecursive(grid); 169 | } 170 | 171 | void UnregisterRecursive(MyEntity e) 172 | { 173 | if (e.IsPreview) 174 | return; 175 | 176 | MyEntities.UnregisterForUpdate(e); 177 | (e.GameLogic as IMyGameLogicComponent)?.UnregisterForUpdate(); 178 | e.Flags |= (EntityFlags)4; 179 | if (e.Hierarchy == null) 180 | return; 181 | 182 | foreach (var child in e.Hierarchy.Children) 183 | UnregisterRecursive((MyEntity)child.Container.Entity); 184 | } 185 | } 186 | 187 | /// 188 | /// Reveals this group to game and physics logic. 189 | /// 190 | public void Reveal() 191 | { 192 | foreach (var grid in Grids) 193 | { 194 | if (grid.Parent == null) 195 | RegisterRecursive(grid); 196 | } 197 | 198 | EnableProjectors(); 199 | 200 | void RegisterRecursive(MyEntity e) 201 | { 202 | if (e.IsPreview) 203 | return; 204 | 205 | MyEntities.RegisterForUpdate(e); 206 | (e.GameLogic as IMyGameLogicComponent)?.RegisterForUpdate(); 207 | e.Flags &= ~(EntityFlags)4; 208 | if (e.Hierarchy == null) 209 | return; 210 | 211 | foreach (var child in e.Hierarchy.Children) 212 | RegisterRecursive((MyEntity)child.Container.Entity); 213 | } 214 | } 215 | } 216 | 217 | } 218 | -------------------------------------------------------------------------------- /Concealment/Concealment.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {E5C0184B-7DC4-43D8-872E-2F71162748AA} 6 | Library 7 | Properties 8 | Concealment 9 | Concealment 10 | v4.6.1 11 | 512 12 | 13 | 14 | true 15 | $(SolutionDir)\bin\x64\Debug\ 16 | DEBUG;TRACE 17 | full 18 | x64 19 | prompt 20 | MinimumRecommendedRules.ruleset 21 | 22 | 23 | $(SolutionDir)\bin\x64\Release\ 24 | TRACE 25 | true 26 | pdbonly 27 | x64 28 | prompt 29 | MinimumRecommendedRules.ruleset 30 | 31 | 32 | 33 | $(SolutionDir)\GameBinaries\HavokWrapper.dll 34 | False 35 | 36 | 37 | ..\packages\NLog.4.4.12\lib\net45\NLog.dll 38 | False 39 | 40 | 41 | 42 | 43 | $(SolutionDir)\GameBinaries\Sandbox.Common.dll 44 | False 45 | 46 | 47 | $(SolutionDir)\GameBinaries\Sandbox.Game.dll 48 | False 49 | 50 | 51 | $(SolutionDir)\GameBinaries\Sandbox.Graphics.dll 52 | False 53 | 54 | 55 | $(SolutionDir)\GameBinaries\SpaceEngineers.Game.dll 56 | False 57 | 58 | 59 | $(SolutionDir)\GameBinaries\SpaceEngineers.ObjectBuilders.dll 60 | False 61 | 62 | 63 | $(SolutionDir)\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll 64 | False 65 | 66 | 67 | $(SolutionDir)\GameBinaries\SteamSDK.dll 68 | False 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | False 81 | $(SolutionDir)\TorchBinaries\Torch.dll 82 | False 83 | 84 | 85 | False 86 | $(SolutionDir)\TorchBinaries\Torch.API.dll 87 | False 88 | 89 | 90 | $(SolutionDir)\GameBinaries\VRage.dll 91 | False 92 | 93 | 94 | $(SolutionDir)\GameBinaries\VRage.Audio.dll 95 | False 96 | 97 | 98 | $(SolutionDir)\GameBinaries\VRage.Dedicated.dll 99 | False 100 | 101 | 102 | $(SolutionDir)\GameBinaries\VRage.Game.dll 103 | False 104 | 105 | 106 | $(SolutionDir)\GameBinaries\VRage.Game.XmlSerializers.dll 107 | False 108 | 109 | 110 | $(SolutionDir)\GameBinaries\VRage.Input.dll 111 | False 112 | 113 | 114 | $(SolutionDir)\GameBinaries\VRage.Library.dll 115 | False 116 | 117 | 118 | $(SolutionDir)\GameBinaries\VRage.Math.dll 119 | False 120 | 121 | 122 | $(SolutionDir)\GameBinaries\VRage.Native.dll 123 | False 124 | 125 | 126 | $(SolutionDir)\GameBinaries\VRage.OpenVRWrapper.dll 127 | False 128 | 129 | 130 | $(SolutionDir)\GameBinaries\VRage.Render.dll 131 | False 132 | 133 | 134 | $(SolutionDir)\GameBinaries\VRage.Render11.dll 135 | False 136 | 137 | 138 | $(SolutionDir)\GameBinaries\VRage.Scripting.dll 139 | False 140 | 141 | 142 | 143 | 144 | 145 | Properties\AssemblyVersion.cs 146 | 147 | 148 | 149 | 150 | ConcealmentControl.xaml 151 | 152 | 153 | 154 | DynamicConcealmentEditor.xaml 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | Designer 163 | MSBuild:Compile 164 | 165 | 166 | Designer 167 | MSBuild:Compile 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /Concealment/ConcealmentControl.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 30 | 31 | 32 | 34 | 35 | 36 | 38 | 39 | 40 |