Skip to content

Commit 66eddee

Browse files
committed
Initial commit
1 parent 2cfb6a8 commit 66eddee

9 files changed

Lines changed: 771 additions & 0 deletions

Concealment/Commands.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.ConcealDistance;
18+
}
19+
var num = Plugin.ConcealDistantGrids(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("all", "Reveal all grids", null, "reveal"), Permission(MyPromoteLevel.SpaceMaster)]
39+
public void RevealAll()
40+
{
41+
int num = Plugin.RevealAll();
42+
Context.Respond($"{num} grids revealed.");
43+
}
44+
}
45+
}

Concealment/ConcealGroup.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using Sandbox.Game.Entities;
6+
using Sandbox.Game.Entities.Blocks;
7+
using Sandbox.Game.World;
8+
using SpaceEngineers.Game.Entities.Blocks;
9+
using VRage.Groups;
10+
using VRageMath;
11+
12+
namespace Concealment
13+
{
14+
public class ConcealGroup
15+
{
16+
/// <summary>
17+
/// Entity ID of the first grid in the group.
18+
/// </summary>
19+
public long Id { get; }
20+
public DateTime ConcealTime { get; set; }
21+
public BoundingBoxD WorldAABB { get; private set; }
22+
public List<MyCubeGrid> Grids { get; }
23+
public List<MyMedicalRoom> MedicalRooms { get; } = new List<MyMedicalRoom>();
24+
public List<MyCryoChamber> CryoChambers { get; } = new List<MyCryoChamber>();
25+
internal volatile int ProxyId = -1;
26+
27+
public ConcealGroup(MyGroups<MyCubeGrid, MyGridPhysicalGroupData>.Group group)
28+
{
29+
Grids = group.Nodes.Select(n => n.NodeData).ToList();
30+
Id = Grids.First().EntityId;
31+
}
32+
33+
public string GridNames
34+
{
35+
get { return string.Join(", ", Grids.Select(g => g.DisplayName)); }
36+
}
37+
38+
public void UpdatePostConceal()
39+
{
40+
UpdateAABB();
41+
CacheSpawns();
42+
}
43+
44+
private void UpdateAABB()
45+
{
46+
var startPos = Grids.First().PositionComp.GetPosition();
47+
var box = new BoundingBoxD(startPos, startPos);
48+
49+
foreach (var aabb in Grids.Select(g => g.PositionComp.WorldAABB))
50+
box.Include(aabb);
51+
52+
WorldAABB = box;
53+
}
54+
55+
private void CacheSpawns()
56+
{
57+
MedicalRooms.Clear();
58+
CryoChambers.Clear();
59+
60+
foreach (var block in Grids.SelectMany(x => x.GetFatBlocks()))
61+
{
62+
if (block is MyMedicalRoom medical)
63+
MedicalRooms.Add(medical);
64+
else if (block is MyCryoChamber cryo)
65+
CryoChambers.Add(cryo);
66+
}
67+
}
68+
69+
public bool IsMedicalRoomAvailable(long identityId)
70+
{
71+
foreach (var room in MedicalRooms)
72+
{
73+
if (room.HasPlayerAccess(identityId) && room.IsWorking)
74+
return true;
75+
}
76+
77+
return false;
78+
}
79+
80+
public bool IsCryoOccupied(ulong steamId)
81+
{
82+
var currentIdField = typeof(MyCryoChamber).GetField("m_currentPlayerId", BindingFlags.NonPublic | BindingFlags.Instance);
83+
84+
foreach (var chamber in CryoChambers)
85+
{
86+
var value = (MyPlayer.PlayerId?)currentIdField.GetValue(chamber);
87+
if (value?.SteamId == steamId)
88+
return true;
89+
}
90+
91+
return false;
92+
}
93+
}
94+
95+
}

