Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Fixes MOTD not showing if the GreetingMessage field is empty. Remove …
Browse files Browse the repository at this point in the history
…leftover debug logging from player block enforcement. Improvements to concealment.
  • Loading branch information
rexxar-tc committed Jun 9, 2016
1 parent f278876 commit 4310910
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 217 deletions.
6 changes: 3 additions & 3 deletions EssentialsPlugin/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//4
//5
//
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyFileVersion("1.13.7.4")]
[assembly: AssemblyVersion("1.13.7.4")]
[assembly: AssemblyFileVersion("1.13.7.5")]
[assembly: AssemblyVersion("1.13.7.5")]
115 changes: 35 additions & 80 deletions EssentialsPlugin/EntityManagers/EntityManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting;
using System.Threading;
using EssentialsPlugin.ProcessHandlers;
using EssentialsPlugin.Utility;
Expand Down Expand Up @@ -42,8 +43,6 @@ public static void CheckAndConcealEntities( )
try
{
List<MyPlayer> players;
HashSet<MyEntity> entities;
HashSet<MyEntity> entitiesFiltered = new HashSet<MyEntity>( );

try
{
Expand All @@ -54,39 +53,18 @@ public static void CheckAndConcealEntities( )
Essentials.Log.Error( ex, "Error getting players list. Check and Conceal failed: {0}");
return;
}

try
{
entities = MyEntities.GetEntities();
}
catch ( Exception ex )
{
Essentials.Log.Error( ex, "Error getting entity list, skipping check" );
return;
}

foreach (MyEntity entity in entities )
{
if ( !( entity is MyCubeGrid ) )
continue;

if ( UnregisteredEntities.Contains( entity ) )
continue;

entitiesFiltered.Add( entity );
}

var groups = GridGroup.GetGroups( entitiesFiltered, GridLinkTypeEnum.Physical );

foreach ( GridGroup group in groups )
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;}
continue;
}
}
foreach ( MyCubeGrid grid in group.Grids )
{
Expand All @@ -98,21 +76,21 @@ public static void CheckAndConcealEntities( )
if ( grid.IsStatic && !PluginSettings.Instance.ConcealIncludeStations )
continue;
if ( !PluginSettings.Instance.ConcealIncludeLargeGrids )
continue;
}
continue;
}

if ( players.Any( x => Vector3D.Distance( x.GetPosition(), grid.PositionComp.GetPosition() ) < PluginSettings.Instance.DynamicConcealDistance ) )
continue;
continue;

if ( ProcessDockingZone.ZoneCache.Any( x => Vector3D.Distance( x.GetPosition(), grid.PositionComp.GetPosition() ) < 100d ) )
continue;
if ( ProcessDockingZone.ZoneCache.Any( x => Vector3D.Distance( x.GetPosition(), grid.PositionComp.GetPosition() ) < 100 ) )
continue;

if ( CheckConcealBlockRules( grid ) )
continue;

ConcealEntity( grid );
}
}
}
}
catch ( Exception ex )
{
Expand All @@ -137,12 +115,13 @@ private static bool CheckConcealBlockRules( MyCubeGrid grid )
var beacon = cubeBlock as IMyBeacon;
if ( beacon != null)
{
beaconCount++;
//beaconCount++;
// Keep this return here, as 4 beacons always means true
if ( beaconCount >= 4 )
{
return true;
}
//DON'T TELL ME WHAT TO DO
//if ( beaconCount >= 4 )
//{
// return true;
//}

if ( !beacon.Enabled )
continue;
Expand Down Expand Up @@ -185,21 +164,18 @@ private static bool CheckConcealBlockRules( MyCubeGrid grid )
return true;
}
}

//TODO
/*

var cryo = cubeBlock as MyCryoChamber;
if ( cryo?.Pilot != null )
return true;
*/

var production = cubeBlock as IMyProductionBlock;
if ( production != null )
if ( production != null && PluginSettings.Instance.DynamicConcealProduction )
{
if ( !production.Enabled )
continue;

if ( production.IsProducing )
if ( !production.IsQueueEmpty )
return true;
}

Expand Down Expand Up @@ -459,7 +435,7 @@ private static bool CheckRevealBlockRules( MyCubeGrid grid, out string reason )

if ( medical.HasPlayerAccess( playerId ) )
{
reason = $"Grid has medbay and player is factionshare - playerid: {playerId}";
reason = $"Grid has medbay and player has access - playerid: {playerId}";
return true;
}
}
Expand All @@ -473,50 +449,26 @@ private static bool CheckRevealBlockRules( MyCubeGrid grid, out string reason )
}

