using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.Workshop;
using Microsoft.CodeAnalysis;
using ModernizationPort;
using ModernizationPort.Legacy;
using UModLoader;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 HelmetEditorPatch
{
[BepInPlugin("modernization.helmet.patch", "Helmet Editor Patch", "0.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class HelmetPatchPlugin : BaseUnityPlugin
{
[HarmonyPatch]
internal static class FlameImpactTeamCapture
{
internal static TeamHolder lastTeam;
internal static Vector3 lastPos;
internal static float lastTime;
private static MethodBase TargetMethod()
{
return AccessTools.Method(typeof(FlameMovement), "OnTriggerEnter", new Type[1] { typeof(Collider) }, (Type[])null);
}
private static bool Prepare()
{
return TargetMethod() != null;
}
[HarmonyPrefix]
private static void Prefix(FlameMovement __instance)
{
//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)
try
{
if (!((Object)(object)__instance == (Object)null))
{
TeamHolder component = ((Component)__instance).GetComponent<TeamHolder>();
if (!((Object)(object)component == (Object)null))
{
lastTeam = component;
lastPos = ((Component)__instance).transform.position;
lastTime = Time.unscaledTime;
}
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(Explosion), "Start", new Type[] { })]
internal static class ExplosionTeamFix
{
[HarmonyPrefix]
private static void Prefix(Explosion __instance)
{
//IL_0035: 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_0085: 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)
try
{
if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponentInParent<TeamHolder>() != (Object)null)
{
return;
}
TeamHolder val = null;
if (Time.unscaledTime - FlameImpactTeamCapture.lastTime < 0.5f && Vector3.Distance(FlameImpactTeamCapture.lastPos, ((Component)__instance).transform.position) < 4f)
{
val = FlameImpactTeamCapture.lastTeam;
}
if ((Object)(object)val == (Object)null)
{
return;
}
TeamHolder component = ((Component)__instance).GetComponent<TeamHolder>();
TeamHolder obj = (((Object)(object)component != (Object)null) ? component : ((Component)__instance).gameObject.AddComponent<TeamHolder>());
obj.team = val.team;
obj.spawner = val.spawner;
if ((Object)(object)val.spawner != (Object)null)
{
Unit componentInParent = val.spawner.GetComponentInParent<Unit>();
DataHandler val2 = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).GetComponentInChildren<DataHandler>() : null);
if ((Object)(object)val2 != (Object)null && (Object)(object)val2.mainRig != (Object)null)
{
__instance.AddProtectedRig(val2.mainRig);
}
}
}
catch (Exception ex)
{
log.LogWarning((object)("爆炸补队伍失败(不影响其它功能): " + ex.Message));
}
}
}
[HarmonyPatch]
private static class SpawnIgnoredFrames
{
private static MethodBase TargetMethod()
{
Type[] types = typeof(RangeWeapon).Assembly.GetTypes();
foreach (Type type in types)
{
if (type.Name != "ProjectilesSpawnManager")
{
continue;
}
MethodInfo[] methods = type.GetMethods(AccessTools.all);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name == "SpawnProjectile" && methodInfo.GetParameters().Length >= 10)
{
return methodInfo;
}
}
}
return null;
}
private static bool Prepare()
{
return TargetMethod() != null;
}
[HarmonyPostfix]
private static void Postfix(GameObject __result, Unit unit)
{
try
{
if ((Object)(object)__result == (Object)null)
{
return;
}
string text = ((((Object)__result).name != null) ? ((Object)__result).name : "");
if (!text.StartsWith("现代弹丸") && !text.Contains("现代火苗") && !text.Contains("CP_现代火苗"))
{
return;
}
RaycastTrail[] componentsInChildren = __result.GetComponentsInChildren<RaycastTrail>(true);
foreach (RaycastTrail val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null))
{
val.ignoredFrames = 3;
}
}
if (text.Contains("火苗"))
{
if ((Object)(object)unit != (Object)null && (Object)(object)__result.GetComponent<TeamHolder>() == (Object)null)
{
TeamHolder.AddTeamHolder(__result, ((Component)unit).gameObject);
}
if ((Object)(object)__result.GetComponent<FlameParticleEmitter>() == (Object)null)
{
__result.AddComponent<FlameParticleEmitter>();
}
}
}
catch (Exception ex)
{
log.LogWarning((object)("[生成防护] 设置失败: " + ex.Message));
}
}
}
[HarmonyPatch(typeof(ProjectileHit), "Hit", new Type[]
{
typeof(RaycastHit),
typeof(float)
})]
private static class HitDiag
{
[HarmonyPostfix]
private static void Postfix(ProjectileHit __instance, RaycastHit sentHit)
{
}
}
internal sealed class TemplateWatchdog : MonoBehaviour
{
private float next;
private int rounds;
private void Update()
{
if (!(Time.unscaledTime < next))
{
next = Time.unscaledTime + 30f;
rounds++;
log.LogInfo((object)("[模板自检] 弹丸模板=" + CountAlive(bulletTemplates) + " 个 " + ListAlive(bulletTemplates) + " 现代火苗=" + Describe(cachedFlame)));
if (rounds >= 20)
{
Object.Destroy((Object)(object)this);
}
}
}
private static int CountAlive(List<GameObject> list)
{
if (list == null)
{
return 0;
}
int num = 0;
foreach (GameObject item in list)
{
if ((Object)(object)item != (Object)null)
{
num++;
}
}
return num;
}
private static string ListAlive(List<GameObject> list)
{
if (list == null)
{
return "(无)";
}
StringBuilder stringBuilder = new StringBuilder();
foreach (GameObject item in list)
{
if (!((Object)(object)item == (Object)null))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(',');
}
stringBuilder.Append(((Object)item).name);
}
}
if (stringBuilder.Length != 0)
{
return stringBuilder.ToString();
}
return "(无)";
}
private static string Describe(GameObject go)
{
if ((Object)(object)go == (Object)null)
{
return "null";
}
return "存活(" + ((Object)go).name + ", active=" + go.activeInHierarchy + ")";
}
}
internal sealed class FlashlightKeeper : MonoBehaviour
{
public Light light;
public ShootPosition shoot;
private void LateUpdate()
{
//IL_0006: 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_00bd: 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_00d7: 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)
if (((Component)this).transform.position.y < -1000f)
{
return;
}
if ((Object)(object)light == (Object)null)
{
Light[] componentsInChildren = ((Component)this).GetComponentsInChildren<Light>(true);
foreach (Light val in componentsInChildren)
{
if ((Object)(object)val != (Object)null && (int)val.type == 0)
{
light = val;
break;
}
}
}
if ((Object)(object)light == (Object)null)
{
return;
}
((Behaviour)light).enabled = true;
light.intensity = 3f;
if ((Object)(object)shoot == (Object)null)
{
shoot = ((Component)this).GetComponentInChildren<ShootPosition>();
}
if ((Object)(object)shoot != (Object)null)
{
Vector3 forward = ((Component)shoot).transform.forward;
if (((Vector3)(ref forward)).sqrMagnitude > 0.0001f)
{
((Component)light).transform.rotation = Quaternion.LookRotation(forward);
}
}
}
}
internal sealed class ShootFxDiag : MonoBehaviour
{
private ParticleSystem muzzleFlash;
private ParticleSystem shell;
private bool registered;
private int printed;
private void Init()
{
ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
foreach (ParticleSystem val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null))
{
if (((Object)((Component)val).gameObject).name.Contains("MuzzleFlash"))
{
muzzleFlash = val;
}
else if (((Object)((Component)val).gameObject).name.Contains("FX_Bullet_Shells_01"))
{
shell = val;
}
}
}
RangeWeapon component = ((Component)this).GetComponent<RangeWeapon>();
MethodInfo methodInfo = AccessTools.Method(typeof(RangeWeapon), "AddShootAction", (Type[])null, (Type[])null);
if ((Object)(object)component != (Object)null && methodInfo != null)
{
Action action = EmitFx;
methodInfo.Invoke(component, new object[1] { action });
registered = true;
}
log.LogWarning((object)("[开火特效修复] " + ((Object)((Component)this).gameObject).name + " 注册Emit回调=" + registered + " flash=" + ((Object)(object)muzzleFlash != (Object)null) + " shell=" + ((Object)(object)shell != (Object)null)));
}
private void EmitFx()
{
if ((Object)(object)muzzleFlash != (Object)null)
{
try
{
muzzleFlash.Play();
muzzleFlash.Emit(6);
}
catch
{
}
}
if ((Object)(object)shell != (Object)null)
{
try
{
shell.Play();
shell.Emit(2);
}
catch
{
}
}
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (!(((Component)this).transform.position.y < -1000f) && !registered)
{
Init();
}
}
}
internal sealed class FlameJetFx : MonoBehaviour
{
private ParticleSystem jet;
private ParticleSystem[] jetSystems;
private bool registered;
private void Init()
{
Transform val = FindChildRecursive(((Component)this).transform, "exampleEffect_FlameThrower");
if (Object.op_Implicit((Object)(object)val))
{
jet = ((Component)val).GetComponent<ParticleSystem>();
}
if ((Object)(object)jet != (Object)null)
{
jetSystems = ((Component)jet).GetComponentsInChildren<ParticleSystem>(true);
}
ShootPosition componentInChildren = ((Component)this).GetComponentInChildren<ShootPosition>();
if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)((Component)componentInChildren).transform.parent))
{
val.SetParent(((Component)componentInChildren).transform.parent);
}
RangeWeapon component = ((Component)this).GetComponent<RangeWeapon>();
MethodInfo methodInfo = AccessTools.Method(typeof(RangeWeapon), "AddShootAction", (Type[])null, (Type[])null);
if ((Object)(object)jet != (Object)null && (Object)(object)component != (Object)null && methodInfo != null)
{
methodInfo.Invoke(component, new object[1]
{
new Action(EmitJet)
});
registered = true;
}
log.LogWarning((object)("[喷火修复] " + ((Object)((Component)this).gameObject).name + " 找到粒子=" + ((Object)(object)val != (Object)null) + " PS=" + ((Object)(object)jet != (Object)null) + " 注册回调=" + registered));
}
private void EmitJet()
{
//IL_003d: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)jet == (Object)null)
{
return;
}
try
{
jet.Play(true);
if (jetSystems != null)
{
ParticleSystem[] array = jetSystems;
foreach (ParticleSystem val in array)
{
if (!((Object)(object)val == (Object)null))
{
EmissionModule emission = val.emission;
MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
float constant = ((MinMaxCurve)(ref rateOverTime)).constant;
int num = ((constant > 0f) ? Mathf.Clamp(Mathf.RoundToInt(constant * 0.1f), 2, 40) : 6);
val.Emit(num);
}
}
}
else
{
jet.Emit(30);
}
}
catch
{
}
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (!(((Component)this).transform.position.y < -1000f) && !registered)
{
Init();
}
}
private static Transform FindChildRecursive(Transform parent, string name)
{
if ((Object)(object)parent == (Object)null)
{
return null;
}
if (((Object)parent).name == name)
{
return parent;
}
for (int i = 0; i < parent.childCount; i++)
{
Transform val = FindChildRecursive(parent.GetChild(i), name);
if (Object.op_Implicit((Object)(object)val))
{
return val;
}
}
return null;
}
}
internal sealed class FlameParticleEmitter : MonoBehaviour
{
private ParticleSystem[] systems;
private float[] budgets;
private float[] carry;
private void Awake()
{
//IL_0006: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (((Component)this).transform.position.y < -1000f)
{
return;
}
systems = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
if (systems == null || systems.Length == 0)
{
return;
}
budgets = new float[systems.Length];
carry = new float[systems.Length];
for (int i = 0; i < systems.Length; i++)
{
float num;
if (!((Object)(object)systems[i] != (Object)null))
{
num = 0f;
}
else
{
EmissionModule emission = systems[i].emission;
MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
num = ((MinMaxCurve)(ref rateOverTime)).constant;
}
float num2 = num;
budgets[i] = ((num2 > 0f) ? num2 : 2f);
}
EmitAll(0.1f);
}
private void Update()
{
if (systems != null)
{
float deltaTime = Time.deltaTime;
if (!(deltaTime <= 0f))
{
EmitAll(deltaTime);
}
}
}
private void EmitAll(float dt)
{
for (int i = 0; i < systems.Length; i++)
{
ParticleSystem val = systems[i];
if ((Object)(object)val == (Object)null)
{
continue;
}
carry[i] += budgets[i] * dt;
int num = (int)carry[i];
if (num > 0)
{
carry[i] -= num;
try
{
val.Emit(num);
}
catch
{
}
}
}
}
}
internal sealed class TemplateGuard : MonoBehaviour
{
public bool restoreRemove;
public float seconds = 5f;
public bool shrink;
public bool isTemplate;
private void Start()
{
if (IsRegisteredTemplate(((Component)this).gameObject))
{
return;
}
TrailRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<TrailRenderer>(true);
foreach (TrailRenderer val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null))
{
val.emitting = true;
((Renderer)val).enabled = true;
}
}
if (restoreRemove)
{
RemoveAfterSeconds val2 = ((Component)this).gameObject.GetComponent<RemoveAfterSeconds>();
if ((Object)(object)val2 == (Object)null)
{
val2 = ((Component)this).gameObject.AddComponent<RemoveAfterSeconds>();
}
val2.seconds = seconds;
val2.shrink = shrink;
}
}
private void DumpRuntimeProjectile()
{
//IL_00dd: 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_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
try
{
ProjectileHit componentInChildren = ((Component)this).GetComponentInChildren<ProjectileHit>();
MoveTransform componentInChildren2 = ((Component)this).GetComponentInChildren<MoveTransform>();
TrailRenderer componentInChildren3 = ((Component)this).GetComponentInChildren<TrailRenderer>();
RaycastTrail componentInChildren4 = ((Component)this).GetComponentInChildren<RaycastTrail>();
TeamHolder component = ((Component)this).GetComponent<TeamHolder>();
StringBuilder stringBuilder = new StringBuilder();
Component[] componentsInChildren = ((Component)this).GetComponentsInChildren<Component>(true);
foreach (Component val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null))
{
stringBuilder.Append(((object)val).GetType().Name).Append(',');
}
}
string text = "NULL";
if ((Object)(object)componentInChildren3 != (Object)null && (Object)(object)((Renderer)componentInChildren3).sharedMaterial != (Object)null && (Object)(object)((Renderer)componentInChildren3).sharedMaterial.shader != (Object)null)
{
text = ((Object)((Renderer)componentInChildren3).sharedMaterial.shader).name;
}
ManualLogSource log = HelmetPatchPlugin.log;
object[] array = new object[22];
array[0] = ((Object)((Component)this).gameObject).name;
Vector3 position = ((Component)this).transform.position;
array[1] = ((Vector3)(ref position)).ToString("F1");
array[2] = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.damage.ToString("F1") : "null");
array[3] = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.allowedHits.ToString() : "-");
array[4] = (Object)(object)componentInChildren != (Object)null;
array[5] = (Object)(object)componentInChildren2 != (Object)null;
array[6] = (((Object)(object)componentInChildren2 != (Object)null) ? componentInChildren2.gravity.ToString("F1") : "-");
array[7] = (Object)(object)componentInChildren3 != (Object)null;
array[8] = ((!((Object)(object)componentInChildren3 != (Object)null)) ? "-" : (((Object)(object)((Renderer)componentInChildren3).sharedMaterial != (Object)null) ? ((Object)((Renderer)componentInChildren3).sharedMaterial).name : "NULL"));
array[9] = (Object)(object)componentInChildren3 != (Object)null && ((Renderer)componentInChildren3).enabled;
array[10] = (Object)(object)componentInChildren4 != (Object)null;
array[11] = (Object)(object)component != (Object)null;
array[12] = (((Object)(object)component != (Object)null) ? ((object)Unsafe.As<Team, Team>(ref component.team)/*cast due to .constrained prefix*/).ToString() : "-");
array[13] = (Object)(object)component != (Object)null && (Object)(object)component.spawner != (Object)null;
array[14] = stringBuilder.ToString();
array[15] = text;
array[16] = (Object)(object)componentInChildren3 != (Object)null && componentInChildren3.emitting;
array[17] = (((Object)(object)componentInChildren3 != (Object)null) ? componentInChildren3.time.ToString("F3") : "-");
array[18] = (((Object)(object)componentInChildren3 != (Object)null) ? componentInChildren3.startWidth.ToString("F3") : "-");
array[19] = (((Object)(object)componentInChildren3 != (Object)null) ? componentInChildren3.endWidth.ToString("F3") : "-");
array[20] = (((Object)(object)componentInChildren3 != (Object)null) ? componentInChildren3.positionCount.ToString() : "-");
array[21] = (((Object)(object)componentInChildren3 != (Object)null) ? ((object)componentInChildren3.startColor/*cast due to .constrained prefix*/).ToString() : "-");
log.LogWarning((object)string.Format("[弹丸诊断] name={0} pos={1} damage={2} allowedHits={3} ProjectileHit={4} MoveTransform={5}(grav={6}) TrailRenderer={7}(mat={8},enabled={9}) RaycastTrail={10} TeamHolder={11}(team={12},spawner={13}) 组件=[{14}] TRAIL[shader={15} emit={16} time={17} w={18}/{19} pts={20} color={21}]", array));
}
catch (Exception ex)
{
HelmetPatchPlugin.log.LogWarning((object)("[弹丸诊断] 打印失败: " + ex.Message));
}
}
private static bool IsRegisteredTemplate(GameObject go)
{
if ((Object)(object)cachedFlame == (Object)(object)go)
{
return true;
}
foreach (GameObject bulletTemplate in bulletTemplates)
{
if ((Object)(object)bulletTemplate == (Object)(object)go)
{
return true;
}
}
return false;
}
}
internal struct GunSpec
{
public readonly string DisplayName;
public readonly string Container;
public readonly string BundleKey;
public readonly float Scale;
public readonly Vector3 Rotation;
public readonly Vector3 Translation;
public readonly bool Flashlight;
public readonly bool MuzzleEffects;
public readonly int Capacity;
public readonly float ShotInterval;
public readonly float ReloadSeconds;
public readonly float Recoil;
public readonly float TorsoRecoil;
public readonly float Spread;
public readonly float Range;
public readonly bool ModernBullet;
public readonly bool FlameBullet;
public readonly bool RocketBullet;
public readonly float Damage;
public readonly int Hits;
public readonly int Bullets;
public GunSpec(string displayName, string container, string bundleKey, float scale, Vector3 rotation, Vector3 translation, bool flashlight, bool muzzleEffects, int capacity, float shotInterval, float reloadSeconds, float recoil, float range, bool modernBullet = true, bool flameBullet = false, float damage = 20f, int hits = 1, int bullets = 1, float torsoRecoil = float.NaN, float spread = 0f, bool rocketBullet = false)
{
//IL_001e: 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_0026: 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)
DisplayName = displayName;
Container = container;
BundleKey = bundleKey;
Scale = scale;
Rotation = rotation;
Translation = translation;
Flashlight = flashlight;
MuzzleEffects = muzzleEffects;
Capacity = capacity;
ShotInterval = shotInterval;
ReloadSeconds = reloadSeconds;
Recoil = recoil;
TorsoRecoil = (float.IsNaN(torsoRecoil) ? recoil : torsoRecoil);
Spread = spread;
Range = range;
ModernBullet = modernBullet;
FlameBullet = flameBullet;
RocketBullet = rocketBullet;
Damage = damage;
Hits = hits;
Bullets = bullets;
}
}
internal struct HelmetSpec
{
public readonly string DisplayName;
public readonly string BundleKey;
public readonly GearType Gear;
public readonly float Scale;
public readonly Vector3 Rotation;
public readonly Vector3 Translation;
public HelmetSpec(string displayName, string bundleKey, GearType gear, float scale, Vector3 rotation, Vector3 translation)
{
//IL_000f: 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_001e: 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_0026: 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)
DisplayName = displayName;
BundleKey = bundleKey;
Gear = gear;
Scale = scale;
Rotation = rotation;
Translation = translation;
}
}
public const string Guid = "modernization.helmet.patch";
public const string Version = "0.2.0";
public const string PortGuid = "modernization.port.bepinex";
private const int ModId = 1459449901;
private const int IdBase = 800000;
private static readonly HelmetSpec[] Specs = new HelmetSpec[16]
{
new HelmetSpec("现代军盔", "Modernization/clothes/Militaryhelmet4", (GearType)0, 0.105f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.075f, 0.0525f)),
new HelmetSpec("军盔 MK1", "Modernization/clothes/Militaryhelmet1", (GearType)0, 0.215f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.1f, 0.045f)),
new HelmetSpec("军盔 MK3", "Modernization/clothes/militaryhelmet3", (GearType)0, 0.125f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.075f, 0.0125f)),
new HelmetSpec("军盔 MK5", "Modernization/clothes/Militaryhelmet5", (GearType)0, 0.105f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.095f, 0.0125f)),
new HelmetSpec("军盔 MK6", "Modernization/clothes/Militaryhelmet6", (GearType)0, 0.115f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.055f, 0.0415f)),
new HelmetSpec("护目头盔", "Modernization/clothes/gogglehelmet", (GearType)0, 1f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f)),
new HelmetSpec("军医头盔", "Modernization/clothes/googlehelmetmedic", (GearType)0, 1.24f, new Vector3(0f, 0f, 0f), new Vector3(0.005f, 0f, 0f)),
new HelmetSpec("防暴头盔", "Modernization/clothes/Riothelmet2", (GearType)0, 1.05f, new Vector3(0f, 0f, 0f), new Vector3(0.01f, 0f, 0f)),
new HelmetSpec("特警头盔", "Modernization/clothes/swathelm2", (GearType)0, 1.05f, new Vector3(0f, 0f, 0f), new Vector3(0.005f, 0f, 0.015f)),
new HelmetSpec("特警头盔 变体", "Modernization/clothes/Swathelm Variant", (GearType)0, 1f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f)),
new HelmetSpec("重装头盔", "Modernization/clothes/Juggernauthelm", (GearType)0, 0.0115f, new Vector3(-90f, 0f, 0f), new Vector3(0f, -0.05f, -0.05f)),
new HelmetSpec("军用背心", "Modernization/clothes/Militaryvest2", (GearType)3, 1.05f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.25f, -0.05f)),
new HelmetSpec("伞兵背心", "Modernization/clothes/paratroopervest", (GearType)3, 1.055f, new Vector3(90f, 0f, 0f), new Vector3(0f, -0.17f, 0.05f)),
new HelmetSpec("特警防弹衣", "Modernization/clothes/swatbodyarmor", (GearType)3, 1.05f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.25f, -0.05f)),
new HelmetSpec("重装甲", "Modernization/clothes/Juggarmor", (GearType)3, 0.4f, new Vector3(0f, 100f, 0f), new Vector3(0f, -0.9f, 0.1f)),
new HelmetSpec("医疗包", "Modernization/clothes/medicpack", (GearType)3, 1.025f, new Vector3(0f, 0f, 0f), new Vector3(0f, -0.25f, -0.05f))
};
private static readonly GunSpec[] GunSpecs = new GunSpec[17]
{
new GunSpec("现代手枪", "Glock18", "Modernization/guns/beretta", 1f, new Vector3(0f, 90f, 0f), new Vector3(0f, -0.05f, 0.1f), flashlight: false, muzzleEffects: true, 9, 1f, 3f, 5f, 85f, modernBullet: true, flameBullet: false, 20f, 1, 1, 0f, 2.5f),
new GunSpec("现代沙漠之鹰", "Glock18", "Modernization/guns/Deagle", 1f, new Vector3(0f, -90f, 0f), new Vector3(0f, -0.085f, 0.28f), flashlight: false, muzzleEffects: true, 6, 1f, 3f, 9.5f, 100f, modernBullet: true, flameBullet: false, 100f, 2, 1, 9.5f, 1f),
new GunSpec("现代P90", "Musket", "Modernization/guns/P90 (2)", 1f, new Vector3(0f, -90f, 0f), new Vector3(0f, 0f, 0.2f), flashlight: true, muzzleEffects: true, 50, 0.06f, 5f, 2.5f, 145f, modernBullet: true, flameBullet: false, 20f, 1, 1, 1f, 3.5f),
new GunSpec("现代乌兹", "Musket", "Modernization/guns/Uzi", 1f, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0.2f), flashlight: false, muzzleEffects: true, 30, 0.065f, 3.5f, 2.5f, 95f, modernBullet: true, flameBullet: false, 25f, 1, 1, 1f, 3.5f),
new GunSpec("现代AK-47", "Musket", "Modernization/guns/Ak-47", 1f, new Vector3(0f, 180f, 0f), new Vector3(0f, 0f, 0.175f), flashlight: false, muzzleEffects: true, 30, 0.1f, 3.5f, 10.5f, 135f, modernBullet: true, flameBullet: false, 50f, 1, 1, 0f, 2.5f),
new GunSpec("现代AR-15", "Musket", "Modernization/guns/Ar15", 1f, new Vector3(-90f, 0f, 180f), new Vector3(0f, -0.05f, 0.375f), flashlight: true, muzzleEffects: true, 30, 0.08f, 5f, 2f, 150f, modernBullet: true, flameBullet: false, 20f, 1, 1, 2f, 2.5f),
new GunSpec("现代SCAR-L", "Musket", "Modernization/guns/Scar-L", 1f, new Vector3(-90f, 0f, 90f), new Vector3(0f, 0f, 0.4f), flashlight: false, muzzleEffects: true, 30, 0.075f, 5f, 5.5f, 150f, modernBullet: true, flameBullet: false, 50f, 1, 1, 2f, 1.5f),
new GunSpec("现代SCAR-2倍镜", "Musket", "Modernization/guns/Scarwith2xscope", 1f, new Vector3(-90f, 0f, 0f), new Vector3(0f, 0.075f, 0.25f), flashlight: false, muzzleEffects: true, 30, 0.075f, 5f, 5.5f, 150f, modernBullet: true, flameBullet: false, 50f, 1, 1, 2f, 1.5f),
new GunSpec("现代SS2突击步枪", "Musket", "Modernization/guns/SS2_AssaultRifle", 1f, new Vector3(-90f, 0f, 0f), new Vector3(0f, 0.075f, 0.35f), flashlight: true, muzzleEffects: true, 30, 0.075f, 5f, 8f, 150f, modernBullet: true, flameBullet: false, 45f, 1, 1, 3f, 2.5f),
new GunSpec("现代VSS微声狙", "Musket", "Modernization/guns/VSSMK1", 1f, new Vector3(0f, 180f, 0f), new Vector3(0f, -0.15f, 0.1f), flashlight: false, muzzleEffects: true, 12, 1.1f, 5f, 5.5f, 350f, modernBullet: true, flameBullet: false, 100f, 2, 1, 3.5f, 0.75f),
new GunSpec("现代CheyTac狙击", "Musket", "Modernization/guns/Sniper1", 1f, new Vector3(-90f, 0f, 0f), new Vector3(0f, -0.05f, 0.38f), flashlight: false, muzzleEffects: true, 5, 2.85f, 6f, 14.5f, 650f, modernBullet: true, flameBullet: false, 700f, 5, 1, 7.5f, 0.05f),
new GunSpec("现代AWP", "Musket", "Modernization/guns/Sniper2", 1f, new Vector3(-90f, 180f, 0f), new Vector3(0f, 0f, 0.425f), flashlight: false, muzzleEffects: true, 5, 1.65f, 5f, 14.5f, 650f, modernBullet: true, flameBullet: false, 200f, 2, 1, 7.5f, 0.05f),
new GunSpec("现代雷明顿霰弹", "Musket", "Modernization/guns/Shotgun1 (2)", 1f, new Vector3(0f, 90f, 0f), new Vector3(0f, -0.1f, 0.2f), flashlight: false, muzzleEffects: true, 7, 1.5f, 6f, 2.5f, 61f, modernBullet: true, flameBullet: false, 85f, 2, 6, 2.5f, 6.5f),
new GunSpec("现代M249机枪", "Musket", "Modernization/guns/m249", 1f, new Vector3(-90f, 0f, 0f), new Vector3(0f, 0f, -0.19f), flashlight: false, muzzleEffects: true, 150, 0.085f, 10f, 12.5f, 200f, modernBullet: true, flameBullet: false, 75f, 1, 1, 0f, 6.5f),
new GunSpec("现代榴弹发射器", "Chukonu", "Modernization/guns/grenadelauncher", 1.4f, new Vector3(-90f, 90f, 0f), new Vector3(0f, -0.3f, 0.335f), flashlight: false, muzzleEffects: true, 6, 1f, 5f, 15.5f, 94f, modernBullet: true, flameBullet: false, 50f, 1, 1, 3.5f, 3.5f, rocketBullet: true),
new GunSpec("现代火焰喷射器", "HarpoonGun", "Modernization/guns/Flamethrower", 1.25f, new Vector3(0f, -200f, 0f), new Vector3(-0.1f, 0.25f, 1.05f), flashlight: false, muzzleEffects: false, 100, 0.1f, 6f, 0f, 40f, modernBullet: false, flameBullet: true),
new GunSpec("现代警棍", "BrawlerAxe", "Modernization/guns/policebaton", 0.065f, new Vector3(90f, -94f, 0f), new Vector3(0f, 0.275f, 0.1f), flashlight: false, muzzleEffects: false, 30, 0.075f, 5f, 5.5f, 150f, modernBullet: false)
};
private static ManualLogSource log;
internal static bool Done;
private float nextCheck;
private static Harmony harmony;
private static readonly List<GameObject> bulletTemplates = new List<GameObject>();
private static bool flameBuilt;
private static GameObject cachedFlame;
private static readonly Vector3 HiddenOrigin = new Vector3(0f, -10000f, 0f);
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
log = ((BaseUnityPlugin)this).Logger;
log.LogInfo((object)"Helmet Editor Patch 0.2.0 已加载,等待内容库就绪。");
try
{
harmony = new Harmony("modernization.helmet.patch");
harmony.PatchAll(typeof(HelmetPatchPlugin).Assembly);
int num = harmony.GetPatchedMethods().Count();
log.LogInfo((object)("已挂载 Harmony 补丁,命中方法数: " + num));
}
catch (Exception ex)
{
log.LogError((object)("挂载 Harmony 补丁失败: " + ex));
}
}
private void Update()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
if (Done || Time.realtimeSinceStartup < nextCheck)
{
return;
}
nextCheck = Time.realtimeSinceStartup + 1f;
try
{
ContentDatabase val = (ContentDatabase)AccessTools.Field(typeof(ContentDatabase), "m_instance").GetValue(null);
if (val != null && val.LandfallContentDatabase != null && val.LandfallContentDatabase.GetUnitBlueprints().Any() && PortReady())
{
Done = true;
RegisterHelmets(val);
RegisterGuns(val);
((Component)this).gameObject.AddComponent<TemplateWatchdog>();
}
}
catch (Exception ex)
{
Done = true;
log.LogError((object)("注册头盔失败: " + ex));
}
}
private static bool PortReady()
{
try
{
Type type = AccessTools.TypeByName("ModernizationPort.PortPlugin");
if (type == null)
{
return false;
}
FieldInfo fieldInfo = AccessTools.Field(type, "Ready");
return fieldInfo != null && (bool)fieldInfo.GetValue(null);
}
catch
{
return false;
}
}
private unsafe void RegisterHelmets(ContentDatabase content)
{
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: 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_0111: 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_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
LandfallContentDatabase landfallContentDatabase = content.LandfallContentDatabase;
FieldInfo fieldInfo = AccessTools.Field(typeof(LandfallContentDatabase), "m_characterProps");
if (fieldInfo == null)
{
log.LogError((object)"找不到 m_characterProps。");
return;
}
if (!(fieldInfo.GetValue(landfallContentDatabase) is IDictionary<DatabaseID, GameObject> dictionary))
{
log.LogError((object)"m_characterProps 类型不符。");
return;
}
IDictionary<DatabaseID, Object> dictionary2 = AccessTools.Field(((object)content.AssetLoader).GetType(), "m_nonStreamableAssets")?.GetValue(content.AssetLoader) as IDictionary<DatabaseID, Object>;
GameObject val = FindVanillaHelmetTemplate();
if ((Object)(object)val == (Object)null)
{
log.LogError((object)"找不到原版头盔模板(仅用于取 Entity 元数据)。");
return;
}
CharacterItem component = val.GetComponent<CharacterItem>();
if ((Object)(object)component == (Object)null || component.Entity == null)
{
log.LogError((object)"模板缺少 CharacterItem/Entity。");
return;
}
int num = 0;
HelmetSpec[] specs = Specs;
for (int i = 0; i < specs.Length; i++)
{
HelmetSpec spec = specs[i];
List<DatabaseID> list = new List<DatabaseID>();
try
{
DatabaseID val2 = NewId(dictionary, component.Entity.GUID, "helmet/" + spec.DisplayName);
GameObject value = BuildHelmet(component.Entity, spec, val2);
dictionary.Add(val2, value);
list.Add(val2);
if (dictionary2 != null)
{
if (dictionary2.ContainsKey(val2))
{
DatabaseID val3 = val2;
throw new InvalidOperationException("资产 ID 已被占用: " + ((object)(*(DatabaseID*)(&val3))/*cast due to .constrained prefix*/).ToString());
}
dictionary2.Add(val2, (Object)(object)value);
}
num++;
log.LogInfo((object)("已注册头盔: " + spec.DisplayName + " ID=(" + val2.m_modID + "," + val2.m_ID + ")"));
}
catch (Exception ex)
{
foreach (DatabaseID item in list)
{
dictionary.Remove(item);
try
{
dictionary2?.Remove(item);
}
catch
{
}
}
log.LogError((object)("头盔 " + spec.DisplayName + " 失败(已回滚): " + ex));
}
}
log.LogInfo((object)("完成,新增 " + num + " 顶;衣物总数 " + dictionary.Count));
}
private unsafe void RegisterGuns(ContentDatabase content)
{
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
try
{
LandfallContentDatabase landfallContentDatabase = content.LandfallContentDatabase;
FieldInfo fieldInfo = AccessTools.Field(typeof(LandfallContentDatabase), "m_weapons");
if (fieldInfo == null)
{
log.LogError((object)"找不到 m_weapons。");
return;
}
if (!(fieldInfo.GetValue(landfallContentDatabase) is IDictionary<DatabaseID, GameObject> dictionary))
{
log.LogError((object)"m_weapons 类型不符。");
return;
}
IDictionary<DatabaseID, Object> dictionary2 = AccessTools.Field(((object)content.AssetLoader).GetType(), "m_nonStreamableAssets")?.GetValue(content.AssetLoader) as IDictionary<DatabaseID, Object>;
int num = 0;
int num2 = -1;
GunSpec[] gunSpecs = GunSpecs;
for (int i = 0; i < gunSpecs.Length; i++)
{
GunSpec spec = gunSpecs[i];
num2++;
DatabaseID val = default(DatabaseID);
bool flag = false;
try
{
if (!ULoader.VDic.ContainsKey("weapons") || !ULoader.VDic["weapons"].TryGetValue(spec.Container, out var value))
{
goto IL_0101;
}
GameObject val2 = (GameObject)((value is GameObject) ? value : null);
if (val2 == null || !Object.op_Implicit((Object)(object)val2))
{
goto IL_0101;
}
CharacterItem component = val2.GetComponent<CharacterItem>();
if ((Object)(object)component == (Object)null || component.Entity == null)
{
log.LogError((object)("容器缺少 CharacterItem/Entity: " + spec.Container));
continue;
}
val = NewId(dictionary, component.Entity.GUID, "gun/" + spec.DisplayName);
GameObject val3 = BuildGun(val2, component.Entity, spec, val, landfallContentDatabase, dictionary2, num2);
if ((Object)(object)val3 == (Object)null)
{
continue;
}
dictionary.Add(val, val3);
flag = true;
if (dictionary2 != null)
{
if (dictionary2.ContainsKey(val))
{
DatabaseID val4 = val;
throw new InvalidOperationException("资产 ID 已被占用: " + ((object)(*(DatabaseID*)(&val4))/*cast due to .constrained prefix*/).ToString());
}
dictionary2.Add(val, (Object)(object)val3);
}
num++;
log.LogInfo((object)("已注册枪械: " + spec.DisplayName + " ID=(" + val.m_modID + "," + val.m_ID + ")"));
goto end_IL_00bb;
IL_0101:
log.LogError((object)("找不到原版武器容器: " + spec.Container));
end_IL_00bb:;
}
catch (Exception ex)
{
if (flag)
{
try
{
dictionary.Remove(val);
}
catch
{
}
try
{
dictionary2?.Remove(val);
}
catch
{
}
}
log.LogError((object)("枪械 " + spec.DisplayName + " 失败(已回滚): " + ex));
}
}
log.LogInfo((object)("完成,新增 " + num + " 把枪;武器总数 " + dictionary.Count));
}
catch (Exception ex2)
{
log.LogError((object)("注册枪械时异常(不影响服装): " + ex2));
}
}
private GameObject BuildGun(GameObject template, DatabaseEntity templateEntity, GunSpec spec, DatabaseID id, LandfallContentDatabase dbRef, IDictionary<DatabaseID, Object> assetsRef, int specIndex)
{
//IL_0037: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: 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_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(template);
((Object)val).name = "CP_" + spec.DisplayName;
Object.DontDestroyOnLoad((Object)(object)val);
ClearWeaponArtefacts(val);
if ((Object)(object)PinaCollada.SetBundleObject(val, spec.BundleKey, spec.Scale, (Vector3?)spec.Rotation, (Vector3?)spec.Translation, "/guns/" + spec.DisplayName) == (Object)null)
{
log.LogError((object)("枪械模型加载失败: " + spec.BundleKey));
Object.DestroyImmediate((Object)(object)val);
return null;
}
if (spec.Flashlight)
{
Weapon component = val.GetComponent<Weapon>();
if ((Object)(object)component != (Object)null)
{
component.possessionAimingMode = (PossessionAimingMode)1;
}
Transform val2 = null;
Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
foreach (Transform val3 in componentsInChildren)
{
if (((Object)((Component)val3).gameObject).name.Contains("FlashLightprefab"))
{
val2 = val3;
break;
}
}
if ((Object)(object)val2 == (Object)null)
{
val2 = val.transform;
}
Light val4 = ((Component)val2).gameObject.AddComponent<Light>();
val4.type = (LightType)0;
val4.color = new Color(1f, 1f, 1f);
val4.spotAngle = 20f;
val4.range = 20f;
val4.shadows = (LightShadows)0;
val4.intensity = 3f;
((Behaviour)val4).enabled = true;
ShootPosition componentInChildren = val.GetComponentInChildren<ShootPosition>();
if ((Object)(object)componentInChildren != (Object)null)
{
Vector3 forward = ((Component)componentInChildren).transform.forward;
if (((Vector3)(ref forward)).sqrMagnitude > 0.0001f)
{
((Component)val4).transform.rotation = Quaternion.LookRotation(forward);
}
}
FlashlightKeeper flashlightKeeper = val.AddComponent<FlashlightKeeper>();
flashlightKeeper.light = val4;
flashlightKeeper.shoot = componentInChildren;
}
WeaponItem component2 = val.GetComponent<WeaponItem>();
if ((Object)(object)component2 == (Object)null)
{
log.LogError((object)("容器缺少 WeaponItem: " + spec.Container));
Object.DestroyImmediate((Object)(object)val);
return null;
}
DatabaseEntity val5 = templateEntity.ShallowCopy();
val5.GUID = id;
val5.Name = spec.DisplayName;
AccessTools.Field(typeof(DatabaseEntity), "m_unlockKey").SetValue(val5, "");
AccessTools.Field(typeof(CharacterItem), "m_entity").SetValue(component2, val5);
SetPrivate(component2, "m_showInEditor", true);
RangeWeapon componentInChildren2 = val.GetComponentInChildren<RangeWeapon>();
if ((Object)(object)componentInChildren2 != (Object)null)
{
componentInChildren2.allowedToFire = true;
componentInChildren2.shootRecoil = spec.Recoil;
componentInChildren2.torsoRecoil = spec.TorsoRecoil;
((Weapon)componentInChildren2).maxRange = spec.Range;
componentInChildren2.spread = spec.Spread;
ShootPosition componentInChildren3 = val.GetComponentInChildren<ShootPosition>();
if (Object.op_Implicit((Object)(object)componentInChildren3))
{
((Component)componentInChildren3).transform.localPosition = new Vector3(0f, 0f, 0.15f);
}
LegacyMagazine val6 = LegacyMagazine.For(componentInChildren2);
if ((Object)(object)val6 != (Object)null)
{
val6.InitialAmmo = spec.Capacity;
val6.Capacity = spec.Capacity;
val6.ShotInterval = spec.ShotInterval;
val6.ReloadSeconds = spec.ReloadSeconds;
val6.ReloadSound = "Modernization/reloadsound";
}
componentInChildren2.numberOfObjects = spec.Bullets;
if (spec.FlameBullet)
{
GameObject val7 = BuildFlameBullet(dbRef, assetsRef, componentInChildren2);
if ((Object)(object)val7 != (Object)null)
{
componentInChildren2.ObjectToSpawn = val7;
}
val.AddComponent<FlameJetFx>();
}
else if (spec.RocketBullet)
{
GameObject val8 = BuildGrenadeBullet(dbRef, assetsRef, "现代弹丸·" + spec.DisplayName, 900000 + specIndex);
if ((Object)(object)val8 != (Object)null)
{
componentInChildren2.ObjectToSpawn = val8;
}
}
else if (spec.MuzzleEffects && spec.ModernBullet)
{
bool num = spec.DisplayName.Contains("霰弹");
Color? trailColor = (num ? new Color?(new Color(125f / 128f, 43f / 128f, 0.17578125f)) : ((Color?)null));
string bulletModelKey = (num ? "Modernization/Shotgunbullet" : null);
GameObject val9 = BuildModernBullet(dbRef, assetsRef, spec.Damage, spec.Hits, "现代弹丸·" + spec.DisplayName, 900000 + specIndex, trailColor, bulletModelKey);
if ((Object)(object)val9 != (Object)null)
{
componentInChildren2.ObjectToSpawn = val9;
}
}
if (spec.MuzzleEffects)
{
AddPortComponent(val, "MuzzleFlash");
AddPortComponent(val, "BulletCase");
val.AddComponent<ShootFxDiag>();
}
}
val.SetActive(true);
val.transform.position = HiddenOrigin;
return val;
}
private GameObject BuildModernBullet(LandfallContentDatabase db, IDictionary<DatabaseID, Object> assets, float damage, int hits, string displayName, int numericId, Color? trailColor = null, string bulletModelKey = null)
{
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
try
{
Type type = AccessTools.TypeByName("ModernizationPort.Legacy.UManager");
if (type == null)
{
log.LogError((object)"找不到 UManager,无法生成现代弹丸。");
return null;
}
object obj = Activator.CreateInstance(type);
MethodInfo methodInfo = AccessTools.Method(type, "ModernBullet", new Type[1] { typeof(Unit) }, (Type[])null);
if (methodInfo == null)
{
log.LogError((object)"找不到 UManager.ModernBullet。");
return null;
}
object? obj2 = methodInfo.Invoke(obj, new object[1]);
GameObject val = (GameObject)((obj2 is GameObject) ? obj2 : null);
if ((Object)(object)val == (Object)null)
{
log.LogError((object)"ModernBullet 返回 null(火枪弹丸模板缺失)。");
return null;
}
Object.DontDestroyOnLoad((Object)(object)val);
val.transform.position = HiddenOrigin;
((Object)val).name = displayName;
ProjectileHit componentInChildren = val.GetComponentInChildren<ProjectileHit>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.damage = damage;
componentInChildren.allowedHits = hits;
componentInChildren.stopAditionalHitsOnArmor = false;
componentInChildren.destroyOnRefect = true;
}
else
{
log.LogWarning((object)(displayName + " 没有 ProjectileHit,伤害未设置。"));
}
if (!string.IsNullOrEmpty(bulletModelKey))
{
PinaCollada.SetMeshRenderers(val, false);
PinaCollada.SetStaticMesh(val, bulletModelKey, 0.25f, (Vector3?)null, (Vector3?)Vector3.zero, "PinaCollada Mesh Object");
val.transform.localScale = new Vector3(1f, 1f, 2f);
}
DisarmRemoveAfterSeconds(val);
FixTrailMaterial(val, trailColor);
RegisterBullet(db, assets, val, displayName, numericId);
bulletTemplates.Add(val);
return val;
}
catch (Exception ex)
{
log.LogError((object)("生成现代弹丸失败: " + ex));
return null;
}
}
private GameObject BuildGrenadeBullet(LandfallContentDatabase db, IDictionary<DatabaseID, Object> assets, string displayName, int numericId)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_00d0: 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_00dd: Expected O, but got Unknown
GameObject val = BuildModernBullet(db, assets, 50f, 1, displayName, numericId);
if ((Object)(object)val == (Object)null)
{
return null;
}
try
{
PinaCollada.SetMeshRenderers(val, false);
PinaCollada.SetStaticMesh(val, "Modernization/grenadelauncherammo", 0.15f, (Vector3?)new Vector3(-90f, 0f, 0f), (Vector3?)Vector3.zero, "PinaCollada Mesh Object");
val.transform.localScale = Vector3.one;
ProjectileHit componentInChildren = val.GetComponentInChildren<ProjectileHit>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.damage = 50f;
componentInChildren.force = 150f;
componentInChildren.destroyOnHit = true;
try
{
UPool myPool = UPool.MyPool;
GameObject val2 = ((myPool != null) ? myPool.GetObject("Grenade") : null);
if ((Object)(object)val2 != (Object)null)
{
componentInChildren.objectsToSpawn = (ObjectToSpawn[])(object)new ObjectToSpawn[1]
{
new ObjectToSpawn
{
objectToSpawn = val2
}
};
}
else
{
log.LogWarning((object)"池里没有 Grenade,榴弹将没有爆炸。");
}
}
catch (Exception ex)
{
log.LogWarning((object)("取 Grenade 池对象失败(榴弹无爆炸): " + ex.Message));
}
}
TrailRenderer[] componentsInChildren = val.GetComponentsInChildren<TrailRenderer>(true);
foreach (TrailRenderer val3 in componentsInChildren)
{
if (Object.op_Implicit((Object)(object)val3))
{
Object.DestroyImmediate((Object)(object)val3);
}
}
log.LogInfo((object)(displayName + " 已改造为榴弹弹丸(榴弹模型 + Grenade 爆炸)"));
}
catch (Exception ex2)
{
log.LogWarning((object)("改造榴弹弹丸失败(退回普通现代弹丸): " + ex2.Message));
}
return val;
}
private void FixTrailMaterial(GameObject bullet, Color? trailColor = null)
{
//IL_0023: 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_0028: 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_00b1: 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)
Color val = (Color)(((??)trailColor) ?? new Color(0.99609375f, 0.88671875f, 23f / 128f));
bool flag = ((Object)bullet).name.Contains("霰弹");
TrailRenderer[] componentsInChildren = bullet.GetComponentsInChildren<TrailRenderer>(true);
foreach (TrailRenderer val2 in componentsInChildren)
{
if (!((Object)(object)val2 == (Object)null))
{
val2.autodestruct = false;
val2.time = (flag ? 0.015f : 0.01f);
val2.startWidth = (flag ? 0.045f : 0.04f);
val2.endWidth = (flag ? 0.05f : 0.04f);
val2.startColor = val;
val2.endColor = val;
if (Object.op_Implicit((Object)(object)((Renderer)val2).material))
{
((Renderer)val2).material.color = val;
}
val2.emitting = true;
((Renderer)val2).enabled = true;
((Renderer)val2).receiveShadows = false;
((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val2).allowOcclusionWhenDynamic = true;
((Renderer)val2).motionVectorGenerationMode = (MotionVectorGenerationMode)1;
((Renderer)val2).rendererPriority = 0;
val2.minVertexDistance = 0.1f;
val2.alignment = (LineAlignment)0;
val2.shadowBias = 0.5f;
((Renderer)val2).lightProbeUsage = (LightProbeUsage)1;
}
}
}
private void DisarmRemoveAfterSeconds(GameObject template, float fallbackSeconds = -1f, bool fallbackShrink = false)
{
float num = fallbackSeconds;
bool shrink = fallbackShrink;
bool flag = false;
RemoveAfterSeconds[] componentsInChildren = template.GetComponentsInChildren<RemoveAfterSeconds>(true);
foreach (RemoveAfterSeconds val in componentsInChildren)
{
if (!((Object)(object)val == (Object)null))
{
if (!flag)
{
num = val.seconds;
shrink = val.shrink;
flag = true;
}
Object.DestroyImmediate((Object)(object)val);
}
}
if (!(num < 0f))
{
TemplateGuard templateGuard = template.GetComponent<TemplateGuard>();
if ((Object)(object)templateGuard == (Object)null)
{
templateGuard = template.AddComponent<TemplateGuard>();
}
templateGuard.isTemplate = true;
templateGuard.restoreRemove = true;
templateGuard.seconds = num;
templateGuard.shrink = shrink;
}
}
private GameObject BuildFlameBullet(LandfallContentDatabase db, IDictionary<DatabaseID, Object> assets, RangeWeapon range)
{
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
if (flameBuilt)
{
return cachedFlame;
}
flameBuilt = true;
try
{
GameObject val = null;
try
{
UPool myPool = UPool.MyPool;
val = ((myPool != null) ? myPool.GetObject("rocket") : null);
}
catch (Exception ex)
{
log.LogWarning((object)("取 rocket 池对象失败: " + ex.Message));
}
GameObject val2;
if ((Object)(object)val != (Object)null)
{
val2 = Object.Instantiate<GameObject>(val);
((Object)val2).name = "CP_现代火苗";
}
else
{
log.LogWarning((object)"池里没有 rocket,火苗回退钩爪壳。");
GameObject val3 = (((Object)(object)range != (Object)null) ? range.ObjectToSpawn : null);
if ((Object)(object)val3 == (Object)null)
{
log.LogError((object)"火焰喷射器容器没有弹丸模板。");
return null;
}
val2 = Object.Instantiate<GameObject>(val3);
((Object)val2).name = "CP_现代火苗";
int num = 0;
Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true);
foreach (Component val4 in componentsInChildren)
{
if (!((Object)(object)val4 == (Object)null) && val4 is LineRenderer)
{
((Renderer)(LineRenderer)val4).enabled = false;
num++;
}
}
PullStick[] componentsInChildren2 = val2.GetComponentsInChildren<PullStick>(true);
foreach (PullStick val5 in componentsInChildren2)
{
if ((Object)(object)val5 != (Object)null)
{
((Behaviour)val5).enabled = false;
}
}
ProjectileStick[] componentsInChildren3 = val2.GetComponentsInChildren<ProjectileStick>(true);
foreach (ProjectileStick val6 in componentsInChildren3)
{
if ((Object)(object)val6 != (Object)null)
{
((Behaviour)val6).enabled = false;
}
}
Rigidbody[] componentsInChildren4 = val2.GetComponentsInChildren<Rigidbody>(true);
foreach (Rigidbody val7 in componentsInChildren4)
{
if (!((Object)(object)val7 == (Object)null))
{
val7.useGravity = false;
val7.drag = 0f;
}
}
}
PinaCollada.SetMeshRenderers(val2, false);
if ((Object)(object)val2.GetComponentInChildren<ProjectileHit>() == (Object)null)
{
ProjectileHit obj = val2.AddComponent<ProjectileHit>();
obj.damage = 0f;
obj.force = 0f;
obj.allowedHits = 1;
}
val2.transform.localScale = new Vector3(2f, 0.1f, 2f);
PinaCollada.SetBundleObject(val2, "Modernization/particlesystems/exampleEffect_Fire", 1f, (Vector3?)new Vector3(0f, 0f, 0f), (Vector3?)new Vector3(0f, 0.1f, 0.7f), "/particlesystems/exampleEffect_Fire");
DisarmRemoveAfterSeconds(val2, 5f, fallbackShrink: true);
ParticleSystem[] componentsInChildren5 = val2.GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem val8 in componentsInChildren5)
{
if (!((Object)(object)val8 == (Object)null))
{
MainModule main = val8.main;
((MainModule)(ref main)).startSizeMultiplier = 0.02f;
((MainModule)(ref main)).simulationSpeed = ((MainModule)(ref main)).simulationSpeed * 5f;
CollisionModule collision = val8.collision;
((CollisionModule)(ref collision)).bounceMultiplier = 2f;
((CollisionModule)(ref collision)).colliderForce = 2f;
((CollisionModule)(ref collision)).enableDynamicColliders = true;
((CollisionModule)(ref collision)).collidesWith = LayerMask.op_Implicit(0);
Transform transform = ((Component)val8).transform;
transform.localScale *= 0.02f;
}
}
FlameMovement val9 = val2.GetComponent<FlameMovement>() ?? val2.AddComponent<FlameMovement>();
val9.speed = 7f;
val9.rotSpeed = 0.001f;
try
{
UPool myPool2 = UPool.MyPool;
GameObject val10 = ((myPool2 != null) ? myPool2.GetObject("Flamethrow") : null);
if ((Object)(object)val10 != (Object)null)
{
val9.objectToSpawn = val10;
}
else
{
log.LogWarning((object)"池里没有 Flamethrow,火苗将没有烧伤效果。");
}
}
catch (Exception ex2)
{
log.LogWarning((object)("取 Flamethrow 池对象失败(火苗无烧伤): " + ex2.Message));
}
Object.DontDestroyOnLoad((Object)(object)val2);
val2.transform.position = HiddenOrigin;
RegisterBullet(db, assets, val2, "现代火苗", 900001);
cachedFlame = val2;
log.LogInfo((object)("已注册火苗弹丸(壳=" + (((Object)(object)val != (Object)null) ? "rocket" : "钩爪回退") + ")"));
return val2;
}
catch (Exception ex3)
{
log.LogError((object)("生成火苗弹丸失败: " + ex3));
return null;
}
}
private void RegisterBullet(LandfallContentDatabase db, IDictionary<DatabaseID, Object> assets, GameObject bullet, string displayName, int numericId)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00c4: 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)
if (!(AccessTools.Field(typeof(LandfallContentDatabase), "m_projectiles")?.GetValue(db) is IDictionary<DatabaseID, GameObject> dictionary))
{
log.LogError((object)"找不到 m_projectiles,弹丸未注册。");
return;
}
ProjectileEntity val = bullet.GetComponent<ProjectileEntity>();
if ((Object)(object)val == (Object)null)
{
val = bullet.AddComponent<ProjectileEntity>();
log.LogWarning((object)(displayName + " 原本没有 ProjectileEntity,已补挂。"));
}
DatabaseID val2 = default(DatabaseID);
((DatabaseID)(ref val2))..ctor(1459449901, numericId);
DatabaseEntity val3 = (DatabaseEntity)((val.Entity != null) ? ((object)val.Entity.ShallowCopy()) : ((object)new DatabaseEntity((WorkshopContentType)5)));
val3.GUID = val2;
val3.Name = displayName;
val.Entity = val3;
if (dictionary.ContainsKey(val2))
{
dictionary.Remove(val2);
}
dictionary.Add(val2, bullet);
if (assets != null && !assets.ContainsKey(val2))
{
assets.Add(val2, (Object)(object)bullet);
}
log.LogInfo((object)("已注册弹丸: " + displayName + " ID=(" + val2.m_modID + "," + val2.m_ID + ")"));
}
private static void ClearWeaponArtefacts(GameObject weapon)
{
BoxCollider[] componentsInChildren = weapon.GetComponentsInChildren<BoxCollider>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
}
ParticleSystem[] componentsInChildren2 = weapon.GetComponentsInChildren<ParticleSystem>();
for (int i = 0; i < componentsInChildren2.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
}
ParticleSystemRenderer[] componentsInChildren3 = weapon.GetComponentsInChildren<ParticleSystemRenderer>();
for (int i = 0; i < componentsInChildren3.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
}
}
private static Component AddPortComponent(GameObject host, string typeName)
{
try
{
Type type = PortType(typeName);
if (type == null)
{
log.LogWarning((object)("未找到组件类型: " + typeName));
return null;
}
Component component = host.GetComponent(type);
if ((Object)(object)component != (Object)null)
{
return component;
}
Component val = host.AddComponent(type);
PropertyInfo property = type.GetProperty("enabled");
if (property != null && property.CanWrite)
{
property.SetValue(val, true, null);
}
return val;
}
catch (Exception ex)
{
log.LogWarning((object)("挂载组件 " + typeName + " 失败: " + ex.Message));
return null;
}
}
private static Type PortType(string shortName)
{
Type type = AccessTools.TypeByName("ModernizationPort." + shortName);
if (type != null)
{
return type;
}
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
try
{
Type[] types = assembly.GetTypes();
foreach (Type type2 in types)
{
if (type2.Name == shortName && typeof(Component).IsAssignableFrom(type2))
{
return type2;
}
}
}
catch
{
}
}
return null;
}
private static GameObject FindVanillaHelmetTemplate()
{
try
{
if (ULoader.VDic == null || !ULoader.VDic.ContainsKey("clothes"))
{
return null;
}
Dictionary<string, object> dictionary = ULoader.VDic["clothes"];
string[] array = new string[2] { "Ancient_Helmet004", "Ancient_Helmet001" };
foreach (string text in array)
{
if (dictionary.TryGetValue(text, out var value))
{
GameObject val = (GameObject)((value is GameObject) ? value : null);
if (val != null && Object.op_Implicit((Object)(object)val))
{
log.LogInfo((object)("元数据模板: " + text));
return val;
}
}
}
foreach (KeyValuePair<string, object> item in dictionary)
{
object value2 = item.Value;
GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null);
if (Object.op_Implicit((Object)(object)val2) && ((Object)val2).name.IndexOf("Helmet", StringComparison.OrdinalIgnoreCase) >= 0)
{
log.LogInfo((object)("元数据模板(兜底): " + item.Key));
return val2;
}
}
}
catch (Exception ex)
{
log.LogError((object)("取模板异常: " + ex));
}
return null;
}
private GameObject BuildHelmet(DatabaseEntity templateEntity, HelmetSpec spec, DatabaseID id)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_0069: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("CP_" + spec.DisplayName);
Object.DontDestroyOnLoad((Object)(object)val);
GameObject val2 = new GameObject(spec.DisplayName + "_model");
val2.transform.SetParent(val.transform, false);
val2.transform.localPosition = Vector3.zero;
val2.transform.localRotation = Quaternion.identity;
val2.transform.localScale = Vector3.one;
GameObject val3 = PinaCollada.SetBundleObject(val2, spec.BundleKey, spec.Scale, (Vector3?)spec.Rotation, (Vector3?)spec.Translation, spec.DisplayName);
if ((Object)(object)val3 == (Object)null)
{
log.LogError((object)("模型加载失败: " + spec.BundleKey));
Object.DestroyImmediate((Object)(object)val);
return null;
}
int num = 0;
Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>(true);
foreach (Collider val4 in componentsInChildren)
{
if (!((Object)(object)val4 == (Object)null))
{
Object.DestroyImmediate((Object)(object)val4);
num++;
}
}
if (num > 0)
{
log.LogInfo((object)("护甲 " + spec.DisplayName + " 剥离碰撞体 " + num + " 个"));
}
SkinnedMeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (SkinnedMeshRenderer val5 in componentsInChildren2)
{
if (Object.op_Implicit((Object)(object)val5))
{
Object.DestroyImmediate((Object)(object)val5);
}
}
PropItem val6 = val.AddComponent<PropItem>();
DatabaseEntity val7 = templateEntity.ShallowCopy();
val7.GUID = id;
val7.Name = spec.DisplayName;
AccessTools.Field(typeof(DatabaseEntity), "m_unlockKey").SetValue(val7, "");
AccessTools.Field(typeof(CharacterItem), "m_entity").SetValue(val6, val7);
SetPrivate(val6, "m_gearType", spec.Gear);
SetPrivate(val6, "m_showInEditor", true);
SetPrivate(val6, "m_forceBoneAttach", true);
val.SetActive(true);
val.transform.position = HiddenOrigin;
return val;
}
private static void SetPrivate(object target, string field, object value)
{
FieldInfo obj = AccessTools.Field(target.GetType(), field) ?? AccessTools.Field(typeof(CharacterItem), field);
if (obj == null)
{
throw new MissingFieldException(target.GetType().Name, field);
}
obj.SetValue(target, value);
}
private static DatabaseID NewId(IDictionary<DatabaseID, GameObject> props, DatabaseID templateGuid, string seed)
{
//IL_0028: 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_0039: Unknown result type (might be due to invalid IL or missing references)
int num = StableId(seed);
DatabaseID val = default(DatabaseID);
for (int i = 0; i < 4096; i++)
{
((DatabaseID)(ref val))..ctor(1459449901, 800000 + ((num + i) & 0xFFFF));
if (!((DatabaseID)(ref val)).Equals(templateGuid) && !props.ContainsKey(val))
{
return val;
}
}
throw new InvalidOperationException("找不到可用 ID。");
}
private static int StableId(string text)
{
uint num = 2166136261u;
foreach (char c in text)
{
num ^= c;
num *= 16777619;
}
return (int)(num & 0x7FFFFFFF);
}
}
}