Concealment/Concealment.csproj

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E5C0184B-7DC4-43D8-872E-2F71162748AA}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Concealment</RootNamespace>
11+
<AssemblyName>Concealment</AssemblyName>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
33+
<DebugSymbols>true</DebugSymbols>
34+
<OutputPath>bin\x64\Debug\</OutputPath>
35+
<DefineConstants>DEBUG;TRACE</DefineConstants>
36+
<DebugType>full</DebugType>
37+
<PlatformTarget>x64</PlatformTarget>
38+
<ErrorReport>prompt</ErrorReport>
39+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
42+
<OutputPath>bin\x64\Release\</OutputPath>
43+
<DefineConstants>TRACE</DefineConstants>
44+
<Optimize>true</Optimize>
45+
<DebugType>pdbonly</DebugType>
46+
<PlatformTarget>x64</PlatformTarget>
47+
<ErrorReport>prompt</ErrorReport>
48+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
49+
</PropertyGroup>
50+
<ItemGroup>
51+
<Reference Include="HavokWrapper">
52+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\HavokWrapper.dll</HintPath>
53+
</Reference>
54+
<Reference Include="NLog">
55+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\NLog.dll</HintPath>
56+
</Reference>
57+
<Reference Include="PresentationCore" />
58+
<Reference Include="PresentationFramework" />
59+
<Reference Include="Sandbox.Common">
60+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\Sandbox.Common.dll</HintPath>
61+
</Reference>
62+
<Reference Include="Sandbox.Game">
63+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\Sandbox.Game.dll</HintPath>
64+
</Reference>
65+
<Reference Include="Sandbox.Graphics">
66+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\Sandbox.Graphics.dll</HintPath>
67+
</Reference>
68+
<Reference Include="SpaceEngineers.Game">
69+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\SpaceEngineers.Game.dll</HintPath>
70+
</Reference>
71+
<Reference Include="SpaceEngineers.ObjectBuilders">
72+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\SpaceEngineers.ObjectBuilders.dll</HintPath>
73+
</Reference>
74+
<Reference Include="SpaceEngineers.ObjectBuilders.XmlSerializers">
75+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
76+
</Reference>
77+
<Reference Include="SteamSDK">
78+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\SteamSDK.dll</HintPath>
79+
</Reference>
80+
<Reference Include="System" />
81+
<Reference Include="System.Core" />
82+
<Reference Include="System.Xaml" />
83+
<Reference Include="System.Xml.Linq" />
84+
<Reference Include="System.Data.DataSetExtensions" />
85+
<Reference Include="Microsoft.CSharp" />
86+
<Reference Include="System.Data" />
87+
<Reference Include="System.Net.Http" />
88+
<Reference Include="System.Xml" />
89+
<Reference Include="Torch, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
90+
<SpecificVersion>False</SpecificVersion>
91+
<HintPath>..\..\Torch\Torch.Server\bin\x64\Release\Torch.dll</HintPath>
92+
</Reference>
93+
<Reference Include="Torch.API, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
94+
<SpecificVersion>False</SpecificVersion>
95+
<HintPath>..\..\Torch\Torch.Server\bin\x64\Release\Torch.API.dll</HintPath>
96+
</Reference>
97+
<Reference Include="VRage">
98+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.dll</HintPath>
99+
</Reference>
100+
<Reference Include="VRage.Audio">
101+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Audio.dll</HintPath>
102+
</Reference>
103+
<Reference Include="VRage.Dedicated">
104+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Dedicated.dll</HintPath>
105+
</Reference>
106+
<Reference Include="VRage.Game">
107+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Game.dll</HintPath>
108+
</Reference>
109+
<Reference Include="VRage.Game.XmlSerializers">
110+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Game.XmlSerializers.dll</HintPath>
111+
</Reference>
112+
<Reference Include="VRage.Input">
113+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Input.dll</HintPath>
114+
</Reference>
115+
<Reference Include="VRage.Library">
116+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Library.dll</HintPath>
117+
</Reference>
118+
<Reference Include="VRage.Math">
119+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Math.dll</HintPath>
120+
</Reference>
121+
<Reference Include="VRage.Native">
122+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Native.dll</HintPath>
123+
</Reference>
124+
<Reference Include="VRage.OpenVRWrapper">
125+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.OpenVRWrapper.dll</HintPath>
126+
</Reference>
127+
<Reference Include="VRage.Render">
128+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Render.dll</HintPath>
129+
</Reference>
130+
<Reference Include="VRage.Render11">
131+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Render11.dll</HintPath>
132+
</Reference>
133+
<Reference Include="VRage.Scripting">
134+
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\VRage.Scripting.dll</HintPath>
135+
</Reference>
136+
<Reference Include="WindowsBase" />
137+
</ItemGroup>
138+
<ItemGroup>
139+
<Compile Include="Commands.cs" />
140+
<Compile Include="ConcealGroup.cs" />
141+
<Compile Include="ConcealmentControl.xaml.cs">
142+
<DependentUpon>ConcealmentControl.xaml</DependentUpon>
143+
</Compile>
144+
<Compile Include="ConcealmentPlugin.cs" />
145+
<Compile Include="Properties\AssemblyInfo.cs" />
146+
<Compile Include="Settings.cs" />
147+
</ItemGroup>
148+
<ItemGroup>
149+
<Page Include="ConcealmentControl.xaml">
150+
<SubType>Designer</SubType>
151+
<Generator>MSBuild:Compile</Generator>
152+
</Page>
153+
</ItemGroup>
154+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
155+
</Project>