var cryo = cubeBlock as MyCryoChamber;
if ( cryo != null )
{
if ( cryo.Pilot == null )
continue;

if ( !cryo.IsFunctional )
continue;

if ( PluginSettings.Instance.DynamicConcealIncludeMedBays )
{
lock ( Online )
{
foreach ( ulong connectedPlayer in Online )
{
long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId( connectedPlayer );
if ( cryo != null )
{
if ( cryo.Pilot == null )
continue;

if (cryo.Pilot.GetPlayerIdentityId() == playerId )
{
reason = $"Grid has cryopod and player is inside - playerid: {playerId}";
return true;
}
if ( !cryo.IsFunctional )
continue;

if ( cryo.HasPlayerAccess( playerId ) )
{
reason = $"Grid has cryopod and player can use - playerid: {playerId}";
return true;
}
}
}
}
else
{
reason = "Grid has cryopod and conceal can not include cryopods";
return true;
}
}
reason = $"Grid has cryopod and player is inside - player: {cryo.Pilot.DisplayName}";
return true;
}

//don't check conceal settings for production blocks, we always want them to reveal
var production = cubeBlock as MyProductionBlock;
if ( production != null )
{
if ( !production.Enabled )
continue;

if ( production.Queue.Any() )
if ( !production.IsQueueEmpty )
{
reason = "Grid has production facility that has a queue";
return true;
Expand Down Expand Up @@ -657,6 +609,9 @@ private static void UnregisterHierarchy( MyEntity entity )
if ( entity.Hierarchy == null )
return;

if ( UnregisteredEntities.Contains( entity ) )
return;

foreach ( var child in entity.Hierarchy.Children )
{
MyEntity childEntity = (MyEntity)child.Container.Entity;
Expand Down
53 changes: 12 additions & 41 deletions EssentialsPlugin/Essentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ public string[ ] DynamicConcealIgnoreSubTypeList

[Category( "Dynamic Entity Management" )]
[DisplayName( "Include MedBays" )]
[Description( "The list of subtype blocks that will make the entity manager ignore a grid. If a grid contains any of these block subtypes, it will automatically not include it when deciding whether to conceal the grid or not" )]
[Description( "If any online player has access to a working medbay on a grid, it will be ignored." )]
[Browsable( true )]
[ReadOnly( false )]
public bool DynamicConcealIncludeMedBays
Expand All @@ -721,47 +721,18 @@ public bool DynamicConcealIncludeMedBays
set { PluginSettings.Instance.DynamicConcealIncludeMedBays = value; }
}

/* Experiments not working yet */
/*
[Category("Dynamic Entity Management")]
[Description("")]
[Browsable(true)]
[ReadOnly(false)]
public bool DynamicConcealServerOnly
{
get { return PluginSettings.Instance.DynamicConcealServerOnly; }
set
{
PluginSettings.Instance.DynamicConcealServerOnly = value;
}
}

[Category("Dynamic Entity Management")]
[Description("")]
[Browsable(true)]
[ReadOnly(false)]
public bool DynamicClientConcealEnabled
{
get { return PluginSettings.Instance.DynamicClientConcealEnabled; }
set
{
PluginSettings.Instance.DynamicClientConcealEnabled = value;
}
}
[Category("Dynamic Entity Management")]
[Description("")]
[Browsable(true)]
[ReadOnly(false)]
public float DynamicClientConcealDistance
{
get { return PluginSettings.Instance.DynamicClientConcealDistance; }
set
{
PluginSettings.Instance.DynamicClientConcealDistance = value;
}
}
/**/
[Category("Dynamic Entity Management")]
[DisplayName("Include Active Production")]
[Description("Ships with active production blocks will be concealed.")]
[Browsable(true)]
[ReadOnly(false)]
public bool DynamicConcealProduction
{
get { return PluginSettings.Instance.DynamicConcealIncludeMedBays; }
set { PluginSettings.Instance.DynamicConcealIncludeMedBays = value; }
}

[Category( "Dynamic Entity Management" )]
[DisplayName( "Log Actions" )]
[Description( "Enable / Disable console messages that display whether an entity is concealed or revealed. Should be off if you don't care about seeing how many entities get revealed/concealed." )]
Expand Down
Loading

0 comments on commit 4310910

Please sign in to comment.