

using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using KindredCommands.Commands.Converters;
using KindredCommands.Data;
using KindredCommands.Models;
using KindredCommands.Services;
using Microsoft.CodeAnalysis;
using NetTopologySuite.Geometries;
using NetTopologySuite.Index.Strtree;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Gameplay.Clan;
using ProjectM.Gameplay.Scripting;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using ProjectM.Shared;
using ProjectM.Shared.Systems;
using ProjectM.Terrain;
using ProjectM.Tiles;
using Stunlock.Core;
using Stunlock.Localization;
using Stunlock.Network;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Transforms;
using UnityEngine;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("odjit")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Commands to expand Administration efforts and provide information")]
[assembly: AssemblyFileVersion("2.5.8.0")]
[assembly: AssemblyInformationalVersion("2.5.8+30905e0f01ebde50deeabaadd002615b4817c109")]
[assembly: AssemblyProduct("KindredCommands")]
[assembly: AssemblyTitle("KindredCommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.5.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace KindredCommands
{
internal class Buffs
{
public delegate void BuffCreated(Entity buffEntity);
[CompilerGenerated]
private sealed class <RemoveAndAddBuffCoroutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Entity targetEntity;
public PrefabGUID buffPrefab;
public Entity userEntity;
public float duration;
public BuffCreated callback;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RemoveAndAddBuffCoroutine>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
RemoveBuff(targetEntity, buffPrefab);
break;
case 1:
<>1__state = -1;
break;
}
if (BuffUtility.HasBuff<EntityManager>(Core.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab)))
{
<>2__current = null;
<>1__state = 1;
return true;
}
AddBuff(userEntity, targetEntity, buffPrefab, duration);
Entity buffEntity = default(Entity);
if (callback != null && BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab), ref buffEntity))
{
callback(buffEntity);
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static bool AddBuff(Entity User, Entity Character, PrefabGUID buffPrefab, float duration = 0f, bool immortal = true)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
DebugEventsSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<DebugEventsSystem>();
ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
val.BuffPrefabGUID = buffPrefab;
ApplyBuffDebugEvent val2 = val;
FromCharacter val3 = default(FromCharacter);
val3.User = User;
val3.Character = Character;
FromCharacter val4 = val3;
Entity entity = default(Entity);
if (!BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity))
{
existingSystemManaged.ApplyBuff(val4, val2);
if (BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity))
{
if (entity.Has<CreateGameplayEventsOnSpawn>())
{
entity.Remove<CreateGameplayEventsOnSpawn>();
}
if (entity.Has<GameplayEventListeners>())
{
entity.Remove<GameplayEventListeners>();
}
if (immortal)
{
entity.Add<Buff_Persists_Through_Death>();
if (entity.Has<RemoveBuffOnGameplayEvent>())
{
entity.Remove<RemoveBuffOnGameplayEvent>();
}
if (entity.Has<RemoveBuffOnGameplayEventEntry>())
{
entity.Remove<RemoveBuffOnGameplayEventEntry>();
}
}
if (duration > -1f && duration != 0f)
{
if (!entity.Has<LifeTime>())
{
entity.Add<LifeTime>();
entity.Write<LifeTime>(new LifeTime
{
EndAction = (LifeTimeEndAction)2
});
}
LifeTime componentData = entity.Read<LifeTime>();
componentData.Duration = duration;
entity.Write<LifeTime>(componentData);
}
else if (duration == -1f)
{
if (entity.Has<LifeTime>())
{
LifeTime componentData2 = entity.Read<LifeTime>();
componentData2.EndAction = (LifeTimeEndAction)0;
entity.Write<LifeTime>(componentData2);
}
if (entity.Has<RemoveBuffOnGameplayEvent>())
{
entity.Remove<RemoveBuffOnGameplayEvent>();
}
if (entity.Has<RemoveBuffOnGameplayEventEntry>())
{
entity.Remove<RemoveBuffOnGameplayEventEntry>();
}
}
return true;
}
return false;
}
return false;
}
public static void RemoveBuff(Entity Character, PrefabGUID buffPrefab)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Entity val = default(Entity);
if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref val))
{
DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
}
}
public static void RemoveAndAddBuff(Entity userEntity, Entity targetEntity, PrefabGUID buffPrefab, float duration = -1f, BuffCreated callback = null)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (!BuffUtility.HasBuff<EntityManager>(Core.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab)))
{
AddBuff(userEntity, targetEntity, buffPrefab, duration);
Entity buffEntity = default(Entity);
if (callback != null && BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab), ref buffEntity))
{
callback(buffEntity);
}
}
else
{
Core.StartCoroutine(RemoveAndAddBuffCoroutine(userEntity, targetEntity, buffPrefab, duration, callback));
}
}
[IteratorStateMachine(typeof(<RemoveAndAddBuffCoroutine>d__4))]
private static IEnumerator RemoveAndAddBuffCoroutine(Entity userEntity, Entity targetEntity, PrefabGUID buffPrefab, float duration, BuffCreated callback)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RemoveAndAddBuffCoroutine>d__4(0)
{
userEntity = userEntity,
targetEntity = targetEntity,
buffPrefab = buffPrefab,
duration = duration,
callback = callback
};
}
public static void AddGlow(Entity userEntity, Entity targetEntity, PrefabGUID glowPrefab)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
RemoveAndAddBuff(userEntity, targetEntity, glowPrefab, -1f, delegate(Entity glowBuffEntity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
if (glowBuffEntity.Has<EntityOwner>())
{
glowBuffEntity.Write<EntityOwner>(new EntityOwner
{
Owner = targetEntity
});
}
if (glowBuffEntity.Has<CreateGameplayEventsOnSpawn>())
{
glowBuffEntity.Remove<CreateGameplayEventsOnSpawn>();
}
if (glowBuffEntity.Has<GameplayEventListeners>())
{
glowBuffEntity.Remove<GameplayEventListeners>();
}
if (glowBuffEntity.Has<RemoveBuffOnGameplayEvent>())
{
glowBuffEntity.Remove<RemoveBuffOnGameplayEvent>();
}
if (glowBuffEntity.Has<RemoveBuffOnGameplayEventEntry>())
{
glowBuffEntity.Remove<RemoveBuffOnGameplayEventEntry>();
}
if (glowBuffEntity.Has<DealDamageOnGameplayEvent>())
{
glowBuffEntity.Remove<DealDamageOnGameplayEvent>();
}
if (glowBuffEntity.Has<ModifyMovementSpeedBuff>())
{
glowBuffEntity.Remove<ModifyMovementSpeedBuff>();
}
if (glowBuffEntity.Has<HealOnGameplayEvent>())
{
glowBuffEntity.Remove<HealOnGameplayEvent>();
}
if (glowBuffEntity.Has<DestroyOnGameplayEvent>())
{
glowBuffEntity.Remove<DestroyOnGameplayEvent>();
}
if (glowBuffEntity.Has<WeakenBuff>())
{
glowBuffEntity.Remove<WeakenBuff>();
}
if (glowBuffEntity.Has<ReplaceAbilityOnSlotBuff>())
{
glowBuffEntity.Remove<ReplaceAbilityOnSlotBuff>();
}
if (glowBuffEntity.Has<AmplifyBuff>())
{
glowBuffEntity.Remove<AmplifyBuff>();
}
if (glowBuffEntity.Has<EmpowerBuff>())
{
glowBuffEntity.Remove<EmpowerBuff>();
}
if (glowBuffEntity.Has<BuffResistances>())
{
glowBuffEntity.Remove<BuffResistances>();
}
if (glowBuffEntity.Has<BuffResistanceElement>())
{
glowBuffEntity.Remove<BuffResistanceElement>();
}
if (glowBuffEntity.Has<AbsorbBuff>())
{
glowBuffEntity.Remove<AbsorbBuff>();
}
if (glowBuffEntity.Has<FortifyBuff>())
{
glowBuffEntity.Remove<FortifyBuff>();
}
if (glowBuffEntity.Has<ModifyUnitStatBuff_DOTS>())
{
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).GetBuffer<ModifyUnitStatBuff_DOTS>(glowBuffEntity, false).Clear();
}
if (glowBuffEntity.Has<BuffModificationFlagData>())
{
glowBuffEntity.Remove<BuffModificationFlagData>();
}
if (glowBuffEntity.Has<SpellModArithmetic>())
{
glowBuffEntity.Remove<SpellModArithmetic>();
}
if (glowBuffEntity.Has<MoveTowardsPositionBuff>())
{
glowBuffEntity.Remove<MoveTowardsPositionBuff>();
}
if (glowBuffEntity.Has<Dash>())
{
glowBuffEntity.Remove<Dash>();
}
if (glowBuffEntity.Has<DashSpawn>())
{
glowBuffEntity.Remove<DashSpawn>();
}
if (glowBuffEntity.Has<TravelToTarget>())
{
glowBuffEntity.Remove<TravelToTarget>();
}
if (glowBuffEntity.Has<TravelBuff>())
{
glowBuffEntity.Remove<TravelBuff>();
}
if (glowBuffEntity.Has<TravelBuffSpawn>())
{
glowBuffEntity.Remove<TravelBuffSpawn>();
}
if (glowBuffEntity.Has<CreateGameplayEventsOnTick>())
{
glowBuffEntity.Remove<CreateGameplayEventsOnTick>();
}
if (glowBuffEntity.Has<ScriptSpawn>())
{
glowBuffEntity.Remove<ScriptSpawn>();
}
if (glowBuffEntity.Has<ScriptDestroy>())
{
glowBuffEntity.Remove<ScriptDestroy>();
}
glowBuffEntity.Add<HideOutsideVision>();
});
}
}
internal static class Core
{
private static MonoBehaviour monoBehaviour;
public const int MAX_REPLY_LENGTH = 509;
private static bool _hasInitialized = false;
public static World Server { get; } = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
public static EntityManager EntityManager { get; } = Server.EntityManager;
public static GameDataSystem GameDataSystem { get; } = Server.GetExistingSystemManaged<GameDataSystem>();
public static GenerateCastleSystem GenerateCastle { get; private set; }
public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; }
public static PrefabCollectionSystem PrefabCollection { get; } = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
public static RelicDestroySystem RelicDestroySystem { get; internal set; }
public static ServerScriptMapper ServerScriptMapper { get; internal set; }
public static double ServerTime => ServerGameManager.ServerTime;
public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();
public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }
public static ManualLogSource Log { get; } = Plugin.PluginLog;
public static AnnouncementsService AnnouncementsService { get; internal set; }
public static AuditService AuditService { get; } = new AuditService();
public static AutoChainInstanceService AutoChainInstanceService { get; internal set; }
public static BloodBoundService BloodBoundService { get; private set; }
public static BoostedPlayerService BoostedPlayerService { get; internal set; }
public static BossService Boss { get; internal set; }
public static CastleTerritoryService CastleTerritory { get; private set; }
public static ConfigSettingsService ConfigSettings { get; internal set; }
public static DropItemService DropItem { get; internal set; }
public static GearService GearService { get; internal set; }
public static GlobalMiscService GlobalMisc { get; internal set; }
public static LocalizationService Localization { get; } = new LocalizationService();
public static PlayerService Players { get; internal set; }
public static PrefabService Prefabs { get; internal set; }
public static PrisonerService Prisoners { get; internal set; }
public static RegionService Regions { get; internal set; }
public static ServantSenderService ServantSender { get; internal set; }
public static SoulshardService SoulshardService { get; internal set; }
public static TerritoryLocationService TerritoryLocation { get; internal set; }
public static TrackPlayerEquipmentService TrackPlayerEquipment { get; internal set; }
public static UnitSpawnerService UnitSpawner { get; internal set; }
public static void LogException(Exception e, [CallerMemberName] string caller = null)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource log = Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(caller);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.Message);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.StackTrace);
}
log.LogError(val);
}
internal static void InitializeAfterLoaded()
{
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Expected O, but got Unknown
if (!_hasInitialized)
{
GenerateCastle = Server.GetOrCreateSystemManaged<GenerateCastleSystem>();
PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
RelicDestroySystem = Server.GetExistingSystemManaged<RelicDestroySystem>();
ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
Prefabs = new PrefabService();
ConfigSettings = new ConfigSettingsService();
BoostedPlayerService = new BoostedPlayerService();
Players = new PlayerService();
AnnouncementsService = new AnnouncementsService();
try
{
AutoChainInstanceService = new AutoChainInstanceService();
}
catch (FileNotFoundException)
{
AutoChainInstanceService = null;
Log.LogError((object)"Missing NetTopologySuite.dll from plugins so will not be able to fully force all respawns");
}
BloodBoundService = new BloodBoundService();
Boss = new BossService();
CastleTerritory = new CastleTerritoryService();
DropItem = new DropItemService();
GearService = new GearService();
GlobalMisc = new GlobalMiscService();
Prisoners = new PrisonerService();
Regions = new RegionService();
ServantSender = new ServantSenderService();
SoulshardService = new SoulshardService();
TerritoryLocation = new TerritoryLocationService();
TrackPlayerEquipment = new TrackPlayerEquipmentService();
UnitSpawner = new UnitSpawnerService();
Character.Populate();
_hasInitialized = true;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("InitializeAfterLoaded");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" completed");
}
log.LogInfo(val);
}
}
private static World GetWorld(string name)
{
Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
while (enumerator.MoveNext())
{
World current = enumerator.Current;
if (current.Name == name)
{
return current;
}
}
return null;
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
if ((Object)(object)monoBehaviour == (Object)null)
{
GameObject val = new GameObject("KindredCommands");
monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
Object.DontDestroyOnLoad((Object)val);
}
return monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
}
public static void StopCoroutine(Coroutine coroutine)
{
if (!((Object)(object)monoBehaviour == (Object)null))
{
monoBehaviour.StopCoroutine(coroutine);
}
}
}
public static class ECSExtensions
{
public delegate void ActionRef<T>(ref T item);
public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
byte[] array = StructureToByteArray(componentData);
int num = Marshal.SizeOf<T>();
fixed (byte* ptr = array)
{
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
}
}
public static void With<T>(this Entity entity, ActionRef<T> action) where T : struct
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
T item = entity.ReadRW<T>();
action(ref item);
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item);
}
public unsafe static T ReadRW<T>(this Entity entity) where T : struct
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, val.TypeIndex)));
}
public static byte[] StructureToByteArray<T>(T structure) where T : struct
{
int num = Marshal.SizeOf(structure);
byte[] array = new byte[num];
IntPtr intPtr = Marshal.AllocHGlobal(num);
Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
Marshal.Copy(intPtr, array, 0, num);
Marshal.FreeHGlobal(intPtr);
return array;
}
public unsafe static T Read<T>(this Entity entity) where T : struct
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
}
public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.Server.EntityManager;
return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
}
public static bool Has<T>(this Entity entity)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
}
public static string LookupName(this PrefabGUID prefabGuid)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
NativeParallelHashMap<PrefabGUID, Entity> guidToEntityMap = existingSystemManaged._PrefabLookupMap.GuidToEntityMap;
if (!guidToEntityMap.ContainsKey(prefabGuid))
{
return "GUID Not Found";
}
PrefabLookupMap prefabLookupMap = existingSystemManaged._PrefabLookupMap;
return ((PrefabLookupMap)(ref prefabLookupMap)).GetName(prefabGuid) + " PrefabGuid(" + ((PrefabGUID)(ref prefabGuid)).GuidHash + ")";
}
public static string PrefabName(this PrefabGUID prefabGuid)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
string prefabName = Core.Localization.GetPrefabName(prefabGuid);
if (!string.IsNullOrEmpty(prefabName))
{
return prefabName;
}
return prefabGuid.LookupName();
}
public static string EntityName(this Entity entity)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
string text = string.Empty;
if (entity.Has<NameableInteractable>())
{
NameableInteractable val = entity.Read<NameableInteractable>();
text = ((object)(FixedString64Bytes)(ref val.Name)).ToString();
}
if (string.IsNullOrEmpty(text) && entity.Has<PrefabGUID>())
{
text = entity.Read<PrefabGUID>().PrefabName();
}
if (string.IsNullOrEmpty(text))
{
text = ((object)(Entity)(ref entity)).ToString();
}
return text;
}
public static void Add<T>(this Entity entity)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).AddComponent(entity, val);
}
public static void Remove<T>(this Entity entity)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
}
}
internal static class Helper
{
[CompilerGenerated]
private sealed class <GetAllEntitiesInRadius>d__8<T> : IEnumerable<Entity>, IEnumerable, IEnumerator<Entity>, IEnumerator, IDisposable
{
private int <>1__state;
private Entity <>2__current;
private int <>l__initialThreadId;
private float2 center;
public float2 <>3__center;
private float radius;
public float <>3__radius;
private NativeList<Entity> <entities>5__2;
private Enumerator<Entity> <>7__wrap2;
Entity IEnumerator<Entity>.Current
{
[DebuggerHidden]
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return <>2__current;
}
}
[DebuggerHidden]
public <GetAllEntitiesInRadius>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
TileModelSpatialLookupSystemData tileModelLookupSystemData = Core.GenerateCastle._TileModelLookupSystemData;
TileModelSpatialLookupRO spatialLookupReadOnlyAndComplete = ((TileModelSpatialLookupSystemData)(ref tileModelLookupSystemData)).GetSpatialLookupReadOnlyAndComplete((SystemBase)(object)Core.GenerateCastle);
ConvertPosToTileGrid(center);
float2 val = ConvertPosToTileGrid(center - radius);
float2 val2 = ConvertPosToTileGrid(center + radius);
BoundsMinMax val3 = default(BoundsMinMax);
((BoundsMinMax)(ref val3))..ctor(Mathf.FloorToInt(val.x), Mathf.FloorToInt(val.y), Mathf.CeilToInt(val2.x), Mathf.CeilToInt(val2.y));
<entities>5__2 = ((TileModelSpatialLookupRO)(ref spatialLookupReadOnlyAndComplete)).GetEntities(ref val3, (TileType)255, 16, 16);
<>7__wrap2 = <entities>5__2.GetEnumerator();
break;
}
case 1:
<>1__state = -1;
break;
}
while (<>7__wrap2.MoveNext())
{
Entity current = <>7__wrap2.Current;
if (current.Has<T>() && current.Has<Translation>())
{
float3 value = current.Read<Translation>().Value;
if (math.distance(center, ((float3)(ref value)).xz) <= radius)
{
<>2__current = current;
<>1__state = 1;
return true;
}
}
}
<entities>5__2.Dispose();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<Entity> IEnumerable<Entity>.GetEnumerator()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
<GetAllEntitiesInRadius>d__8<T> <GetAllEntitiesInRadius>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<GetAllEntitiesInRadius>d__ = this;
}
else
{
<GetAllEntitiesInRadius>d__ = new <GetAllEntitiesInRadius>d__8<T>(0);
}
<GetAllEntitiesInRadius>d__.center = <>3__center;
<GetAllEntitiesInRadius>d__.radius = <>3__radius;
return <GetAllEntitiesInRadius>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<Entity>)this).GetEnumerator();
}
}
public static AdminAuthSystem adminAuthSystem = Core.Server.GetExistingSystemManaged<AdminAuthSystem>();
public static ClanSystem_Server clanSystem = Core.Server.GetExistingSystemManaged<ClanSystem_Server>();
public static EntityCommandBufferSystem entityCommandBufferSystem = Core.Server.GetExistingSystemManaged<EntityCommandBufferSystem>();
public static PrefabGUID GetPrefabGUID(Entity entity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.EntityManager;
PrefabGUID componentData = default(PrefabGUID);
try
{
componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(entity);
return componentData;
}
catch
{
((PrefabGUID)(ref componentData))..ctor(0);
}
return componentData;
}
public static bool TryGetClanEntityFromPlayer(Entity User, out Entity ClanEntity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (User.Read<TeamReference>().Value._Value.ReadBuffer<TeamAllies>().Length > 0)
{
ClanEntity = User.Read<TeamReference>().Value._Value.ReadBuffer<TeamAllies>()[0].Value;
return true;
}
ClanEntity = default(Entity);
return false;
}
public static Entity AddItemToInventory(Entity recipient, PrefabGUID guid, int amount)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
try
{
ServerGameManager serverGameManager = Core.Server.GetExistingSystemManaged<ServerScriptMapper>()._ServerGameManager;
return ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(recipient, guid, amount).NewEntity;
}
catch (Exception e)
{
Core.LogException(e, "AddItemToInventory");
}
return default(Entity);
}
public static NativeArray<Entity> GetEntitiesByComponentType<T1>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
EntityQueryOptions val = (EntityQueryOptions)0;
if (includeAll)
{
val = (EntityQueryOptions)(val | 0xC3);
}
if (includeDisabled)
{
val = (EntityQueryOptions)(val | 2);
}
if (includeSpawn)
{
val = (EntityQueryOptions)(val | 0x40);
}
if (includePrefab)
{
val = (EntityQueryOptions)(val | 1);
}
if (includeDestroyed)
{
val = (EntityQueryOptions)(val | 0x80);
}
EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2));
val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0));
EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions(val);
EntityManager entityManager = Core.EntityManager;
EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3);
return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
EntityQueryOptions val = (EntityQueryOptions)0;
if (includeAll)
{
val = (EntityQueryOptions)(val | 0xC3);
}
if (includeDisabled)
{
val = (EntityQueryOptions)(val | 2);
}
if (includeSpawn)
{
val = (EntityQueryOptions)(val | 0x40);
}
if (includePrefab)
{
val = (EntityQueryOptions)(val | 1);
}
if (includeDestroyed)
{
val = (EntityQueryOptions)(val | 0x80);
}
EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2));
val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0));
val2 = ((EntityQueryBuilder)(ref val2)).AddAll(new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0));
EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions(val);
EntityManager entityManager = Core.EntityManager;
EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3);
return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
[IteratorStateMachine(typeof(<GetAllEntitiesInRadius>d__8<>))]
public static IEnumerable<Entity> GetAllEntitiesInRadius<T>(float2 center, float radius)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetAllEntitiesInRadius>d__8<T>(-2)
{
<>3__center = center,
<>3__radius = radius
};
}
public static Entity FindClosestTilePosition(Vector3 pos, bool ignoreFloors = false)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
TileModelSpatialLookupSystemData tileModelLookupSystemData = Core.GenerateCastle._TileModelLookupSystemData;
TileModelSpatialLookupRO spatialLookupReadOnlyAndComplete = ((TileModelSpatialLookupSystemData)(ref tileModelLookupSystemData)).GetSpatialLookupReadOnlyAndComplete((SystemBase)(object)Core.GenerateCastle);
float3 val = ConvertPosToTileGrid(float3.op_Implicit(pos));
BoundsMinMax val2 = default(BoundsMinMax);
((BoundsMinMax)(ref val2))..ctor((int)((double)val.x - 2.5), (int)((double)val.z - 2.5), (int)((double)val.x + 2.5), (int)((double)val.z + 2.5));
Entity result = Entity.Null;
float num = float.MaxValue;
NativeList<Entity> entities = ((TileModelSpatialLookupRO)(ref spatialLookupReadOnlyAndComplete)).GetEntities(ref val2, (TileType)255, 16, 16);
for (int i = 0; i < entities.Length; i++)
{
Entity val3 = entities[i];
if (val3.Has<TilePosition>() && val3.Has<Translation>() && (!ignoreFloors || !val3.Has<CastleFloor>()))
{
float3 value = val3.Read<Translation>().Value;
float num2 = math.distancesq(float3.op_Implicit(pos), value);
if (num2 < num && GetPrefabGUID(val3).LookupName().StartsWith("TM_"))
{
num = num2;
result = val3;
}
}
}
entities.Dispose();
return result;
}
public static float2 ConvertPosToTileGrid(float2 pos)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
return new float2((float)(Mathf.FloorToInt(pos.x * 2f) + 6400), (float)(Mathf.FloorToInt(pos.y * 2f) + 6400));
}
public static float3 ConvertPosToTileGrid(float3 pos)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
return new float3((float)(Mathf.FloorToInt(pos.x * 2f) + 6400), pos.y, (float)(Mathf.FloorToInt(pos.z * 2f) + 6400));
}
public static void RepairGear(Entity Character, bool repair = true)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
Equipment val = Character.Read<Equipment>();
NativeList<Entity> val2 = default(NativeList<Entity>);
val2..ctor(AllocatorHandle.op_Implicit((Allocator)2));
((Equipment)(ref val)).GetAllEquipmentEntities(val2, false);
Enumerator<Entity> enumerator = val2.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (current.Has<Durability>())
{
Durability val3 = current.Read<Durability>();
if (repair)
{
val3.Value = val3.MaxDurability;
}
else
{
val3.Value = 0f;
}
current.Write<Durability>(val3);
}
}
val2.Dispose();
InventoryBuffer val4 = default(InventoryBuffer);
for (int i = 0; i < 36; i++)
{
if (!InventoryUtilities.TryGetItemAtSlot<EntityManager>(Core.EntityManager, Character, i, ref val4))
{
continue;
}
Entity entity = val4.ItemEntity._Entity;
if (entity.Has<Durability>())
{
Durability val5 = entity.Read<Durability>();
if (repair)
{
val5.Value = val5.MaxDurability;
}
else
{
val5.Value = 0f;
}
entity.Write<Durability>(val5);
}
}
}
public static void ReviveCharacter(Entity Character, Entity User, ChatCommandContext ctx = null)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
Health val = Character.Read<Health>();
if (ctx != null)
{
ctx.Reply("TryGetbuff");
}
Entity val2 = default(Entity);
if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, Character, PrefabIdentifier.op_Implicit(Prefabs.Buff_General_Vampire_Wounded_Buff), ref val2))
{
if (ctx != null)
{
ctx.Reply("Destroy");
}
DestroyUtility.Destroy(Core.EntityManager, val2, (DestroyDebugReason)13, (string)null, 0);
if (ctx != null)
{
ctx.Reply("Health");
}
val.Value = ModifiableFloat.op_Implicit(val.MaxHealth);
val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth);
Character.Write<Health>(val);
}
if (val.IsDead)
{
if (ctx != null)
{
ctx.Reply("Respawn");
}
LocalToWorld val3 = Character.Read<LocalToWorld>();
float3 position = ((LocalToWorld)(ref val3)).Position;
Nullable_Unboxed<float3> val4 = default(Nullable_Unboxed<float3>);
val4.value = position;
Nullable_Unboxed<float3> val5 = val4;
if (ctx != null)
{
ctx.Reply("Respawn2");
}
ServerBootstrapSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<ServerBootstrapSystem>();
EntityCommandBuffer val6 = Core.Server.GetExistingSystemManaged<EntityCommandBufferSystem>().CreateCommandBuffer();
if (ctx != null)
{
ctx.Reply("Respawn3");
}
existingSystemManaged.RespawnCharacter(val6, User, val5, Character, default(Entity), -1);
}
}
public static void KickPlayer(Entity userEntity)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.Server.EntityManager;
User val = userEntity.Read<User>();
if (val.IsConnected && val.PlatformId != 0L)
{
Entity entity = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
{
ComponentType.ReadOnly<NetworkEventType>(),
ComponentType.ReadOnly<SendEventToUser>(),
ComponentType.ReadOnly<KickEvent>()
});
entity.Write<KickEvent>(new KickEvent
{
PlatformId = val.PlatformId
});
entity.Write<SendEventToUser>(new SendEventToUser
{
UserIndex = val.Index
});
entity.Write<NetworkEventType>(new NetworkEventType
{
EventId = NetworkEvents.EventId_KickEvent,
IsAdminEvent = false,
IsDebugEvent = false
});
}
}
public static void UnlockWaypoints(Entity userEntity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.EntityManager;
DynamicBuffer<UnlockedWaypointElement> val = ((EntityManager)(ref entityManager)).AddBuffer<UnlockedWaypointElement>(userEntity);
val.Clear();
Enumerator<Entity> enumerator = GetEntitiesByComponentType<ChunkWaypoint>().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
val.Add(new UnlockedWaypointElement
{
Waypoint = current.Read<NetworkId>()
});
}
}
public static void RevealMapForPlayer(Entity userEntity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.EntityManager;
Enumerator<UserMapZoneElement> enumerator = ((EntityManager)(ref entityManager)).GetBuffer<UserMapZoneElement>(userEntity, false).GetEnumerator();
while (enumerator.MoveNext())
{
UserMapZoneElement current = enumerator.Current;
NetworkedEntity userZoneEntity = current.UserZoneEntity;
Entity entityOnServer = ((NetworkedEntity)(ref userZoneEntity)).GetEntityOnServer();
entityManager = Core.EntityManager;
DynamicBuffer<UserMapZonePackedRevealElement> buffer = ((EntityManager)(ref entityManager)).GetBuffer<UserMapZonePackedRevealElement>(entityOnServer, false);
buffer.Clear();
UserMapZonePackedRevealElement val = default(UserMapZonePackedRevealElement);
val.PackedPixel = byte.MaxValue;
UserMapZonePackedRevealElement val2 = val;
for (int i = 0; i < 8192; i++)
{
buffer.Add(val2);
}
}
}
}
[BepInPlugin("aa.odjit.KindredCommands", "KindredCommands", "2.5.8")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
internal static Harmony Harmony;
internal static ManualLogSource PluginLog;
public static ManualLogSource LogInstance { get; private set; }
public override void Load()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
if (!(Application.productName != "VRisingServer"))
{
PluginLog = ((BasePlugin)this).Log;
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("aa.odjit.KindredCommands");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("2.5.8");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
LogInstance = ((BasePlugin)this).Log;
Database.InitConfig();
Harmony = new Harmony("aa.odjit.KindredCommands");
Harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll();
}
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
public void OnGameInitialized()
{
if (!HasLoaded())
{
((BasePlugin)this).Log.LogDebug((object)"Attempt to initialize before everything has loaded.");
}
else
{
Core.InitializeAfterLoaded();
}
}
private static bool HasLoaded()
{
PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
if (existingSystemManaged == null)
{
return false;
}
return existingSystemManaged.SpawnableNameToPrefabGuidDictionary.Count > 0;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "aa.odjit.KindredCommands";
public const string PLUGIN_NAME = "KindredCommands";
public const string PLUGIN_VERSION = "2.5.8";
}
}
namespace KindredCommands.Services
{
[HarmonyBefore(new string[] { "gg.deca.VampireCommandFramework" })]
[HarmonyPatch(typeof(ServerBootstrapSystem), "SendRevealedMapData")]
public static class RevealedMapDataPatch
{
public static void Prefix(ServerBootstrapSystem __instance, Entity userEntity, User user)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (Core.ConfigSettings == null)
{
Core.InitializeAfterLoaded();
}
if (Core.ConfigSettings.RevealMapToAll)
{
User val = userEntity.Read<User>();
if (((FixedString64Bytes)(ref val.CharacterName)).IsEmpty)
{
Helper.RevealMapForPlayer(userEntity);
}
}
}
}
internal class AdminService
{
public static void AdminUser(Entity userEntity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
User val = userEntity.Read<User>();
EntityManager entityManager = Core.EntityManager;
EntityArchetype val2 = ((EntityManager)(ref entityManager)).CreateArchetype((ComponentType[])(object)new ComponentType[2]
{
ComponentType.ReadWrite<FromCharacter>(),
ComponentType.ReadWrite<AdminAuthEvent>()
});
entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).CreateEntity(val2).Write<FromCharacter>(new FromCharacter
{
Character = ((NetworkedEntity)(ref val.LocalCharacter)).GetEntityOnServer(),
User = userEntity
});
}
}
internal class AnnouncementsService
{
public struct Announcement
{
public string Name { get; set; }
public string Time { get; set; }
public string Message { get; set; }
public bool OneTime { get; set; }
}
[CompilerGenerated]
private sealed class <MessageCoroutine>d__7 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Announcement announcement;
public AnnouncementsService <>4__this;
private DateTime <announcementTime>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <MessageCoroutine>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
int num = <>1__state;
AnnouncementsService announcementsService = <>4__this;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
FixedString512Bytes val = FixedString512Bytes.op_Implicit(announcement.Message);
ServerChatUtils.SendSystemMessageToAllClients(Core.EntityManager, ref val);
<announcementTime>5__2 = <announcementTime>5__2.AddDays(1.0);
announcementsService.SortAnnouncements();
if (announcement.OneTime)
{
announcementsService.announcements.Remove(announcement);
announcementsService.announcementCoroutines.Remove(announcement.Name);
announcementsService.SaveAnnoucements();
return false;
}
}
else
{
<>1__state = -1;
if (!DateTime.TryParse(announcement.Time, out <announcementTime>5__2))
{
ManualLogSource log = Core.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(64, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to parse time for announcement ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(announcement.Name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" with time ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(announcement.Time);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" and message \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(announcement.Message);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\"");
}
log.LogError(val2);
return false;
}
if (!announcement.OneTime && <announcementTime>5__2 < DateTime.Now)
{
<announcementTime>5__2 = <announcementTime>5__2.AddDays(1.0);
}
}
<>2__current = (object)new WaitForSecondsRealtime((float)(<announcementTime>5__2 - DateTime.Now).TotalSeconds);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static readonly string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "KindredCommands");
private static readonly string ANNOUNCEMENTS_PATH = Path.Combine(CONFIG_PATH, "announcements.json");
private readonly List<Announcement> announcements = new List<Announcement>();
private Dictionary<string, Coroutine> announcementCoroutines = new Dictionary<string, Coroutine>();
public AnnouncementsService()
{
LoadAnnoucements();
}
private void ScheduleAnnouncement(Announcement announcement)
{
Coroutine val = Core.StartCoroutine(MessageCoroutine(announcement));
if (val != null)
{
announcementCoroutines[announcement.Name] = val;
}
}
[IteratorStateMachine(typeof(<MessageCoroutine>d__7))]
private IEnumerator MessageCoroutine(Announcement announcement)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MessageCoroutine>d__7(0)
{
<>4__this = this,
announcement = announcement
};
}
public bool AddAnnouncement(string name, string message, DateTime time, bool oneTime)
{
string nameLower = name.ToLowerInvariant();
if (announcements.Where((Announcement a) => a.Name.ToLowerInvariant() == nameLower).Any())
{
return false;
}
Announcement announcement = default(Announcement);
announcement.Name = name;
announcement.Time = time.ToString();
announcement.Message = message;
announcement.OneTime = oneTime;
Announcement announcement2 = announcement;
announcements.Add(announcement2);
ScheduleAnnouncement(announcement2);
SortAnnouncements();
SaveAnnoucements();
return true;
}
private void SortAnnouncements()
{
announcements.Sort(AnnouncementCompare);
static int AnnouncementCompare(Announcement x, Announcement y)
{
if (!DateTime.TryParse(x.Time, out var result))
{
return -1;
}
if (!DateTime.TryParse(y.Time, out var result2))
{
return 1;
}
DateTime now = DateTime.Now;
if (result < now)
{
result = result.AddDays(1.0);
}
if (result2 < now)
{
result2 = result2.AddDays(1.0);
}
int num = DateTime.Compare(result, result2);
if (num == 0)
{
num = string.Compare(x.Name, y.Name, StringComparison.InvariantCultureIgnoreCase);
}
return num;
}
}
public bool RemoveAnnouncement(string name)
{
string nameLower = name.ToLowerInvariant();
IEnumerable<string> source = from a in announcements
where a.Name.ToLowerInvariant() == nameLower
select a into x
select x.Name;
if (!source.Any())
{
return false;
}
name = source.First();
announcements.RemoveAll((Announcement a) => a.Name == name);
if (!announcementCoroutines.TryGetValue(name, out var value))
{
SaveAnnoucements();
return true;
}
Core.StopCoroutine(value);
announcementCoroutines.Remove(name);
SaveAnnoucements();
return true;
}
public IEnumerable<Announcement> GetAnnouncements()
{
return announcements;
}
private void LoadAnnoucements()
{
if (File.Exists(ANNOUNCEMENTS_PATH))
{
string json = File.ReadAllText(ANNOUNCEMENTS_PATH);
announcements.Clear();
announcements.AddRange(JsonSerializer.Deserialize<Announcement[]>(json));
SortAnnouncements();
foreach (Coroutine value in announcementCoroutines.Values)
{
Core.StopCoroutine(value);
}
announcementCoroutines.Clear();
{
foreach (Announcement announcement in announcements)
{
ScheduleAnnouncement(announcement);
}
return;
}
}
SaveAnnoucements();
}
private void SaveAnnoucements()
{
if (!Directory.Exists(CONFIG_PATH))
{
Directory.CreateDirectory(CONFIG_PATH);
}
JsonSerializerOptions options = new JsonSerializerOptions
{
WriteIndented = true
};
string contents = JsonSerializer.Serialize(announcements, options);
File.WriteAllText(ANNOUNCEMENTS_PATH, contents);
}
}
internal class AuditMiddleware : CommandMiddleware
{
public override void BeforeExecute(ICommandContext ctx, CommandAttribute attribute, MethodInfo method)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
ChatCommandContext val = (ChatCommandContext)ctx;
string text = method.DeclaringType.Assembly.GetName().Name;
if (method.DeclaringType.IsDefined(typeof(CommandGroupAttribute)))
{
CommandGroupAttribute val2 = (CommandGroupAttribute)Attribute.GetCustomAttribute(method.DeclaringType, typeof(CommandGroupAttribute), inherit: false);
text = text + "." + val2.Name;
}
text = text + "." + attribute.Name;
Core.AuditService.LogCommandUsage(val.Event.User, text);
}
}
internal class AuditService : IDisposable
{
private static readonly string CONFIG_PATH = Path.Combine(Paths.ConfigPath, "KindredCommands");
private static readonly string AUDIT_PATH = Path.Combine(CONFIG_PATH, "audit-" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".csv");
private const string DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.fff";
private readonly ConcurrentQueue<string> _auditQueue = new ConcurrentQueue<string>();
private readonly AutoResetEvent _signal = new AutoResetEvent(initialState: false);
private readonly Task _processingTask;
private bool _isDisposed;
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private static bool inExecuteCommandWithArgs = false;
private static bool inHelpCmd = false;
private static bool InExecute
{
get
{
if (inExecuteCommandWithArgs)
{
return !inHelpCmd;
}
return false;
}
}
public AuditService()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(typeof(CommandRegistry), "CanCommandExecute", (Type[])null, (Type[])null);
HarmonyMethod val = new HarmonyMethod(typeof(AuditService), "CanCommandExecutePostfix", (Type[])null);
Plugin.Harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
HookUpForSeeingIfCheckingPermission();
AuditMiddleware item = new AuditMiddleware();
CommandRegistry.Middlewares.Add((CommandMiddleware)(object)item);
Directory.CreateDirectory(CONFIG_PATH);
_processingTask = Task.Run((Func<Task?>)ProcessQueueAsync, _cancellationTokenSource.Token);
}
private async Task ProcessQueueAsync()
{
while (!_cancellationTokenSource.Token.IsCancellationRequested)
{
await Task.Run(() => _signal.WaitOne(TimeSpan.FromSeconds(1.0)), _cancellationTokenSource.Token);
string result;
while (_auditQueue.TryDequeue(out result) && !_cancellationTokenSource.Token.IsCancellationRequested)
{
try
{
File.AppendAllText(AUDIT_PATH, result);
}
catch (Exception ex)
{
Console.WriteLine("Error writing to audit log: " + ex.Message);
}
}
}
}
private static void CanCommandExecutePostfix(ICommandContext ctx, object command, ref bool __result)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
if (__result || !InExecute)
{
return;
}
ChatCommandContext val = (ChatCommandContext)ctx;
try
{
PropertyInfo property = command.GetType().GetProperty("Method");
if (property == null)
{
return;
}
MethodInfo methodInfo = property.GetValue(command) as MethodInfo;
if (methodInfo == null)
{
return;
}
string text = methodInfo.DeclaringType.Assembly.GetName().Name;
PropertyInfo proper#define TRACE
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using NetTopologySuite.Algorithm;
using NetTopologySuite.Algorithm.Construct;
using NetTopologySuite.Algorithm.Distance;
using NetTopologySuite.Algorithm.Locate;
using NetTopologySuite.EdgeGraph;
using NetTopologySuite.Geometries;
using NetTopologySuite.Geometries.Implementation;
using NetTopologySuite.Geometries.Prepared;
using NetTopologySuite.Geometries.Utilities;
using NetTopologySuite.GeometriesGraph;
using NetTopologySuite.GeometriesGraph.Index;
using NetTopologySuite.IO;
using NetTopologySuite.IO.GML2;
using NetTopologySuite.Index;
using NetTopologySuite.Index.Chain;
using NetTopologySuite.Index.HPRtree;
using NetTopologySuite.Index.IntervalRTree;
using NetTopologySuite.Index.KdTree;
using NetTopologySuite.Index.Quadtree;
using NetTopologySuite.Index.Strtree;
using NetTopologySuite.Mathematics;
using NetTopologySuite.Noding;
using NetTopologySuite.Noding.Snap;
using NetTopologySuite.Noding.Snapround;
using NetTopologySuite.Operation;
using NetTopologySuite.Operation.Buffer;
using NetTopologySuite.Operation.Distance;
using NetTopologySuite.Operation.Overlay;
using NetTopologySuite.Operation.Overlay.Snap;
using NetTopologySuite.Operation.OverlayNG;
using NetTopologySuite.Operation.Predicate;
using NetTopologySuite.Operation.Relate;
using NetTopologySuite.Operation.RelateNG;
using NetTopologySuite.Operation.Union;
using NetTopologySuite.Operation.Valid;
using NetTopologySuite.Planargraph;
using NetTopologySuite.Planargraph.Algorithm;
using NetTopologySuite.Precision;
using NetTopologySuite.Shape.Fractal;
using NetTopologySuite.Simplify;
using NetTopologySuite.Triangulate;
using NetTopologySuite.Triangulate.Polygon;
using NetTopologySuite.Triangulate.QuadEdge;
using NetTopologySuite.Triangulate.Tri;
using NetTopologySuite.Utilities;
using RTools_NTS.Util;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyDelaySign(false)]
[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]
[assembly: Guid("6B7EB658-792E-4178-B853-8AEB851513A9")]
[assembly: InternalsVisibleTo("NetTopologySuite.Tests.NUnit, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e5a9697e3d378de4bdd1607b9a6ea7884823d3909f8de55b573416d9adb0ae25eebc39007d71a7228c500d6e846d54dcc2cd839056c38c0a5e86b73096d90504f753ea67c9b5e61ecfdb8edf0f1dfaf0455e9a0f9e124e16777baefcda2af9a5a9e48f0c3502891c79444dc2d75aa50b75d148e16f1401dcb18bc1638cc764a9")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("NetTopologySuite - Team")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2006 - 2025 NetTopologySuite - Team, Diego Guidi, John Diss (www.newgrove.com), Felix Obermaier (www.ivv-aachen.de), Todd Jackson, Joe Amenta")]
[assembly: AssemblyDescription("The NTS Topology Suite is an API for modelling and manipulating 2-dimensional linear geometry. It provides numerous geometric predicates and functions. NTS conforms to the Simple Features Specification.")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.6.0 (compatible with JTS 1.20.0)+97d26b92586448b52d5a4f0c060217f94f882c75")]
[assembly: AssemblyProduct("NetTopologySuite")]
[assembly: AssemblyTitle("NetTopologySuite")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NetTopologySuite/NetTopologySuite")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class IsReadOnlyAttribute : Attribute
{
}
}
internal static class Consts
{
public const string PublicKeyToken = "0024000004800000940000000602000000240000525341310004000001000100e5a9697e3d378de4bdd1607b9a6ea7884823d3909f8de55b573416d9adb0ae25eebc39007d71a7228c500d6e846d54dcc2cd839056c38c0a5e86b73096d90504f753ea67c9b5e61ecfdb8edf0f1dfaf0455e9a0f9e124e16777baefcda2af9a5a9e48f0c3502891c79444dc2d75aa50b75d148e16f1401dcb18bc1638cc764a9";
}
namespace RTools_NTS.Util
{
public class CharBuffer
{
private int capacity = 128;
private char[] buffer;
private int headIndex;
private int tailIndex;
public int Length
{
get
{
return tailIndex - headIndex;
}
set
{
tailIndex = headIndex + value;
if (tailIndex >= capacity)
{
throw new IndexOutOfRangeException("Tail index greater than capacity");
}
}
}
public int Capacity => capacity;
public char this[int index]
{
get
{
return buffer[index + headIndex];
}
set
{
buffer[index + headIndex] = value;
}
}
public CharBuffer()
{
buffer = new char[capacity];
}
public CharBuffer(int capacity)
{
this.capacity = capacity;
buffer = new char[capacity];
}
protected void Grow(int requestedLen)
{
int val = Math.Max(capacity * 2, requestedLen);
val = Math.Max(val, 16);
char[] destinationArray = new char[val];
Array.Copy(buffer, 0, destinationArray, 0, capacity);
buffer = destinationArray;
capacity = val;
}
protected void CheckCapacity(int requestedLength)
{
if (requestedLength + headIndex >= capacity)
{
if (requestedLength + headIndex > capacity >> 1 && requestedLength < capacity - 1)
{
ShiftToZero();
}
else
{
Grow(0);
}
}
}
protected void ShiftToZero()
{
int length = Length;
for (int i = 0; i < length; i++)
{
buffer[i] = buffer[i + headIndex];
}
headIndex = 0;
tailIndex = length;
}
public void SetBuffer(char[] b, int len)
{
capacity = b.Length;
buffer = b;
headIndex = 0;
tailIndex = len;
}
public void Append(char c)
{
if (tailIndex >= capacity)
{
CheckCapacity(Length + 1);
}
buffer[tailIndex++] = c;
}
public void Append(string s)
{
if (s.Length + tailIndex >= capacity)
{
CheckCapacity(Length + s.Length);
}
for (int i = 0; i < s.Length; i++)
{
buffer[tailIndex++] = s[i];
}
}
public void Append(CharBuffer s)
{
if (s.Length + tailIndex >= capacity)
{
CheckCapacity(Length + s.Length);
}
for (int i = 0; i < s.Length; i++)
{
buffer[tailIndex++] = s[i];
}
}
public void Remove(int i)
{
Remove(i, 1);
}
public void Remove(int i, int n)
{
n = Math.Min(n, Length);
if (i == 0)
{
headIndex += n;
}
else
{
Array.Copy(buffer, i + headIndex + n, buffer, i + headIndex, tailIndex - (i + headIndex + n));
}
}
public int IndexOf(char c)
{
for (int i = headIndex; i < tailIndex; i++)
{
if (buffer[i] == c)
{
return i - headIndex;
}
}
return -1;
}
public void Clear()
{
headIndex = 0;
tailIndex = 0;
}
public override string ToString()
{
return new string(buffer, headIndex, tailIndex - headIndex);
}
}
public class StreamTokenizerUntermException : Exception
{
public StreamTokenizerUntermException(string msg)
: base(msg)
{
}
}
public class StreamTokenizerUntermQuoteException : StreamTokenizerUntermException
{
public StreamTokenizerUntermQuoteException(string msg)
: base(msg)
{
}
}
public class StreamTokenizerUntermCommentException : StreamTokenizerUntermException
{
public StreamTokenizerUntermCommentException(string msg)
: base(msg)
{
}
}
[Flags]
public enum CharTypeBits : byte
{
Word = 1,
Comment = 2,
Whitespace = 4,
Quote = 8,
Digit = 0x10,
HexDigit = 0x20,
Eof = 0x40
}
public class StreamTokenizerSettings
{
private byte[] charTypes;
private bool grabWhitespace;
private bool grabEol;
private bool slashSlashComments;
private bool slashStarComments;
private bool grabComments;
private bool doUntermCheck;
private bool parseNumbers;
private bool parseHexNumbers;
public byte[] CharTypes => charTypes;
public bool GrabWhitespace
{
get
{
return grabWhitespace;
}
set
{
grabWhitespace = value;
}
}
public bool GrabEol
{
get
{
return grabEol;
}
set
{
grabEol = value;
}
}
public bool SlashSlashComments
{
get
{
return slashSlashComments;
}
set
{
slashSlashComments = value;
}
}
public bool SlashStarComments
{
get
{
return slashStarComments;
}
set
{
slashStarComments = value;
}
}
public bool GrabComments
{
get
{
return grabComments;
}
set
{
grabComments = value;
}
}
public bool DoUntermCheck
{
get
{
return doUntermCheck;
}
set
{
doUntermCheck = value;
}
}
public bool ParseNumbers
{
get
{
return parseNumbers;
}
set
{
if (value)
{
for (int i = 48; i <= 57; i++)
{
charTypes[i] |= 16;
}
}
else
{
byte b = 16;
for (int j = 48; j <= 57; j++)
{
charTypes[j] &= (byte)(~b);
}
}
parseNumbers = value;
}
}
public bool ParseHexNumbers
{
get
{
return parseHexNumbers;
}
set
{
parseHexNumbers = value;
if (parseHexNumbers)
{
for (int i = 48; i <= 57; i++)
{
charTypes[i] |= 32;
}
for (int j = 65; j <= 70; j++)
{
charTypes[j] |= 32;
}
for (int k = 97; k <= 102; k++)
{
charTypes[k] |= 32;
}
charTypes[120] |= 32;
}
else
{
byte b = 32;
for (int l = 65; l <= 70; l++)
{
charTypes[l] &= (byte)(~b);
}
for (int m = 97; m <= 102; m++)
{
charTypes[m] &= (byte)(~b);
}
charTypes[120] &= (byte)(~b);
}
}
}
public StreamTokenizerSettings()
{
charTypes = new byte[StreamTokenizer.NChars + 1];
SetDefaults();
}
public StreamTokenizerSettings(StreamTokenizerSettings other)
{
Copy(other);
}
public void Copy(StreamTokenizerSettings other)
{
charTypes = new byte[StreamTokenizer.NChars + 1];
Array.Copy(other.charTypes, 0, charTypes, 0, charTypes.Length);
grabWhitespace = other.grabWhitespace;
grabEol = other.grabEol;
slashSlashComments = other.slashSlashComments;
slashStarComments = other.slashStarComments;
grabComments = other.grabComments;
doUntermCheck = other.doUntermCheck;
parseHexNumbers = other.parseHexNumbers;
}
public bool SetDefaults()
{
slashStarComments = false;
grabComments = false;
slashSlashComments = false;
grabWhitespace = false;
doUntermCheck = true;
grabEol = false;
ResetCharTypeTable();
ParseNumbers = true;
ParseHexNumbers = true;
WordChars(65, 90);
WordChars(97, 122);
WhitespaceChars(0, 32);
QuoteChar(39);
QuoteChar(34);
WordChars(48, 57);
return true;
}
public bool SetupForCodeParse()
{
GrabWhitespace = true;
GrabComments = true;
SlashSlashComments = true;
DoUntermCheck = true;
SlashStarComments = true;
WordChar(95);
ParseNumbers = true;
ParseHexNumbers = true;
return true;
}
public void ResetCharTypeTable()
{
Array.Clear(charTypes, 0, charTypes.Length);
charTypes[StreamTokenizer.NChars] = 64;
}
public void WordChar(int c)
{
charTypes[c] |= 1;
}
public void WordChars(int startChar, int endChar)
{
for (int i = startChar; i <= endChar; i++)
{
charTypes[i] |= 1;
}
}
public void WordChars(string s)
{
for (int i = 0; i < s.Length; i++)
{
charTypes[(uint)s[i]] |= 1;
}
}
public void WhitespaceChar(int c)
{
charTypes[c] = 4;
}
public void WhitespaceChars(int startChar, int endChar)
{
for (int i = startChar; i <= endChar; i++)
{
charTypes[i] = 4;
}
}
public void OrdinaryChars(int startChar, int endChar)
{
for (int i = startChar; i <= endChar; i++)
{
charTypes[i] = 0;
}
}
public void OrdinaryChar(int c)
{
charTypes[c] = 0;
}
public void CommentChar(int c)
{
charTypes[c] = 2;
}
public void QuoteChar(int c)
{
charTypes[c] = 8;
}
public string CharTypeToString(byte ctype)
{
StringBuilder stringBuilder = new StringBuilder();
if (IsCharType(ctype, CharTypeBits.Quote))
{
stringBuilder.Append('q');
}
if (IsCharType(ctype, CharTypeBits.Comment))
{
stringBuilder.Append('m');
}
if (IsCharType(ctype, CharTypeBits.Whitespace))
{
stringBuilder.Append('w');
}
if (IsCharType(ctype, CharTypeBits.Digit))
{
stringBuilder.Append('d');
}
if (IsCharType(ctype, CharTypeBits.Word))
{
stringBuilder.Append('a');
}
if (IsCharType(ctype, CharTypeBits.Eof))
{
stringBuilder.Append('e');
}
if (stringBuilder.Length == 0)
{
stringBuilder.Append('c');
}
return stringBuilder.ToString();
}
public bool IsCharType(byte ctype, CharTypeBits type)
{
return ((uint)ctype & (uint)type) != 0;
}
public bool IsCharType(char c, CharTypeBits type)
{
return ((uint)charTypes[(uint)c] & (uint)type) != 0;
}
public bool IsCharType(int c, CharTypeBits type)
{
return ((uint)charTypes[c] & (uint)type) != 0;
}
public void Display()
{
Display(string.Empty);
}
public void Display(string prefix)
{
}
}
public class StreamTokenizer : IEnumerable<Token>, IEnumerable
{
private enum NextTokenState
{
Start,
Whitespace,
Word,
Quote,
EndQuote,
MaybeNumber,
MaybeComment,
MaybeHex,
HexGot0x,
HexNumber,
LineComment,
BlockComment,
EndBlockComment,
Char,
Eol,
Eof,
Invalid
}
[CompilerGenerated]
private sealed class <GetEnumerator>d__34 : IEnumerator<Token>, IEnumerator, IDisposable
{
private int <>1__state;
private Token <>2__current;
public StreamTokenizer <>4__this;
Token IEnumerator<Token>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GetEnumerator>d__34(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
StreamTokenizer streamTokenizer = <>4__this;
Token token;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
streamTokenizer.lineNumber = 1;
goto IL_005d;
case 1:
<>1__state = -1;
goto IL_005d;
case 2:
{
<>1__state = -1;
return false;
}
IL_005d:
if (streamTokenizer.NextToken(out token))
{
if (token == null)
{
throw new NullReferenceException("StreamTokenizer: Tokenize: Got a null token from NextToken.");
}
<>2__current = token;
<>1__state = 1;
return true;
}
<>2__current = token;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static readonly int NChars = 128;
private static readonly int Eof = NChars;
private TextReader textReader;
private int lineNumber;
private CharBuffer backString;
private CharBuffer nextTokenSb;
private CharBuffer tmpSb;
private CharBuffer expSb;
private StreamTokenizerSettings settings;
public TextReader TextReader
{
get
{
return textReader;
}
set
{
textReader = value;
}
}
public StreamTokenizerSettings Settings => settings;
public StreamTokenizer()
{
Initialize();
}
public StreamTokenizer(TextReader sr)
{
Initialize();
textReader = sr;
}
public StreamTokenizer(TextReader sr, StreamTokenizerSettings tokenizerSettings)
{
settings = tokenizerSettings;
Initialize();
textReader = sr;
}
public StreamTokenizer(string str)
{
Initialize();
textReader = new StringReader(str);
}
private void Initialize()
{
backString = new CharBuffer(32);
nextTokenSb = new CharBuffer(1024);
InitializeStream();
if (settings == null)
{
settings = new StreamTokenizerSettings();
settings.SetDefaults();
}
expSb = new CharBuffer();
tmpSb = new CharBuffer();
}
private void InitializeStream()
{
lineNumber = 1;
textReader = null;
}
public void Display()
{
Display(string.Empty);
}
public void Display(string prefix)
{
if (settings != null)
{
settings.Display(prefix + " ");
}
}
private NextTokenState PickNextState(byte ctype, int c)
{
return PickNextState(ctype, c, NextTokenState.Start);
}
private NextTokenState PickNextState(byte ctype, int c, NextTokenState excludeState)
{
if (c == 47)
{
return NextTokenState.MaybeComment;
}
if (excludeState != NextTokenState.MaybeHex && settings.ParseHexNumbers && c == 48)
{
return NextTokenState.MaybeHex;
}
if (excludeState != NextTokenState.MaybeNumber && settings.ParseNumbers && (settings.IsCharType(ctype, CharTypeBits.Digit) || c == 45 || c == 46))
{
return NextTokenState.MaybeNumber;
}
if (settings.IsCharType(ctype, CharTypeBits.Word))
{
return NextTokenState.Word;
}
if (settings.GrabEol && c == 10)
{
return NextTokenState.Eol;
}
if (settings.IsCharType(ctype, CharTypeBits.Whitespace))
{
return NextTokenState.Whitespace;
}
if (settings.IsCharType(ctype, CharTypeBits.Comment))
{
return NextTokenState.LineComment;
}
if (settings.IsCharType(ctype, CharTypeBits.Quote))
{
return NextTokenState.Quote;
}
if (c == Eof || settings.IsCharType(ctype, CharTypeBits.Eof))
{
return NextTokenState.Eof;
}
return NextTokenState.Char;
}
private int GetNextChar()
{
int result;
if (backString.Length > 0)
{
result = backString[0];
backString.Remove(0, 1);
return result;
}
if (textReader == null)
{
return Eof;
}
try
{
while ((result = textReader.Read()) == 13)
{
}
}
catch (Exception)
{
return Eof;
}
if (result == 10)
{
lineNumber++;
}
else if (result < 0)
{
result = Eof;
}
return result;
}
public bool NextToken(out Token token)
{
token = null;
int num = 0;
NextTokenState nextTokenState = NextTokenState.Start;
int num2 = 0;
byte b = 64;
if (nextTokenSb.Length > 0)
{
num2 = nextTokenSb[nextTokenSb.Length - 1];
b = settings.CharTypes[num2];
nextTokenState = PickNextState(b, num2);
}
int num3 = 0;
int num4 = 0;
bool flag = false;
int num5 = lineNumber;
num = num2;
bool flag2 = false;
while (!flag2)
{
num2 = num;
num = GetNextChar();
byte ctype = (byte)((num >= settings.CharTypes.Length) ? 1 : settings.CharTypes[num]);
switch (nextTokenState)
{
case NextTokenState.Start:
nextTokenState = PickNextState(ctype, num);
num5 = lineNumber;
break;
case NextTokenState.Char:
token = new CharToken((char)num2, num5);
flag2 = true;
nextTokenSb.Length = 0;
break;
case NextTokenState.Word:
if (!settings.IsCharType(ctype, CharTypeBits.Word) && !settings.IsCharType(ctype, CharTypeBits.Digit))
{
token = new WordToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
break;
case NextTokenState.Whitespace:
if (!settings.IsCharType(ctype, CharTypeBits.Whitespace) || (settings.GrabEol && num == 10))
{
if (settings.GrabWhitespace)
{
token = new WhitespaceToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
else
{
nextTokenSb.Length = 0;
num5 = lineNumber;
nextTokenState = PickNextState(ctype, num);
}
}
break;
case NextTokenState.EndQuote:
token = new QuoteToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
break;
case NextTokenState.Quote:
if (num == nextTokenSb[0])
{
int num6 = 0;
int num7 = nextTokenSb.Length - 1;
while (num7 >= 0 && nextTokenSb[num7] == '\\')
{
num6++;
num7--;
}
if (num6 % 2 == 0)
{
nextTokenState = NextTokenState.EndQuote;
}
}
if (nextTokenState != NextTokenState.EndQuote && num == Eof)
{
if (settings.DoUntermCheck)
{
nextTokenSb.Length = 0;
throw new StreamTokenizerUntermQuoteException("Unterminated quote");
}
token = new QuoteToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
break;
case NextTokenState.MaybeComment:
if (num == Eof)
{
token = new CharToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
else if (settings.SlashSlashComments && num == 47)
{
nextTokenState = NextTokenState.LineComment;
}
else if (settings.SlashStarComments && num == 42)
{
nextTokenState = NextTokenState.BlockComment;
}
else
{
token = new CharToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
break;
case NextTokenState.LineComment:
if (num == Eof)
{
if (settings.GrabComments)
{
token = new CommentToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
else
{
nextTokenSb.Length = 0;
num5 = lineNumber;
nextTokenState = PickNextState(ctype, num);
}
}
else if (num == 10)
{
if (settings.GrabComments)
{
token = new CommentToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
else
{
nextTokenSb.Length = 0;
num5 = lineNumber;
nextTokenState = PickNextState(ctype, num);
}
}
break;
case NextTokenState.BlockComment:
if (num == Eof)
{
if (settings.DoUntermCheck)
{
nextTokenSb.Length = 0;
throw new StreamTokenizerUntermCommentException("Unterminated comment.");
}
if (settings.GrabComments)
{
token = new CommentToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
else
{
nextTokenSb.Length = 0;
num5 = lineNumber;
nextTokenState = PickNextState(ctype, num);
}
}
else if (num == 47 && num2 == 42)
{
nextTokenState = NextTokenState.EndBlockComment;
}
break;
case NextTokenState.EndBlockComment:
if (settings.GrabComments)
{
token = new CommentToken(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
else
{
nextTokenSb.Length = 0;
num5 = lineNumber;
nextTokenState = PickNextState(ctype, num);
}
break;
case NextTokenState.MaybeHex:
if (num != 120)
{
nextTokenSb.Append((char)num);
backString.Append(nextTokenSb);
nextTokenSb.Length = 0;
num = backString[0];
backString.Remove(0, 1);
nextTokenState = PickNextState(settings.CharTypes[num], num, NextTokenState.MaybeHex);
}
else
{
nextTokenState = NextTokenState.HexGot0x;
}
break;
case NextTokenState.HexGot0x:
if (!settings.IsCharType(ctype, CharTypeBits.HexDigit))
{
nextTokenSb.Append((char)num);
backString.Append(nextTokenSb);
nextTokenSb.Length = 0;
num = backString[0];
backString.Remove(0, 1);
nextTokenState = PickNextState(settings.CharTypes[num], num, NextTokenState.MaybeHex);
}
else
{
nextTokenState = NextTokenState.HexNumber;
}
break;
case NextTokenState.HexNumber:
if (!settings.IsCharType(ctype, CharTypeBits.HexDigit))
{
token = IntToken.ParseHex(nextTokenSb.ToString(), num5);
flag2 = true;
nextTokenSb.Length = 0;
}
break;
case NextTokenState.MaybeNumber:
{
bool flag3 = false;
if (settings.IsCharType(ctype, CharTypeBits.Digit) || settings.IsCharType(num2, CharTypeBits.Digit))
{
flag = true;
}
switch (num)
{
case 46:
num3++;
if (num3 > 1)
{
flag3 = true;
}
break;
case 69:
case 101:
{
num4++;
if (!flag)
{
flag3 = true;
break;
}
if (num4 > 1)
{
flag3 = true;
break;
}
flag3 = true;
expSb.Clear();
expSb.Append((char)num);
if (GrabInt(expSb, allowPlus: true, out var thisChar))
{
nextTokenSb.Append(expSb);
num = thisChar;
}
break;
}
default:
if (num == Eof)
{
flag3 = true;
}
else if ((!settings.IsCharType(ctype, CharTypeBits.Digit) && num != 101 && num != 69 && num != 45 && num != 46) || (num == 43 && num4 == 0))
{
flag3 = true;
}
else if (num == 45 && num2 != 101 && num2 != 69)
{
flag3 = true;
}
break;
}
if (!flag3)
{
break;
}
if (flag)
{
if (nextTokenSb.IndexOf('.') >= 0 || nextTokenSb.IndexOf('e') >= 0 || nextTokenSb.IndexOf('E') >= 0 || nextTokenSb.Length >= 19)
{
token = new FloatToken(nextTokenSb.ToString(), num5);
}
else
{
token = new IntToken(nextTokenSb.ToString(), num5);
}
flag2 = true;
nextTokenSb.Length = 0;
}
else
{
nextTokenSb.Append((char)num);
backString.Append(nextTokenSb);
nextTokenSb.Length = 0;
num = backString[0];
backString.Remove(0, 1);
nextTokenState = PickNextState(settings.CharTypes[num], num, NextTokenState.MaybeNumber);
}
break;
}
case NextTokenState.Eol:
token = new EolToken(num5 - 1);
flag2 = true;
nextTokenSb.Length = 0;
break;
case NextTokenState.Eof:
token = new EofToken(num5);
flag2 = true;
nextTokenSb.Length = 0;
return false;
default:
return false;
}
if (num != Eof)
{
nextTokenSb.Append((char)num);
}
}
return true;
}
private bool GrabInt(CharBuffer sb, bool allowPlus, out char thisChar)
{
tmpSb.Clear();
thisChar = (char)GetNextChar();
if (thisChar == Eof)
{
return false;
}
if (thisChar == '+')
{
if (!allowPlus)
{
backString.Append(thisChar);
return false;
}
tmpSb.Append(thisChar);
}
else if (thisChar == '-')
{
tmpSb.Append(thisChar);
}
else
{
if (!settings.IsCharType(thisChar, CharTypeBits.Digit))
{
backString.Append(thisChar);
return false;
}
backString.Append(thisChar);
}
bool flag = false;
while ((thisChar = (char)GetNextChar()) != Eof && settings.IsCharType(thisChar, CharTypeBits.Digit))
{
flag = true;
tmpSb.Append(thisChar);
}
if (flag)
{
sb.Append(tmpSb);
return true;
}
backString.Append(tmpSb);
if (thisChar != Eof)
{
backString.Append(thisChar);
}
return false;
}
public bool Tokenize(IList<Token> tokens)
{
lineNumber = 1;
Token token;
while (NextToken(out token))
{
if (token == null)
{
throw new NullReferenceException("StreamTokenizer: Tokenize: Got a null token from NextToken.");
}
tokens.Add(token);
}
tokens.Add(token);
return true;
}
public bool TokenizeReader(TextReader tr, IList<Token> tokens)
{
textReader = tr;
return Tokenize(tokens);
}
public bool TokenizeFile(string fileName, IList<Token> tokens)
{
FileInfo fileInfo = new FileInfo(fileName);
FileStream fileStream = null;
try
{
fileStream = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.None);
textReader = new StreamReader(fileStream);
}
catch (DirectoryNotFoundException)
{
}
try
{
if (!Tokenize(tokens))
{
textReader.Dispose();
fileStream?.Dispose();
return false;
}
}
catch (StreamTokenizerUntermException ex2)
{
textReader.Dispose();
fileStream?.Dispose();
throw ex2;
}
if (textReader != null)
{
textReader.Dispose();
}
fileStream?.Dispose();
return true;
}
public Token[] TokenizeFile(string fileName)
{
List<Token> list = new List<Token>();
if (!TokenizeFile(fileName, list))
{
return null;
}
if (list.Count > 0)
{
return list.ToArray();
}
return null;
}
public bool TokenizeString(string str, IList<Token> tokens)
{
textReader = new StringReader(str);
return Tokenize(tokens);
}
public bool TokenizeStream(Stream s, IList<Token> tokens)
{
textReader = new StreamReader(s);
return Tokenize(tokens);
}
[IteratorStateMachine(typeof(<GetEnumerator>d__34))]
public IEnumerator<Token> GetEnumerator()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetEnumerator>d__34(0)
{
<>4__this = this
};
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public abstract class Token
{
private readonly int _lineNumber;
protected object obj;
private bool untermError;
private string untermErrorMsg;
public int LineNumber => _lineNumber;
public object Object => obj;
public bool UntermError
{
get
{
return untermError;
}
set
{
untermError = value;
}
}
public string UntermErrorMsg
{
get
{
return untermErrorMsg;
}
set
{
untermError = true;
untermErrorMsg = value;
}
}
public virtual string StringValue => "unset";
public Token(int line)
{
obj = null;
untermError = false;
_lineNumber = line;
}
public override bool Equals(object other)
{
if (other == null)
{
return false;
}
if (!(other is Token))
{
return false;
}
return obj.Equals(((Token)other).obj);
}
public bool Equals(string s)
{
if (s == null)
{
return false;
}
return StringValue.Equals(s);
}
public bool Equals(char c)
{
if (!(this is CharToken))
{
return false;
}
return (this as CharToken).Object.Equals(c);
}
public static bool operator ==(Token t, object o)
{
if ((object)t == null)
{
if (o == null)
{
return true;
}
return false;
}
if (o == null)
{
return false;
}
return t.Equals(o);
}
public static bool operator !=(Token t, object o)
{
if ((object)t == null)
{
if (o == null)
{
return false;
}
return true;
}
return !t.Equals(o);
}
public static bool operator ==(Token t, char c)
{
return t?.Equals(c) ?? false;
}
public static bool operator !=(Token t, char c)
{
if ((object)t == null)
{
return false;
}
return !t.Equals(c);
}
public static bool operator ==(Token t, string s)
{
if ((object)t == null)
{
if (s == null)
{
return true;
}
return false;
}
return t.Equals(s);
}
public static bool operator !=(Token t, string s)
{
if ((object)t == null)
{
if (s == null)
{
return false;
}
return true;
}
return !t.Equals(s);
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
public string ToLineString()
{
return $"{ToDebugString()}: line {_lineNumber}";
}
public virtual string ToDebugString()
{
return $"{ToString()}: line {_lineNumber}";
}
public object ConvertToType(Type t)
{
return Convert.ChangeType(StringValue, t, CultureInfo.InvariantCulture);
}
}
public class EolToken : Token
{
public override string StringValue => ToString();
public EolToken()
: base(0)
{
}
public EolToken(int line)
: base(line)
{
}
public override string ToDebugString()
{
return "Eol";
}
public override string ToString()
{
return "\n";
}
public override bool Equals(object other)
{
if (!(other is EolToken))
{
return false;
}
return true;
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
}
public class EofToken : Token
{
public override string StringValue => ToString();
public EofToken()
: base(0)
{
}
public EofToken(int line)
: base(line)
{
}
public override string ToString()
{
return string.Empty;
}
public override string ToDebugString()
{
return "Eof";
}
public override bool Equals(object other)
{
if (!(other is EofToken))
{
return false;
}
return true;
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
}
public abstract class StringToken : Token
{
public override string StringValue => (string)obj;
public StringToken(string s)
: base(0)
{
obj = s;
}
public StringToken(string s, int line)
: base(line)
{
obj = s;
}
public override string ToDebugString()
{
return GetType().Name + ":'" + (string)obj + "'";
}
public override string ToString()
{
return (string)obj;
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
}
public class WordToken : StringToken
{
public WordToken(string s)
: base(s)
{
}
public WordToken(string s, int line)
: base(s, line)
{
}
}
public class QuoteToken : StringToken
{
public QuoteToken(string s)
: base(s)
{
}
public QuoteToken(string s, int line)
: base(s, line)
{
}
}
public class CommentToken : StringToken
{
public CommentToken(string s)
: base(s)
{
}
public CommentToken(string s, int line)
: base(s, line)
{
}
}
public class WhitespaceToken : StringToken
{
public WhitespaceToken(string s)
: base(s)
{
}
public WhitespaceToken(string s, int line)
: base(s, line)
{
}
}
public class CharToken : Token
{
public override string StringValue => $"{(char)obj}";
public CharToken(string s, int line)
: base(line)
{
if (s.Length > 0)
{
obj = s[0];
}
}
public CharToken(char c)
: base(0)
{
obj = c;
}
public CharToken(char c, int line)
: base(line)
{
obj = c;
}
public override string ToDebugString()
{
return $"CharToken: {(char)obj}";
}
public override string ToString()
{
return $"{(char)obj}";
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
public override bool Equals(object other)
{
if (other == null)
{
return false;
}
if (!GetType().Equals(other.GetType()))
{
return false;
}
if (obj == null || ((CharToken)other).obj == null)
{
return false;
}
if (((char)obj).Equals((char)((CharToken)other).Object))
{
return true;
}
return false;
}
}
public class FloatToken : Token
{
private NumberFormatInfo numberFormatInfo;
public override string StringValue
{
get
{
if (obj != null)
{
return string.Format(GetNumberFormatInfo(), "{0:R}", (double)obj);
}
return $"null";
}
}
private NumberFormatInfo GetNumberFormatInfo()
{
if (numberFormatInfo == null)
{
numberFormatInfo = new NumberFormatInfo();
numberFormatInfo.NumberDecimalSeparator = ".";
}
return numberFormatInfo;
}
public FloatToken(string s)
: base(0)
{
try
{
obj = double.Parse(s, GetNumberFormatInfo());
}
catch (Exception)
{
obj = null;
}
}
public FloatToken(float f)
: base(0)
{
try
{
obj = (double)f;
}
catch (Exception)
{
obj = null;
}
}
public FloatToken(double d)
: base(0)
{
try
{
obj = d;
}
catch (Exception)
{
obj = null;
}
}
public FloatToken(string s, int line)
: base(line)
{
try
{
obj = double.Parse(s, GetNumberFormatInfo());
}
catch (Exception)
{
obj = null;
}
}
public FloatToken(double f, int line)
: base(line)
{
try
{
obj = f;
}
catch (Exception)
{
obj = null;
}
}
public override string ToDebugString()
{
if (obj != null)
{
return $"FloatToken: {(double)obj:R}";
}
return $"FloatToken: null";
}
public override string ToString()
{
if (obj != null)
{
return $"{(double)obj:R}";
}
return $"null";
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
public override bool Equals(object other)
{
if (other == null)
{
return false;
}
if (!GetType().Equals(other.GetType()))
{
return false;
}
if (obj == null || ((FloatToken)other).obj == null)
{
return false;
}
if (((double)obj).Equals((double)((FloatToken)other).Object))
{
return true;
}
return false;
}
}
public class IntToken : Token
{
public override string StringValue
{
get
{
if (obj != null)
{
return $"{obj}";
}
return $"null";
}
}
public IntToken(int i)
: base(0)
{
obj = i;
}
public IntToken(long i)
: base(0)
{
obj = i;
}
public IntToken(string s)
: base(0)
{
Parse(s);
}
public IntToken(string s, int line)
: base(line)
{
Parse(s);
}
public IntToken(int i, int line)
: base(line)
{
obj = i;
}
public IntToken(long l, int line)
: base(line)
{
obj = l;
}
public static IntToken ParseHex(string s, int lineNumber)
{
IntToken intToken = null;
try
{
return new IntToken(Convert.ToInt32(s, 16), lineNumber);
}
catch
{
return new IntToken(Convert.ToInt64(s, 16), lineNumber);
}
}
private void Parse(string s)
{
if (int.TryParse(s, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out var result))
{
base.obj = result;
return;
}
if (long.TryParse(s, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out var result2))
{
base.obj = result2;
return;
}
int[] array = new int[3] { 16, 2, 8 };
foreach (int fromBase in array)
{
try
{
base.obj = Convert.ToInt32(s, fromBase);
return;
}
catch
{
try
{
base.obj = Convert.ToInt64(s, fromBase);
return;
}
catch
{
}
}
}
base.obj = null;
}
public override string ToDebugString()
{
if (obj != null)
{
return $"IntToken: {obj}";
}
return $"IntToken: null";
}
public override string ToString()
{
if (obj != null)
{
return $"{obj}";
}
return $"null";
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
public override bool Equals(object other)
{
if (other == null)
{
return false;
}
if (!GetType().Equals(other.GetType()))
{
return false;
}
if (obj == null || ((IntToken)other).obj == null)
{
return false;
}
if (!obj.GetType().Equals(((IntToken)other).obj.GetType()))
{
return false;
}
if (obj is int)
{
if (((int)obj).Equals((int)((IntToken)other).Object))
{
return true;
}
}
else if (((long)obj).Equals((long)((IntToken)other).Object))
{
return true;
}
return false;
}
}
public enum VerbosityLevel
{
Error,
Warn,
Info,
Debug
}
}
namespace NetTopologySuite
{
public class NtsGeometryServices
{
private readonly struct GeometryFactoryKey : IEquatable<GeometryFactoryKey>
{
public PrecisionModel PrecisionModel { get; }
public NetTopologySuite.Algorithm.ElevationModel ElevationModel { get; }
public CoordinateSequenceFactory CoordinateSequenceFactory { get; }
public int SRID { get; }
public GeometryFactoryKey(PrecisionModel precisionModel, NetTopologySuite.Algorithm.ElevationModel elevationModel, int srid, CoordinateSequenceFactory factory)
{
PrecisionModel = precisionModel;
ElevationModel = elevationModel;
CoordinateSequenceFactory = factory;
SRID = srid;
}
public override int GetHashCode()
{
return (PrecisionModel, CoordinateSequenceFactory, SRID, ElevationModel).GetHashCode();
}
public override bool Equals(object obj)
{
if (obj is GeometryFactoryKey other)
{
return Equals(other);
}
return false;
}
public bool Equals(GeometryFactoryKey other)
{
if (SRID == other.SRID && object.Equals(CoordinateSequenceFactory, other.CoordinateSequenceFactory) && object.Equals(PrecisionModel, other.PrecisionModel))
{
return object.Equals(ElevationModel, other.ElevationModel);
}
return false;
}
}
private static volatile NtsGeometryServices s_instance = new NtsGeometryServices();
[NonSerialized]
private readonly ConcurrentDictionary<GeometryFactoryKey, GeometryFactory> m_factories = new ConcurrentDictionary<GeometryFactoryKey, GeometryFactory>();
public static NtsGeometryServices Instance
{
get
{
return s_instance;
}
set
{
s_instance = value ?? throw new ArgumentNullException("value");
}
}
public GeometryOverlay GeometryOverlay { get; }
public GeometryRelate GeometryRelate { get; }
public CoordinateEqualityComparer CoordinateEqualityComparer { get; }
public int DefaultSRID { get; }
public CoordinateSequenceFactory DefaultCoordinateSequenceFactory { get; }
public PrecisionModel DefaultPrecisionModel { get; }
public NetTopologySuite.Algorithm.ElevationModel DefaultElevationModel { get; }
internal int NumFactories => m_factories.Count;
public NtsGeometryServices()
: this(GeometryOverlay.Legacy)
{
}
public NtsGeometryServices(GeometryOverlay geometryOverlay)
: this(CoordinateArraySequenceFactory.Instance, PrecisionModel.Floating.Value, -1, geometryOverlay, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(GeometryRelate geometryRelate)
: this(CoordinateArraySequenceFactory.Instance, PrecisionModel.Floating.Value, -1, GeometryOverlay.Legacy, geometryRelate, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(GeometryOverlay geometryOverlay, GeometryRelate geometryRelate)
: this(CoordinateArraySequenceFactory.Instance, PrecisionModel.Floating.Value, -1, geometryOverlay, geometryRelate, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(PrecisionModel precisionModel)
: this(CoordinateArraySequenceFactory.Instance, precisionModel, -1, GeometryOverlay.Legacy, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(PrecisionModel precisionModel, int srid)
: this(CoordinateArraySequenceFactory.Instance, precisionModel, srid, GeometryOverlay.Legacy, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(CoordinateSequenceFactory coordinateSequenceFactory)
: this(coordinateSequenceFactory, PrecisionModel.Floating.Value, -1, GeometryOverlay.Legacy, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(CoordinateSequenceFactory coordinateSequenceFactory, PrecisionModel precisionModel, int srid)
: this(coordinateSequenceFactory, precisionModel, srid, GeometryOverlay.Legacy, new CoordinateEqualityComparer())
{
}
public NtsGeometryServices(CoordinateSequenceFactory coordinateSequenceFactory, PrecisionModel precisionModel, int srid, GeometryOverlay geometryOverlay, CoordinateEqualityComparer coordinateEqualityComparer)
: this(coordinateSequenceFactory, precisionModel, srid, geometryOverlay, GeometryRelate.Legacy, coordinateEqualityComparer)
{
}
public NtsGeometryServices(CoordinateSequenceFactory coordinateSequenceFactory, PrecisionModel precisionModel, int srid, GeometryOverlay geometryOverlay, GeometryRelate geometryRelate, CoordinateEqualityComparer coordinateEqualityComparer)
: this(coordinateSequenceFactory, precisionModel, srid, geometryOverlay, geometryRelate, coordinateEqualityComparer, null)
{
}
public NtsGeometryServices(CoordinateSequenceFactory coordinateSequenceFactory, PrecisionModel precisionModel, int srid, GeometryOverlay geometryOverlay, GeometryRelate geometryRelate, CoordinateEqualityComparer coordinateEqualityComparer, NetTopologySuite.Algorithm.ElevationModel elevationModel)
{
DefaultCoordinateSequenceFactory = coordinateSequenceFactory ?? throw new ArgumentNullException("coordinateSequenceFactory");
DefaultPrecisionModel = precisionModel ?? throw new ArgumentNullException("precisionModel");
DefaultSRID = srid;
DefaultElevationModel = elevationModel;
GeometryOverlay = geometryOverlay ?? throw new ArgumentNullException("geometryOverlay");
GeometryRelate = geometryRelate ?? throw new ArgumentNullException("geometryRelate");
CoordinateEqualityComparer = coordinateEqualityComparer ?? throw new ArgumentNullException("coordinateEqualityComparer");
}
[Obsolete("Will be removed in a future version")]
public PrecisionModel CreatePrecisionModel(PrecisionModels modelType)
{
return new PrecisionModel(modelType);
}
[Obsolete("Will be removed in a future version")]
public PrecisionModel CreatePrecisionModel(PrecisionModel precisionModel)
{
return new PrecisionModel(precisionModel);
}
[Obsolete("Will be removed in a future version")]
public PrecisionModel CreatePrecisionModel(double scale)
{
return new PrecisionModel(scale);
}
public GeometryFactory CreateGeometryFactory()
{
return CreateGeometryFactory(DefaultSRID);
}
public GeometryFactory CreateGeometryFactory(int srid)
{
return CreateGeometryFactory(DefaultPrecisionModel, srid, DefaultCoordinateSequenceFactory);
}
public GeometryFactory CreateGeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory)
{
return CreateGeometryFactory(DefaultPrecisionModel, DefaultSRID, coordinateSequenceFactory);
}
public GeometryFactory CreateGeometryFactory(PrecisionModel precisionModel)
{
return CreateGeometryFactory(precisionModel, DefaultSRID, DefaultCoordinateSequenceFactory);
}
public GeometryFactory CreateGeometryFactory(PrecisionModel precisionModel, int srid)
{
return CreateGeometryFactory(precisionModel, srid, DefaultCoordinateSequenceFactory);
}
public GeometryFactory CreateGeometryFactory(PrecisionModel precisionModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory)
{
return CreateGeometryFactory(precisionModel, DefaultElevationModel, srid, coordinateSequenceFactory);
}
public GeometryFactory CreateGeometryFactory(PrecisionModel precisionModel, NetTopologySuite.Algorithm.ElevationModel elevationModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory)
{
if ((object)precisionModel == null)
{
throw new ArgumentNullException("precisionModel");
}
if (coordinateSequenceFactory == null)
{
throw new ArgumentNullException("coordinateSequenceFactory");
}
return m_factories.GetOrAdd(new GeometryFactoryKey(precisionModel, elevationModel, srid, coordinateSequenceFactory), (GeometryFactoryKey key) => CreateGeometryFactoryCore(key.PrecisionModel, key.ElevationModel, key.SRID, key.CoordinateSequenceFactory));
}
protected virtual GeometryFactory CreateGeometryFactoryCore(PrecisionModel precisionModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory)
{
return CreateGeometryFactoryCore(precisionModel, null, srid, coordinateSequenceFactory);
}
protected virtual GeometryFactory CreateGeometryFactoryCore(PrecisionModel precisionModel, NetTopologySuite.Algorithm.ElevationModel elevationModel, int srid, CoordinateSequenceFactory coordinateSequenceFactory)
{
return new GeometryFactory(precisionModel, elevationModel, srid, coordinateSequenceFactory, this);
}
}
}
namespace NetTopologySuite.Utilities
{
public sealed class AlternativePriorityQueue<TPriority, TData> : IEnumerable<PriorityQueueNode<TPriority, TData>>, IEnumerable
{
private const int DefaultCapacity = 4;
private readonly List<PriorityQueueNode<TPriority, TData>> nodes;
private readonly IComparer<TPriority> priorityComparer;
public int Count { get; private set; }
public PriorityQueueNode<TPriority, TData> Head => nodes[1];
public AlternativePriorityQueue()
: this(4)
{
}
public AlternativePriorityQueue(int capacity)
: this(capacity, (IComparer<TPriority>)null)
{
}
public AlternativePriorityQueue(IComparer<TPriority> priorityComparer)
: this(4, priorityComparer)
{
}
public AlternativePriorityQueue(int capacity, IComparer<TPriority> priorityComparer)
{
if (capacity < 1)
{
throw new ArgumentOutOfRangeException("capacity", "Capacity must be greater than zero.");
}
nodes = new List<PriorityQueueNode<TPriority, TData>>(capacity + 1);
for (int i = 0; i <= capacity; i++)
{
nodes.Add(null);
}
Count = 0;
this.priorityComparer = priorityComparer ?? Comparer<TPriority>.Default;
}
public AlternativePriorityQueue(AlternativePriorityQueue<TPriority, TData> copyFrom)
{
if (copyFrom == null)
{
throw new ArgumentNullException("copyFrom");
}
nodes = new List<PriorityQueueNode<TPriority, TData>>(copyFrom.nodes.Count);
priorityComparer = copyFrom.priorityComparer;
for (int i = 0; i < copyFrom.nodes.Count; i++)
{
PriorityQueueNode<TPriority, TData> priorityQueueNode = copyFrom.nodes[i];
PriorityQueueNode<TPriority, TData> item = ((priorityQueueNode == null) ? null : new PriorityQueueNode<TPriority, TData>(priorityQueueNode));
nodes.Add(item);
}
}
public void Clear()
{
nodes.Clear();
nodes.Add(null);
nodes.Add(null);
Count = 0;
}
public bool Contains(PriorityQueueNode<TPriority, TData> node)
{
if (node != null && node.QueueIndex < nodes.Count)
{
return nodes[node.QueueIndex] == node;
}
return false;
}
public void Enqueue(PriorityQueueNode<TPriority, TData> node, TPriority priority)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
node.Priority = priority;
node.QueueIndex = ++Count;
if (nodes.Count <= Count)
{
nodes.Add(null);
}
nodes[Count] = node;
HeapifyUp(nodes[Count]);
}
public PriorityQueueNode<TPriority, TData> Dequeue()
{
PriorityQueueNode<TPriority, TData> head = Head;
Remove(head);
return head;
}
public void ChangePriority(PriorityQueueNode<TPriority, TData> node, TPriority priority)
{
if (node == null)
{
throw new ArgumentNullException("node");
}
node.Priority = priority;
OnNodeUpdated(node);
}
public bool Remove(PriorityQueueNode<TPriority, TData> node)
{
if (!Contains(node))
{
return false;
}
if (Count <= 1)
{
nodes[1] = null;
Count = 0;
return true;
}
bool flag = false;
PriorityQueueNode<TPriority, TData> priorityQueueNode = nodes[Count];
if (node.QueueIndex != Count)
{
Swap(node, priorityQueueNode);
flag = true;
}
int count = Count - 1;
Count = count;
nodes[node.QueueIndex] = null;
if (flag)
{
OnNodeUpdated(priorityQueueNode);
}
return true;
}
public IEnumerator<PriorityQueueNode<TPriority, TData>> GetEnumerator()
{
return nodes.Skip(1).Take(Count).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
private void HeapifyUp(PriorityQueueNode<TPriority, TData> node)
{
int num = node.QueueIndex / 2;
while (num >= 1)
{
PriorityQueueNode<TPriority, TData> priorityQueueNode = nodes[num];
if (!HasHigherPriority(priorityQueueNode, node))
{
Swap(node, priorityQueueNode);
num = node.QueueIndex / 2;
continue;
}
break;
}
}
private void HeapifyDown(PriorityQueueNode<TPriority, TData> node)
{
int num = node.QueueIndex;
while (true)
{
PriorityQueueNode<TPriority, TData> priorityQueueNode = node;
int num2 = 2 * num;
if (num2 > Count)
{
node.QueueIndex = num;
nodes[num] = node;
return;
}
PriorityQueueNode<TPriority, TData> priorityQueueNode2 = nodes[num2];
if (HasHigherPriority(priorityQueueNode2, priorityQueueNode))
{
priorityQueueNode = priorityQueueNode2;
}
int num3 = num2 + 1;
if (num3 <= Count)
{
PriorityQueueNode<TPriority, TData> priorityQueueNode3 = nodes[num3];
if (HasHigherPriority(priorityQueueNode3, priorityQueueNode))
{
priorityQueueNode = priorityQueueNode3;
}
}
if (priorityQueueNode == node)
{
break;
}
nodes[num] = priorityQueueNode;
int queueIndex = priorityQueueNode.QueueIndex;
priorityQueueNode.QueueIndex = num;
num = queueIndex;
}
node.QueueIndex = num;
nodes[num] = node;
}
private void OnNodeUpdated(PriorityQueueNode<TPriority, TData> node)
{
int num = node.QueueIndex / 2;
PriorityQueueNode<TPriority, TData> lower = nodes[num];
if (num > 0 && HasHigherPriority(node, lower))
{
HeapifyUp(node);
}
else
{
HeapifyDown(node);
}
}
private void Swap(PriorityQueueNode<TPriority, TData> node1, PriorityQueueNode<TPriority, TData> node2)
{
nodes[node1.QueueIndex] = node2;
nodes[node2.QueueIndex] = node1;
int queueIndex = node1.QueueIndex;
node1.QueueIndex = node2.QueueIndex;
node2.QueueIndex = queueIndex;
}
private bool HasHigherPriority(PriorityQueueNode<TPriority, TData> higher, PriorityQueueNode<TPriority, TData> lower)
{
return priorityComparer.Compare(higher.Priority, lower.Priority) < 0;
}
}
public static class Assert
{
public static void IsTrue(bool assertion)
{
IsTrue(assertion, null);
}
public static void IsTrue(bool assertion, string message)
{
if (assertion)
{
return;
}
if (message == null)
{
throw new AssertionFailedException();
}
throw new AssertionFailedException(message);
}
public static void IsEquals(object expectedValue, object actualValue)
{
IsEquals(expectedValue, actualValue, null);
}
public static void IsEquals(object expectedValue, object actualValue, string message)
{
if (actualValue.Equals(expectedValue))
{
return;
}
string arg = ((message != null) ? (": " + message) : string.Empty);
throw new AssertionFailedException(string.Format(CultureInfo.InvariantCulture, "Expected {0} but encountered {1}{2}", expectedValue, actualValue, arg));
}
public static void ShouldNeverReachHere()
{
ShouldNeverReachHere(null);
}
public static void ShouldNeverReachHere(string message)
{
string arg = ((message != null) ? (": " + message) : string.Empty);
throw new AssertionFailedException($"Should never reach here{arg}");
}
}
public class AssertionFailedException : ApplicationException
{
public AssertionFailedException()
{
}
public AssertionFailedException(string message)
: base(message)
{
}
}
internal static class BitTweaks
{
internal static short ReverseByteOrder(short value)
{
return (short)ReverseByteOrder((ushort)value);
}
internal static int ReverseByteOrder(int value)
{
return (int)ReverseByteOrder((uint)value);
}
internal static long ReverseByteOrder(long value)
{
return (long)ReverseByteOrder((ulong)value);
}
internal static float ReverseByteOrder(float value)
{
byte[] bytes = BitConverter.GetBytes(value);
Array.Reverse((Array)bytes, 0, 4);
return BitConverter.ToSingle(bytes, 0);
}
internal static double ReverseByteOrder(double value)
{
return BitConverter.Int64BitsToDouble(ReverseByteOrder(BitConverter.DoubleToInt64Bits(value)));
}
internal static ushort ReverseByteOrder(ushort value)
{
return (ushort)(((value & 0xFF) << 8) | ((value & 0xFF00) >> 8));
}
internal static uint ReverseByteOrder(uint value)
{
return ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) | ((value & 0xFF0000) >> 8) | ((value & 0xFF000000u) >> 24);
}
internal static ulong ReverseByteOrder(ulong value)
{
return ((value & 0xFF) << 56) | ((value & 0xFF00) << 40) | ((value & 0xFF0000) << 24) | ((value & 0xFF000000u) << 8) | ((value & 0xFF00000000L) >> 8) | ((value & 0xFF0000000000L) >> 24) | ((value & 0xFF000000000000L) >> 40) | ((value & 0xFF00000000000000uL) >> 56);
}
}
public class CoordinateArrayFilter : ICoordinateFilter
{
private readonly Coordinate[] _pts;
private int _n;
public Coordinate[] Coordinates => _pts;
public CoordinateArrayFilter(int size)
{
_pts = new Coordinate[size];
}
public void Filter(Coordinate coord)
{
_pts[_n++] = coord;
}
}
public class CoordinateCompare : IComparer
{
public int Compare(object x, object y)
{
if (x is Coordinate && y is Coordinate)
{
Coordinate coordinate = (Coordinate)x;
Coordinate coordinate2 = (Coordinate)y;
if (coordinate.X < coordinate2.X)
{
return -1;
}
if (coordinate.X > coordinate2.X)
{
return 1;
}
if (coordinate.Y < coordinate2.Y)
{
return -1;
}
if (coordinate.Y > coordinate2.Y)
{
return 1;
}
return 0;
}
throw new ArgumentException("Wrong arguments type: Coordinate expected");
}
}
public class CoordinateCountFilter : ICoordinateFilter
{
private int _n;
public int Count => _n;
public void Filter(Coordinate coord)
{
_n++;
}
}
public class Degrees
{
public static double ToRadians(double degrees)
{
return degrees * (Math.PI / 180.0);
}
}
[Obsolete]
public static class EnumUtility
{
public static object Parse(Type type, string value)
{
return Enum.Parse(type, value, ignoreCase: false);
}
public static string Format(Type type, object value, string formatString)
{
return Enum.Format(type, value, formatString);
}
}
public class FunctionsUtil
{
public static readonly Envelope DefaultEnvelope = new Envelope(0.0, 100.0, 0.0, 100.0);
private static readonly GeometryFactory Factory = new GeometryFactory();
public static Envelope GetEnvelopeOrDefault(Geometry g)
{
if (!(g == null))
{
return g.EnvelopeInternal;
}
return DefaultEnvelope;
}
public static GeometryFactory GetFactoryOrDefault(Geometry g)
{
if (!(g == null))
{
return g.Factory;
}
return Factory;
}
public static GeometryFactory GetFactoryOrDefault(IEnumerable<Geometry> gs)
{
if (gs == null)
{
return Factory;
}
foreach (Geometry g in gs)
{
if (g != null)
{
return g.Factory ?? Factory;
}
}
return Factory;
}
[Obsolete]
public static Geometry BuildGeometry(List<Geometry> geoms, Geometry parentGeom)
{
return BuildGeometry((IList<Geometry>)geoms, parentGeom);
}
public static Geometry BuildGeometry(IList<Geometry> geoms, Geometry parentGeom)
{
if (geoms.Count <= 0)
{
return null;
}
if (geoms.Count == 1)
{
return geoms[0];
}
if (parentGeom != null && parentGeom.OgcGeometryType == OgcGeometryType.GeometryCollection)
{
return parentGeom.Factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(geoms));
}
return GetFactoryOrDefault(geoms).BuildGeometry(geoms);
}
public static Geometry BuildGeometry(params Geometry[] geoms)
{
return GetFactoryOrDefault(geoms).CreateGeometryCollection(geoms);
}
public static Geometry BuildGeometry(Geometry a, Geometry b)
{
int num = 0;
if (a != null)
{
num++;
}
if (b != null)
{
num++;
}
Geometry[] array = new Geometry[num];
num = 0;
if (a != null)
{
array[num++] = a;
}
if (b != null)
{
array[num] = b;
}
return GetFactoryOrDefault(array).CreateGeometryCollection(array);
}
}
public class GeometricShapeFactory
{
protected class Dimensions
{
private Coordinate _base;
private Coordinate _centre;
private double _width;
private double _height;
public Coordinate Base
{
get
{
return _base;
}
set
{
_base = value;
}
}
public Coordinate Centre
{
get
{
if (_centre == null)
{
_centre = ((Base != null) ? new Coordinate(Base.X + Width * 0.5, Base.Y + Height * 0.5) : new Coordinate(0.0, 0.0));
}
return _centre;
}
set
{
_centre = value;
}
}
public double Width
{
get
{
return _width;
}
set
{
_width = value;
}
}
public double Height
{
get
{
return _height;
}
set
{
_height = value;
}
}
public double Size
{
set
{
Height = value;
Width = value;
}
}
public double MinSize => Math.Min(Width, Height);
public Envelope Envelope
{
get
{
if (Base != null)
{
return new Envelope(Base.X, Base.X + Width, Base.Y, Base.Y + Height);
}
if (Centre != null)
{
return new Envelope(Centre.X - Width / 2.0, Centre.X + Width / 2.0, Centre.Y - Height / 2.0, Centre.Y + Height / 2.0);
}
return new Envelope(0.0, Width, 0.0, Height);
}
set
{
_width = value.Width;
_height = value.Height;
_base = new Coordinate(value.MinX, value.MinY);
_centre = value.Centre.Copy();
}
}
}
protected GeometryFactory GeomFact;
protected PrecisionModel PrecModel;
private readonly Dimensions _dim = new Dimensions();
private int _nPts = 100;
private double _rotationAngle;
public Coordinate Base
{
set
{
_dim.Base = value;
}
}
public Coordinate Centre
{
set
{
_dim.Centre = value;
}
}
public Envelope Envelope
{
get
{
return _dim.Envelope;
}
set
{
_dim.Envelope = value;
}
}
public int NumPoints
{
get
{
return _nPts;
}
set
{
_nPts = value;
}
}
public double Size
{
set
{
_dim.Size = value;
}
}
public double Width
{
get
{
return _dim.Width;
}
set
{
_dim.Width = value;
}
}
public double Height
{
get
{
return _dim.Height;
}
set
{
_dim.Height = value;
}
}
public double Rotation
{
get
{
return _rotationAngle;
}
set
{
_rotationAngle = value;
}
}
public GeometricShapeFactory()
: this(new GeometryFactory())
{
}
public GeometricShapeFactory(GeometryFactory geomFact)
{
GeomFact = geomFact;
PrecModel = geomFact.PrecisionModel;
}
protected Geometry Rotate(Geometry geom)
{
if (_rotationAngle != 0.0)
{
Coordinate centre = _dim.Centre;
AffineTransformation filter = AffineTransformation.RotationInstance(_rotationAngle, centre.X, centre.Y);
geom.Apply(filter);
}
return geom;
}
protected Coordinate CreateCoord(double x, double y)
{
Coordinate coordinate = new Coordinate(x, y);
PrecModel.MakePrecise(coordinate);
return coordinate;
}
protected Coordinate CreateCoordTrans(double x, double y, Coordinate trans)
{
return CreateCoord(x + trans.X, y + trans.Y);
}
public Polygon CreateRectangle()
{
int num = 0;
int num2 = _nPts / 4;
if (num2 < 1)
{
num2 = 1;
}
double num3 = _dim.Envelope.Width / (double)num2;
double num4 = _dim.Envelope.Height / (double)num2;
Coordinate[] array = new Coordinate[4 * num2 + 1];
Envelope envelope = _dim.Envelope;
for (int i = 0; i < num2; i++)
{
double x = envelope.MinX + (double)i * num3;
double minY = envelope.MinY;
array[num++] = CreateCoord(x, minY);
}
for (int i = 0; i < num2; i++)
{
double maxX = envelope.MaxX;
double y = envelope.MinY + (double)i * num4;
array[num++] = CreateCoord(maxX, y);
}
for (int i = 0; i < num2; i++)
{
double x2 = envelope.MaxX - (double)i * num3;
double maxY = envelope.MaxY;
array[num++] = CreateCoord(x2, maxY);
}
for (int i = 0; i < num2; i++)
{
double minX = envelope.MinX;
double y2 = envelope.MaxY - (double)i * num4;
array[num++] = CreateCoord(minX, y2);
}
array[num] = array[0].Copy();
LinearRing shell = GeomFact.CreateLinearRing(array);
Polygon geom = GeomFact.CreatePolygon(shell);
return (Polygon)Rotate(geom);
}
public Polygon CreateCircle()
{
Envelope envelope = _dim.Envelope;
double num = envelope.Width / 2.0;
double num2 = envelope.Height / 2.0;
double num3 = envelope.MinX + num;
double num4 = envelope.MinY + num2;
Coordinate[] array = new Coordinate[_nPts + 1];
int num5 = 0;
for (int i = 0; i < _nPts; i++)
{
double ang = (double)i * (Math.PI * 2.0 / (double)_nPts);
double x = num * AngleUtility.CosSnap(ang) + num3;
double y = num2 * AngleUtility.SinSnap(ang) + num4;
Coordinate coordinate = CreateCoord(x, y);
array[num5++] = coordinate;
}
array[num5] = array[0];
LinearRing shell = GeomFact.CreateLinearRing(array);
Polygon geom = GeomFact.CreatePolygon(shell);
return (Polygon)Rotate(geom);
}
public Polygon CreateEllipse()
{
Envelope envelope = _dim.Envelope;
double num = envelope.Width / 2.0;
double num2 = envelope.Height / 2.0;
double num3 = envelope.MinX + num;
double num4 = envelope.MinY + num2;
Coordinate[] array = new Coordinate[_nPts + 1];
int num5 = 0;
for (int i = 0; i < _nPts; i++)
{
double num6 = (double)i * (Math.PI * 2.0 / (double)_nPts);
double x = num * Math.Cos(num6) + num3;
double y = num2 * Math.Sin(num6) + num4;
array[num5++] = CreateCoord(x, y);
}
array[num5] = array[0].Copy();
LinearRing shell = GeomFact.CreateLinearRing(array);
Polygon geom = GeomFact.CreatePolygon(shell);
return (Polygon)Rotate(geom);
}
public Polygon CreateSquircle()
{
return CreateSupercircle(4.0);
}
public Polygon CreateSupercircle(double power)
{
double y = 1.0 / power;
double num = _dim.MinSize / 2.0;
Coordinate centre = _dim.Centre;
double num2 = Math.Pow(num, power);
double num3 = num;
double num4 = Math.Pow(num2 / 2.0, y);
int num5 = _nPts / 8;
Coordinate[] array = new Coordinate[num5 * 8 + 1];
double num6 = num4 / (double)num5;
for (int i = 0; i <= num5; i++)
{
double num7 = 0.0;
double num8 = num3;
if (i != 0)
{
num7 = num6 * (double)i;
double num9 = Math.Pow(num7, power);
num8 = Math.Pow(num2 - num9, y);
}
array[i] = CreateCoordTrans(num7, num8, centre);
array[2 * num5 - i] = CreateCoordTrans(num8, num7, centre);
array[2 * num5 + i] = CreateCoordTrans(num8, 0.0 - num7, centre);
array[4 * num5 - i] = CreateCoordTrans(num7, 0.0 - num8, centre);
array[4 * num5 + i] = CreateCoordTrans(0.0 - num7, 0.0 - num8, centre);
array[6 * num5 - i] = CreateCoordTrans(0.0 - num8, 0.0 - num7, centre);
array[6 * num5 + i] = CreateCoordTrans(0.0 - num8, num7, centre);
array[8 * num5 - i] = CreateCoordTrans(0.0 - num7, num8, centre);
}
array[^1] = array[0].Copy();
LinearRing shell = GeomFact.CreateLinearRing(array);
Polygon geom = GeomFact.CreatePolygon(shell);
return (Polygon)Rotate(geom);
}
public LineString CreateArc(double startAng, double angExtent)
{
Envelope envelope = _dim.Envelope;
double num = envelope.Width / 2.0;
double num2 = envelope.Height / 2.0;
double num3 = envelope.MinX + num;
double num4 = envelope.MinY + num2;
double num5 = angExtent;
if (num5 <= 0.0 || num5 > Math.PI * 2.0)
{
num5 = Math.PI * 2.0;
}
double num6 = num5 / (double)(_nPts - 1);
Coordinate[] array = new Coordinate[_nPts];
int num7 = 0;
for (int i = 0; i < _nPts; i++)
{
double ang = startAng + (double)i * num6;
double x = num * AngleUtility.CosSnap(ang) + num3;
double y = num2 * AngleUtility.SinSnap(ang) + num4;
Coordinate coordinate = CreateCoord(x, y);
array[num7++] = coordinate;
}
LineString geom = GeomFact.CreateLineString(array);
return (LineString)Rotate(geom);
}
public Polygon CreateArcPolygon(double startAng, double angExtent)
{
Envelope envelope = _dim.Envelope;
double num = envelope.Width / 2.0;
double num2 = envelope.Height / 2.0;
double num3 = envelope.MinX + num;
double num4 = envelope.MinY + num2;
double num5 = angExtent;
if (num5 <= 0.0 || num5 > Math.PI * 2.0)
{
num5 = Math.PI * 2.0;
}
double num6 = num5 / (double)(_nPts - 1);
Coordinate[] array = new Coordinate[_nPts + 2];
int num7 = 0;
array[num7++] = CreateCoord(num3, num4);
for (int i = 0; i < _nPts; i++)
{
double ang = startAng + num6 * (double)i;
double x = num * AngleUtility.CosSnap(ang) + num3;
double y = num2 * AngleUtility.SinSnap(ang) + num4;
array[num7++] = CreateCoord(x, y);
}
array[num7] = CreateCoord(num3, num4);
LinearRing shell = GeomFact.CreateLinearRing(array);
Polygon geom = GeomFact.CreatePolygon(shell);
return (Polygon)Rotate(geom);
}
}
public sealed class Global
{
private readonly NumberFormatInfo _nfi;
private static readonly Global global = new Global();
private Global()
{
_nfi = new NumberFormatInfo();
_nfi.NumberDecimalSeparator = ".";
}
public static NumberFormatInfo GetNfi()
{
return global._nfi;
}
}
[Obsolete]
public static class Guard
{
public static void IsNotNull(object candidate, string propertyName)
{
if (candidate == null)
{
throw new ArgumentNullException(propertyName);
}
}
}
public class HexConverter
{
private HexConverter()
{
}
public static string ConvertAny2Any(string valueIn, int baseIn, int baseOut)
{
string result = "Error";
valueIn = valueIn.ToUpper();
if (baseIn < 2 || baseIn > 36 || baseOut < 2 || baseOut > 36)
{
return result;
}
if (valueIn.Trim().Length == 0)
{
return result;
}
if (baseIn == baseOut)
{
return valueIn;
}
double num = 0.0;
try
{
if (baseIn == 10)
{
num = double.Parse(valueIn);
}
else
{
char[] array = valueIn.ToCharArray();
int num2 = array.Length;
for (int i = 0; i < array.Length; i++)
{
int num3 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".IndexOf(array[i]);
if (num3 < 0 || num3 > baseIn - 1)
{
return result;
}
num2--;
num += (double)num3 * Math.Pow(baseIn, num2);
}
}
if (baseOut == 10)
{
result = num.ToString();
}
else
{
result = string.Empty;
while (num > 0.0)
{
int num4 = (int)(num % (double)baseOut);
num = (num - (double)num4) / (double)baseOut;
result = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".Substring(num4, 1) + result;
}
}
}
catch (Exception ex)
{
result = ex.Message;
}
return result;
}
}
public class Memory
{
public const double KB = 1024.0;
public const double MB = 1048576.0;
public const double GB = 1073741824.0;
public static long Total => GC.GetTotalMemory(forceFullCollection: true);
public static string TotalString => Format(Total);
public static string Format(long mem)
{
if ((double)mem < 2048.0)
{
return mem + " bytes";
}
if ((double)mem < 2097152.0)
{
return Round((double)mem / 1024.0) + " KB";
}
if ((double)mem < 2147483648.0)
{
return Round((double)mem / 1048576.0) + " MB";
}
return Round((double)mem / 1073741824.0) + " GB";
}
public static double Round(double d)
{
return Math.Ceiling(d * 100.0) / 100.0;
}
}
public class PriorityQueue<T> : IEnumerable<T>, IEnumerable where T : IComparable<T>
{
private class DataEnumerator : IEnumerator<T>, IEnumerator, IDisposable
{
private readonly IEnumerator<PriorityQueueNode<T, T>> _pqnEnumerator;
public T Current
{
get
{
PriorityQueueNode<T, T> current = _pqnEnumerator.Current;
if (current == null)
{
return default(T);
}
return current.Data;
}
}
object IEnumerator.Current => Current;
public DataEnumerator(IEnumerator<PriorityQueueNode<T, T>> pqnEnumerator)
{
_pqnEnumerator = pqnEnumerator;
}
public void Dispose()
{
_pqnEnumerator.Dispose();
}
public bool MoveNext()
{
return _pqnEnumerator.MoveNext();
}
public void Reset()
{
_pqnEnumerator.Reset();
}
}
private readonly AlternativePriorityQueue<T, T> _queue;
public int Size => _queue.Count;
public PriorityQueue()
{
_queue = new AlternativePriorityQueue<T, T>();
}
public PriorityQueue(int capacity, IComparer<T> comparer)
{
_queue = new AlternativePriorityQueue<T, T>(capacity, comparer);
}
public void Add(T x)
{
PriorityQueueNode<T, T> node = new PriorityQueueNode<T, T>(x);
_queue.Enqueue(node, x);
}
public bool IsEmpty()
{
return _queue.Count == 0;
}
public void Clear()
{
_queue.Clear();
}
public T Poll()
{
PriorityQueueNode<T, T> priorityQueueNode = _queue.Dequeue();
if (priorityQueueNode != null)
{
return priorityQueueNode.Data;
}
return default(T);
}
public T Peek()
{
PriorityQueueNode<T, T> head = _queue.Head;
if (head != null)
{
return head.Data;
}
return default(T);
}
public IEnumerator<T> GetEnumerator()
{
return new DataEnumerator(_queue.GetEnumerator());
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
public sealed class PriorityQueueNode<TPriority, TData>
{
private readonly TData data;
public TData Data => data;
public TPriority Priority { get; internal set; }
internal int QueueIndex { get; set; }
public PriorityQueueNode(TData data)
{
this.data = data;
}
internal PriorityQueueNode(PriorityQueueNode<TPriority, TData> copyFrom)
{
data = copyFrom.data;
Priority = copyFrom.Priority;
QueueIndex = copyFrom.QueueIndex;
}
}
public class Radians
{
public static double ToDegrees(double radians)
{
return radians * (180.0 / Math.PI);
}
}
internal class ReverseOrder : IComparer
{
public int Compare(object x, object y)
{
return Comparer<object>.Default.Compare(x, y) * -1;
}
}
internal sealed class TokenStream
{
private bool? prevMoveNextResult;
private Token nextToken;
public IEnumerator<Token> Enumerator { get; }
public TokenStream(IEnumerator<Token> enumerator)
{
Enumerator = enumerator;
}
public Token NextToken(bool advance)
{
if (!prevMoveNextResult.HasValue)
{
ReadNextToken();
}
Token result = nextToken;
if (advance)
{
ReadNextToken();
}
return result;
}
private void ReadNextToken()
{
if (Enumerator.MoveNext())
{
prevMoveNextResult = true;
nextToken = Enumerator.Current;
if (nextToken == null)
{
throw new InvalidOperationException("Token list contains a null value.");
}
}
else
{
prevMoveNextResult = false;
nextToken = null;
}
}
}
public class UniqueCoordinateArrayFilter : ICoordinateFilter
{
private readonly ISet<Coordinate> _coordSet = new HashSet<Coordinate>();
private readonly List<Coordinate> _list = new List<Coordinate>();
public Coordinate[] Coordinates => _list.ToArray();
public static Coordinate[] FilterCoordinates(Coordinate[] coords)
{
UniqueCoordinateArrayFilter uniqueCoordinateArrayFilter = new UniqueCoordinateArrayFilter();
for (int i = 0; i < coords.Length; i++)
{
uniqueCoordinateArrayFilter.Filter(coords[i]);
}
return uniqueCoordinateArrayFilter.Coordinates;
}
public void Filter(Coordinate coord)
{
if (_coordSet.Add(coord))
{
_list.Add(coord);
}
}
}
}
namespace NetTopologySuite.Triangulate
{
public class ConformingDelaunayTriangulationBuilder
{
private ICollection<Coordinate> _siteCoords;
private Geometry _constraintLines;
private double _tolerance;
private QuadEdgeSubdivision _subdiv;
private readonly IDictionary<Coordinate, Vertex> _constraintVertexMap = new SortedDictionary<Coordinate, Vertex>();
public Geometry Constraints
{
set
{
_constraintLines = value;
}
}
public double Tolerance
{
get
{
return _tolerance;
}
set
{
_tolerance = value;
}
}
public void SetSites(Geometry sites)
{
_siteCoords = DelaunayTriangulationBuilder.ExtractUniqueCoordinates(sites);
}
private void Create()
{
if (_subdiv == null)
{
Envelope envelope = DelaunayTriangulationBuilder.Envelope(_siteCoords);
List<Segment> segments = new List<Segment>();
if (_constraintLines != null)
{
envelope.ExpandToInclude(_constraintLines.EnvelopeInternal);
CreateVertices(_constraintLines);
segments = CreateConstraintSegments(_constraintLines);
}
ConformingDelaunayTriangulator conformingDelaunayTriangulator = new ConformingDelaunayTriangulator(CreateSiteVertices(_siteCoords), _tolerance);
conformingDelaunayTriangulator.SetConstraints(segments, new List<Vertex>(_constraintVertexMap.Values));
conformingDelaunayTriangulator.FormInitialDelaunay();
conformingDelaunayTriangulator.EnforceConstraints();
_subdiv = conformingDelaunayTriangulator.Subdivision;
}
}
private IEnumerable<Vertex> CreateSiteVertices(IEnumerable<Coordinate> coords)
{
List<Vertex> list = new List<Vertex>();
foreach (Coordinate coord in coords)
{
if (!_constraintVertexMap.ContainsKey(coord))
{
list.Add(new ConstraintVertex(coord));
}
}
return list;
}
private void CreateVertices(Geometry geom)
{
Coordinate[] coordinates = geom.Coordinates;
for (int i = 0; i < coordinates.Length; i++)
{
ConstraintVertex value = new ConstraintVertex(coordinates[i]);
_constraintVertexMap[coordinates[i]] = value;
}
}
private static List<Segment> CreateConstraintSegments(Geometry geom)
{
ReadOnlyCollection<Geometry> lines = LinearComponentExtracter.GetLines(geom);
List<Segment> list = new List<Segment>();
foreach (LineString item in lines)
{
CreateConstraintSegments(item, list);
}
return list;
}
private static void CreateConstraintSegments(LineString line, IList<Segment> constraintSegs)
{
Coordinate[] coordinates = line.Coordinates;
for (int i = 1; i < coordinates.Length; i++)
{
constraintSegs.Add(new Segment(coordinates[i - 1], coordinates[i]));
}
}
public QuadEdgeSubdivision GetSubdivision()
{
Create();
return _subdiv;
}
public MultiLineString GetEdges(GeometryFactory geomFact)
{
Create();
return _subdiv.GetEdges(geomFact);
}
public GeometryCollection GetTriangles(GeometryFactory geomFact)
{
Create();
return _subdiv.GetTriangles(geomFact);
}
}
public class ConformingDelaunayTriangulator
{
private readonly IList<Vertex> _initialVertices;
private IList<Vertex> _segVertices;
private IList<Segment> _segments = new List<Segment>();
private QuadEdgeSubdivision _subdiv;
private IncrementalDelaunayTriangulator _incDel;
private Geometry _convexHull;
private IConstraintSplitPointFinder _splitFinder = new NonEncroachingSplitPointFinder();
private readonly KdTree<Vertex> _kdt;
private ConstraintVertexFactory _vertexFactory;
private Envelope _computeAreaEnv;
private Coordinate _splitPt;
private readonly double _tolerance;
private const int MaxSplitIteration = 99;
public IConstraintSplitPointFinder SplitPointFinder
{
get
{
return _splitFinder;
}
set
{
_splitFinder = value;
}
}
public double Tolerance => _tolerance;
public ConstraintVertexFactory VertexFactory
{
get
{
return _vertexFactory;
}
set
{
_vertexFactory = value;
}
}
public QuadEdgeSubdivision Subdivision => _subdiv;
public KdTree<Vertex> KDT => _kdt;
public IList<Vertex> InitialVertices => _initialVertices;
public ICollection<Segment> ConstraintSegments => _segments;
public Geometry ConvexHull => _convexHull;
private static Envelope ComputeVertexEnvelope(IEnumerable<Vertex> vertices)
{
Envelope envelope = new Envelope();
foreach (Vertex vertex in vertices)
{
envelope.ExpandToInclude(vertex.Coordinate);
}
return envelope;
}
public ConformingDelaunayTriangulator(IEnumerable<Vertex> initialVertices, double tolerance)
{
_initialVertices = new List<Vertex>(initialVertices);
_tolerance = tolerance;
_kdt = new KdTree<Vertex>(tolerance);
}
public void SetConstraints(IList<Segment> segments, IList<Vertex> segVertices)
{
_segments = segments;
_segVertices = segVertices;
}
private void ComputeBoundingBox()
{
Envelope env = ComputeVertexEnvelope(_initialVertices);
Envelope other = ComputeVertexEnvelope(_segVertices);
Envelope envelope = new Envelope(env);
envelope.ExpandToInclude(other);
double val = envelope.Width * 0.2;
double val2 = envelope.Height * 0.2;
double distance = Math.Max(val, val2);
_computeAreaEnv = new Envelope(envelope);
_computeAreaEnv.ExpandBy(distance);
}
private void ComputeConvexHull()
{
GeometryFactory geomFactory = new GeometryFactory();
ConvexHull convexHull = new ConvexHull(GetPointArray(), geomFactory);
_convexHull = convexHull.GetConvexHull();
}
private Coordinate[] GetPointArray()
{
Coordinate[] array = new Coordinate[_initialVertices.Count + _segVertices.Count];
int num = 0;
foreach (Vertex initialVertex in _initialVertices)
{
array[num++] = initialVertex.Coordinate;
}
foreach (Vertex segVertex in _segVertices)
{
array[num++] = segVertex.Coordinate;
}
return array;
}
private ConstraintVertex CreateVertex(Coordinate p)
{
ConstraintVertex constraintVertex = null;
if (_vertexFactory != null)
{
return _vertexFactory.CreateVertex(p, null);
}
return new ConstraintVertex(p);
}
private ConstraintVertex CreateVertex(Coordinate p, Segment seg)
{
ConstraintVertex constraintVertex = ((_vertexFactory == null) ? new ConstraintVertex(p) : _vertexFactory.CreateVertex(p, seg));
constraintVertex.IsOnConstraint = true;
return constraintVertex;
}
private void InsertSites(ICollection<Vertex> vertices)
{
foreach (Vertex vertex in vertices)
{
InsertSite((ConstraintVertex)vertex);
}
}
private ConstraintVertex InsertSite(ConstraintVertex v)
{
KdNode<Vertex> kdNode = _kdt.Insert(v.Coordinate, v);
if (!kdNode.IsRepeated)
{
_incDel.InsertSite(v);
return v;
}
ConstraintVertex obj = (ConstraintVertex)kdNode.Data;
obj.Merge(v);
return obj;
}
public void InsertSite(Coordinate p)
{
InsertSite(CreateVertex(p));
}
public void FormInitialDelaunay()
{
ComputeBoundingBox();
_subdiv = new QuadEdgeSubdivision(_computeAreaEnv, _tolerance);
_subdiv.SetLocator(new LastFoundQuadEdgeLocator(_subdiv));
_incDel = new IncrementalDelaunayTriangulator(_subdiv);
InsertSites(_initialVertices);
}
public void EnforceConstraints()
{
AddConstraintVertices();
int num = 0;
int num2;
do
{
num2 = EnforceGabriel(_segments);
num++;
}
while (num2 > 0 && num < 99);
if (num == 99 && !Debugger.IsAttached)
{
throw new ConstraintEnforcementException("Too many splitting iterations while enforcing constraints. Last split point was at: ", _splitPt);
}
}
private void AddConstraintVertices()
{
ComputeConvexHull();
InsertSites(_segVertices);
}
private int EnforceGabriel(ICollection<Segment> segsToInsert)
{
List<Segment> list = new List<Segment>();
int num = 0;
List<Segment> list2 = new List<Segment>();
foreach (Segment item3 in segsToInsert)
{
Coordinate coordinate = FindNonGabrielPoint(item3);
if (coordinate != null)
{
_splitPt = _splitFinder.FindSplitPoint(item3, coordinate);
ConstraintVertex constraintVertex = CreateVertex(_splitPt, item3);
InsertSite(constraintVertex).Coordinate.Equals2D(_splitPt);
Segment item = new Segment(item3.StartX, item3.StartY, item3.StartZ, constraintVertex.X, constraintVertex.Y, constraintVertex.Z, item3.Data);
Segment item2 = new Segment(constraintVertex.X, constraintVertex.Y, constraintVertex.Z, item3.EndX, item3.EndY, item3.EndZ, item3.Data);
list.Add(item);
list.Add(item2);
list2.Add(item3);
num++;
}
}
foreach (Segment item4 in list2)
{
segsToInsert.Remove(item4);
}
foreach (Segment item5 in list)
{
segsToInsert.Add(item5);
}
return num;
}
private Coordinate FindNonGabrielPoint(Segment seg)
{
Coordinate start = seg.Start;
Coordinate end = seg.End;
Coordinate coordinate = new Coordinate((start.X + end.X) / 2.0, (start.Y + end.Y) / 2.0);
double num = start.Distance(coordinate);
Envelope envelope = new Envelope(coordinate);
envelope.ExpandBy(num);
IList<KdNode<Vertex>> list = _kdt.Query(envelope);
Coordinate coordinate2 = null;
double num2 = double.MaxValue;
foreach (KdNode<Vertex> item in list)
{
Coordinate coordinate3 = item.Coordinate;
if (coordinate3.Equals2D(start) || coordinate3.Equals2D(end))
{
continue;
}
double num3 = coordinate.Distance(coordinate3);
if (num3 < num)
{
double num4 = num3;
if (coordinate2 == null || num4 < num2)
{
coordinate2 = coordinate3;
num2 = num4;
}
}
}
return coordinate2;
}
}
public class ConstraintEnforcementException : Exception
{
private readonly Coordinate _pt;
public Coordinate Coordinate => _pt;
private static string MsgWithCoord(string msg, Coordinate pt)
{
if (pt != null)
{
return msg + " [ " + WKTWriter.ToPoint(pt) + " ]";
}
return msg;
}
public ConstraintEnforcementException(string msg)
: base(msg)
{
}
public ConstraintEnforcementException(string msg, Coordinate pt)
: base(MsgWithCoord(msg, pt))
{
_pt = pt.Copy();
}
}
public class ConstraintVertex : Vertex
{
private bool isOnConstraint;
private object constraint;
public bool IsOnConstraint
{
get
{
return isOnConstraint;
}
set
{
isOnConstraint = value;
}
}
public object Constraint
{
get
{
return constraint;
}
set
{
isOnConstraint = true;
constraint = value;
}
}
public ConstraintVertex(Coordinate p)
: base(p)
{
}
protected internal void Merge(ConstraintVertex other)
{
if (other.isOnConstraint)
{
isOnConstraint = true;
constraint = other.constraint;
}
}
}
public interface ConstraintVertexFactory
{
ConstraintVertex CreateVertex(Coordinate p, Segment constraintSeg);
}
public class DelaunayTriangulationBuilder
{
private ICollection<Coordinate> _siteCoords;
private double _tolerance;
private QuadEdgeSubdivision _subdiv;
public double Tolerance
{
set
{
_tolerance = value;
}
}
public static CoordinateList ExtractUniqueCoordinates(Geometry geom)
{
if (geom == null)
{
return new CoordinateList();
}
return Unique(geom.Coordinates);
}
public static CoordinateList Unique(Coordinate[] coords)
{
Coordinate[] array = CoordinateArrays.CopyDeep(coords);
Array.Sort(array);
return new CoordinateList(array, allowRepeated: false);
}
public static IList<Vertex> ToVertices(ICollection<Coordinate> coords)
{
List<Vertex> list = new List<Vertex>();
foreach (Coordinate coord in coords)
{
list.Add(new Vertex(coord));
}
return list;
}
public static Envelope Envelope(ICollection<Coordinate> coords)
{
Envelope envelope = new Envelope();
foreach (Coordinate coord in coords)
{
envelope.ExpandToInclude(coord);
}
return envelope;
}
public void SetSites(Geometry geom)
{
_siteCoords = ExtractUniqueCoordinates(geom);
}
public void SetSites(ICollection<Coordinate> coords)
{
_siteCoords = Unique(CoordinateArrays.ToCoordinateArray(coords));
}
private void Create()
{
if (_subdiv == null)
{
Envelope env = Envelope(_siteCoords);
IList<Vertex> vertices = ToVertices(_siteCoords);
_subdiv = new QuadEdgeSubdivision(env, _tolerance);
new IncrementalDelaunayTriangulator(_subdiv).InsertSites(vertices);
}
}
public QuadEdgeSubdivision GetSubdivision()
{
Create();
return _subdiv;
}
public MultiLineString GetEdges(GeometryFactory geomFact)
{
Create();
return _subdiv.GetEdges(geomFact);
}
public GeometryCollection GetTriangles(GeometryFactory geomFact)
{
Create();
return _subdiv.GetTriangles(geomFact);
}
}
public interface IConstraintSplitPointFinder
{
Coordinate FindSplitPoint(Segment seg, Coordinate encroachPt);
}
public class IncrementalDelaunayTriangulator
{
private readonly QuadEdgeSubdivision _subdiv;
private bool _isUsingTolerance;
private bool _isForceConvex = true;
public bool ForceConvex
{
get
{
return _isForceConvex;
}
set
{
_isForceConvex = value;
}
}
public IncrementalDelaunayTriangulator(QuadEdgeSubdivision subdiv)
{
_subdiv = subdiv;
_isUsingTolerance = subdiv.Tolerance > 0.0;
}
public void InsertSites(ICollection<Vertex> vertices)
{
foreach (Vertex vertex in vertices)
{
InsertSite(vertex);
}
}
public NetTopologySuite.Triangulate.QuadEdge.QuadEdge InsertSite(Vertex v)
{
NetTopologySuite.Triangulate.QuadEdge.QuadEdge quadEdge = _subdiv.Locate(v);
if (_subdiv.IsVertexOfEdge(quadEdge, v))
{
return quadEdge;
}
if (_subdiv.IsOnEdge(quadEdge, v.Coordinate))
{
quadEdge = quadEdge.OPrev;
_subdiv.Delete(quadEdge.ONext);
}
NetTopologySuite.Triangulate.QuadEdge.QuadEdge quadEdge2 = _subdiv.MakeEdge(quadEdge.Orig, v);
NetTopologySuite.Triangulate.QuadEdge.QuadEdge.Splice(quadEdge2, quadEdge);
NetTopologySuite.Triangulate.QuadEdge.QuadEdge quadEdge3 = quadEdge2;
do
{
quadEdge2 = _subdiv.Connect(quadEdge, quadEdge2.Sym);
quadEdge = quadEdge2.OPrev;
}
while (quadEdge.LNext != quadEdge3);
while (true)
{
NetTopologySuite.Triangulate.QuadEdge.QuadEdge oPrev = quadEdge.OPrev;
bool flag = oPrev.Dest.RightOf(quadEdge) && v.IsInCircle(quadEdge.Orig, oPrev.Dest, quadEdge.Dest);
if (_isForceConvex)
{
if (IsConcaveBoundary(quadEdge))
{
flag = true;
}
else if (IsBetweenFrameAndInserted(quadEdge, v))
{
flag = false;
}
}
if (flag)
{
NetTopologySuite.Triangulate.QuadEdge.QuadEdge.Swap(quadEdge);
quadEdge = quadEdge.OPrev;
continue;
}
if (quadEdge.ONext == quadEdge3)
{
break;
}
quadEdge = quadEdge.ONext.LPrev;
}
return quadEdge2;
}
private bool IsConcaveBoundary(NetTopologySuite.Triangulate.QuadEdge.QuadEdge e)
{
if (_subdiv.IsFrameVertex(e.Dest))
{
return IsConcaveAtOrigin(e);
}
if (_subdiv.IsFrameVertex(e.Orig))
{
return IsConcaveAtOrigin(e.Sym);
}
return false;
}
private static bool IsConcaveAtOrigin(NetTopologySuite.Triangulate.QuadEdge.QuadEdge e)
{
Coordinate coordinate = e.Orig.Coordinate;
Coordinate coordinate2 = e.OPrev.Dest.Coordinate;
Coordinate coordinate3 = e.ONext.Dest.Coordinate;
return OrientationIndex.CounterClockwise == Orientation.Index(coordinate2, coordinate3, coordinate);
}
private bool IsBetweenFrameAndInserted(NetTopologySuite.Triangulate.QuadEdge.QuadEdge e, Vertex vInsert)
{
Vertex dest = e.ONext.Dest;
Vertex dest2 = e.OPrev.Dest;
if (dest != vInsert || !_subdiv.IsFrameVertex(dest2))
{
if (dest2 == vInsert)
{
return _subdiv.IsFrameVertex(dest);
}
return false;
}
return true;
}
}
public class MidpointSplitPointFinder : IConstraintSplitPointFinder
{
public Coordinate FindSplitPoint(Segment seg, Coordinate encroachPt)
{
Coordinate start = seg.Start;
Coordinate end = seg.End;
return new Coordinate((start.X + end.X) / 2.0, (start.Y + end.Y) / 2.0);
}
}
public class NonEncroachingSplitPointFinder : IConstraintSplitPointFinder
{
public Coordinate FindSplitPoint(Segment seg, Coordinate encroachPt)
{
LineSegment lineSegment = seg.LineSegment;
double num = lineSegment.Length / 2.0;
SplitSegment splitSegment = new SplitSegment(lineSegment);
Coordinate coordinate = ProjectedSplitPoint(seg, encroachPt);
double num2 = coordinate.Distance(encroachPt) * 2.0 * 0.8;
if (num2 > num)
{
num2 = num;
}
splitSegment.MinimumLength = num2;
splitSegment.SplitAt(coordinate);
return splitSegment.SplitPoint;
}
public static Coordinate ProjectedSplitPoint(Segment seg, Coordinate encroachPt)
{
return seg.LineSegment.Project(encroachPt);
}
}
public class Segment
{
private readonly LineSegment _ls;
public Coordinate Start => _ls.GetCoordinate(0);
public Coordinate End => _ls.GetCoordinate(1);
public double StartX => _ls.GetCoordinate(0).X;
public double StartY => _ls.GetCoordinate(0).Y;
public double StartZ => _ls.GetCoordinate(0).Z;
public double EndX => _ls.GetCoordinate(1).X;
public double EndY => _ls.GetCoordinate(1).Y;
public double EndZ => _ls.GetCoordinate(1).Z;
public LineSegment LineSegment => _ls;
public object Data { get; set; }
public Segment(double x1, double y1, double z1, double x2, double y2, double z2)
: this(new CoordinateZ(x1, y1, z1), new CoordinateZ(x2, y2, z2))
{
}
public Segment(double x1, double y1, double z1, double x2, double y2, double z2, object data)
: this(new CoordinateZ(x1, y1, z1), new CoordinateZ(x2, y2, z2), data)
{
}
public Segment(Coordinate p0, Coordinate p1, object data)
{
_ls = new LineSegment(p0, p1);
Data = data;
}
public Segment(Coordinate p0, Coordinate p1)
{
_ls = new LineSegment(p0, p1);
}
public bool EqualsTopologically(Segment s)
{
return _ls.EqualsTopologically(s.LineSegment);
}
public Coordinate Intersection(Segment s)
{
return _ls.Intersection(s.LineSegment);
}
public override string ToString()
{
return _ls.ToString();
}
}
public class SplitSegment
{
private readonly LineSegment _seg;
private readonly double _segLen;
private Coordinate _splitPt;
private double _minimumLen;
public double MinimumLength
{
get
{
return _minimumLen;
}
set
{
_minimumLen = value;
}
}
public Coordinate SplitPoint => _splitPt;
private static Coordinate PointAlongReverse(LineSegment seg, double segmentLengthFraction)
{
return new Coordinate
{
X = seg.P1.X - segmentLengthFraction * (seg.P1.X - seg.P0.X),
Y = seg.P1.Y - segmentLengthFraction * (seg.P1.Y - seg.P0.Y)
};
}
public SplitSegment(LineSegment seg)
{
_seg = seg;
_segLen = seg.Length;
}
public void SplitAt(double length, Coordinate endPt)
{
double segmentLengthFraction = GetConstrainedLength(length) / _segLen;
if (endPt.Equals2D(_seg.P0))
{
_splitPt = _seg.PointAlong(segmentLengthFraction);
}
else
{
_splitPt = PointAlongReverse(_seg, segmentLengthFraction);
}
}
public void SplitAt(Coordinate pt)
{
double segmentLengthFraction = _minimumLen / _segLen;
if (pt.Distance(_seg.P0) < _minimumLen)
{
_splitPt = _seg.PointAlong(segmentLengthFraction);
}
else if (pt.Distance(_seg.P1) < _minimumLen)
{
_splitPt = PointAlongReverse(_seg, segmentLengthFraction);
}
else
{
_splitPt = pt;
}
}
private double GetConstrainedLength(double len)
{
if (len < _minimumLen)
{
return _minimumLen;
}
return len;
}
}
public class VertexTaggedGeometryDataMapper
{
private readonly IDictionary<Coordinate, object> _coordDataMap = new SortedDictionary<Coordinate, object>();
public IList<Coordinate> Coordinates => new List<Coordinate>(_coordDataMap.Keys);
public void LoadSourceGeometries(Geometry geoms)
{
for (int i = 0; i < geoms.NumGeometries; i++)
{
Geometry geometryN = geoms.GetGeometryN(i);
LoadVertices(geometryN.Coordinates, geometryN.UserData);
}
}
public void LoadSourceGeometries(ICollection<Geometry> geoms)
{
foreach (Geometry geom in geoms)
{
LoadVertices(geom.Coordinates, geom.UserData);
}
}
public void LoadSourceGeometries(GeometryCollection geomColl)
{
for (int i = 0; i < geomColl.NumGeometries; i++)
{
Geometry geometryN = geomColl.GetGeometryN(i);
LoadVertices(geometryN.Coordinates, geometryN.UserData);
}
}
private void LoadVertices(Coordinate[] pts, object data)
{
for (int i = 0; i < pts.Length; i++)
{
_coordDataMap.Add(pts[i], data);
}
}
public void TransferData(Geometry targetGeom)
{
for (int i = 0; i < targetGeom.NumGeometries; i++)
{
Geometry geometryN = targetGeom.GetGeometryN(i);
Coordinate coordinate = (Coordinate)geometryN.UserData;
if (coordinate != null)
{
geometryN.UserData = _coordDataMap[coordinate];
}
}
}
}
public class VoronoiDiagramBuilder
{
private ICollection<Coordinate> _siteCoords;
private double _tolerance;
private QuadEdgeSubdivision _subdiv;
private Envelope _clipEnv;
private Envelope _diagramEnv;
public Envelope ClipEnvelope
{
set
{
_clipEnv = value;
}
}
public double Tolerance
{
set
{
_tolerance = value;
}
}
public void SetSites(Geometry geom)
{
_siteCoords = DelaunayTriangulationBuilder.ExtractUniqueCoordinates(geom);
}
public void SetSites(ICollection<Coordinate> coords)
{
_siteCoords = DelaunayTriangulationBuilder.Unique(CoordinateArrays.ToCoordinateArray(coords));
}
private void Create()
{
if (_subdiv == null)
{
_diagramEnv = _clipEnv;
if (_diagramEnv == null)
{
_diagramEnv = DelaunayTriangulationBuilder.Envelope(_siteCoords);
double diameter = _diagramEnv.Diameter;
_diagramEnv.ExpandBy(diameter);
}
IList<Vertex> vertices = DelaunayTriangulationBuilder.ToVertices(_siteCoords);
_subdiv = new QuadEdgeSubdivision(_diagramEnv, _tolerance);
IncrementalDelaunayTriangulator incrementalDelaunayTriangulator = new IncrementalDelaunayTriangulator(_subdiv);
incrementalDelaunayTriangulator.ForceConvex = false;
incrementalDelaunayTriangulator.InsertSites(vertices);
}
}
public QuadEdgeSubdivision GetSubdivision()
{
Create();
return _subdiv;
}
public GeometryCollection GetDiagram(GeometryFactory geomFact)
{
Create();
return ClipGeometryCollection(_subdiv.GetVoronoiDiagram(geomFact), _diagramEnv);
}
private static GeometryCollection ClipGeometryCollection(GeometryCollection geom, Envelope clipEnv)
{
Geometry geometry = geom.Factory.ToGeometry(clipEnv);
List<Geometry> list = new List<Geometry>();
for (int i = 0; i < geom.NumGeometries; i++)
{
Geometry geometryN = geom.GetGeometryN(i);
Geometry geometry2 = null;
if (clipEnv.Contains(geometryN.EnvelopeInternal))
{
geometry2 = geometryN;
}
else if (clipEnv.Intersects(geometryN.EnvelopeInternal))
{
geometry2 = geometry.Intersection(geometryN);
geometry2.UserData = geometryN.UserData;
}
if (geometry2 != null && !geometry2.IsEmpty)
{
list.Add(geometry2);
}
}
return geom.Factory.CreateGeometryCollection(GeometryFactory.ToGeometryArray(list));
}
}
}
namespace NetTopologySuite.Triangulate.Tri
{
public class Tri
{
private const string INVALID_TRI_INDEX = "Invalid Tri index: {0}";
private Coordinate _p0;
private Coordinate _p1;
private Coordinate _p2;
private Tri _tri0;
private Tri _tri1;
private Tri _tri2;
protected Coordinate P0 => _p0;
protected Coordinate P1 => _p1;
protected Coordinate P2 => _p2;
protected Tri Tri0 => _tri0;
protected Tri Tri1 => _tri1;
protected Tri Tri2 => _tri2;
public int NumAdjacent
{
get
{
int num = 0;
if (_tri0 != null)
{
num++;
}
if (_tri1 != null)
{
num++;
}
if (_tri2 != null)
{
num++;
}
return num;
}
}
public double Area => Triangle.Area(_p0, _p1, _p2);
public double Length => Triangle.Length(_p0, _p1, _p2);
public static Geometry ToGeometry(ICollection<Tri> tris, GeometryFactory geomFact)
{
Geometry[] array = new Geometry[tris.Count];
int num = 0;
foreach (Tri tri in tris)
{
array[num++] = tri.ToPolygon(geomFact);
}
return geomFact.CreateGeometryCollection(array);
}
public static double AreaOf(IEnumerable<Tri> triList)
{
double num = 0.0;
foreach (Tri tri in triList)
{
num += tri.Area;
}
return num;
}
public static void Validate(IEnumerable<Tri> triList)
{
foreach (Tri tri in triList)
{
tri.Validate();
}
}
public static Tri Create(Coordinate p0, Coordinate p1, Coordinate p2)
{
return new Tri(p0, p1, p2);
}
public static Tri Create(Coordinate[] pts)
{
return new Tri(pts[0], pts[1], pts[2]);
}
public Tri(Coordinate p0, Coordinate p1, Coordinate p2)
{
_p0 = p0;
_p1 = p1;
_p2 = p2;
}
public void SetAdjacent(Tri tri0, Tri tri1, Tri tri2)
{
_tri0 = tri0;
_tri1 = tri1;
_tri2 = tri2;
}
public void SetAdjacent(Coordinate pt, Tri tri)
{
int index = GetIndex(pt);
SetTri(index, tri);
}
public void SetTri(int edgeIndex, Tri tri)
{
switch (edgeIndex)
{
case 0:
_tri0 = tri;
break;