Concealment/Concealment.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26403.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concealment", "Concealment.csproj", "{E5C0184B-7DC4-43D8-872E-2F71162748AA}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|x64.ActiveCfg = Release|x64
19+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|x64.Build.0 = Release|x64
20+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|x64.ActiveCfg = Release|x64
23+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|x64.Build.0 = Release|x64
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<UserControl x:Class="Concealment.ConcealmentControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Concealment"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300">
9+
<DockPanel>
10+
<StackPanel DockPanel.Dock="Top">
11+
<StackPanel DataContext="{Binding Settings}">
12+
<CheckBox Content="Enable Concealment" Margin="3" IsChecked="{Binding Enabled}" />
13+
<StackPanel Orientation="Horizontal">
14+
<TextBox Margin="3" Width="150" Text="{Binding ConcealDistance}" />
15+
<Label Content="Conceal Distance (meters)" Margin="3" />
16+
</StackPanel>
17+
<StackPanel Orientation="Horizontal">
18+
<TextBox Margin="3" Width="150" Text="{Binding RevealDistance}" />
19+
<Label Content="Reveal Distance (meters)" Margin="3" />
20+
</StackPanel>
21+
<StackPanel Orientation="Horizontal">
22+
<TextBox Margin="3" Width="150" Text="{Binding ConcealInterval}" />
23+
<Label Content="Conceal Interval (ticks, 1/60 s)" Margin="3" />
24+
</StackPanel>
25+
<StackPanel Orientation="Horizontal">
26+
<TextBox Margin="3" Width="150" Text="{Binding RevealInterval}" />
27+
<Label Content="Reveal Interval (ticks, 1/60 s)" Margin="3" />
28+
</StackPanel>
29+
</StackPanel>
30+
<StackPanel Orientation="Horizontal">
31+
<Button Content="Manual Conceal" Margin="3" Click="Conceal_OnClick" />
32+
<Button Content="Manual Reveal" Margin="3" Click="Reveal_OnClick" />
33+
</StackPanel>
34+
</StackPanel>
35+
<Button Content="Reveal Selected" Margin="3" DockPanel.Dock="Bottom" Click="ButtonBase_OnClick" />
36+
<ListView Name="Concealed" Margin="3" DockPanel.Dock="Bottom" ItemsSource="{Binding ConcealGroups}">
37+
<ItemsControl.ItemTemplate>
38+
<DataTemplate>
39+
<StackPanel>
40+
<TextBlock Text="{Binding GridNames}" />
41+
</StackPanel>
42+
</DataTemplate>
43+
</ItemsControl.ItemTemplate>
44+
</ListView>
45+
</DockPanel>
46+
47+
</UserControl>

0 commit comments

Comments
 (0)