using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using LongshipUpgrades;
using Microsoft.CodeAnalysis;
using ServerSync;
using Splatform;
using TMPro;
using UnityEngine;
using YamlDotNet.Serialization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Longship Upgrades")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Longship Upgrades")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9273280b-9a2b-4143-a5d8-0723a4036a85")]
[assembly: AssemblyFileVersion("1.0.16")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.16.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace LongshipUpgrades
{
public class LongshipCustomizableParts : MonoBehaviour
{
public static bool prefabInit = false;
private Ship m_ship;
private ZNetView m_nview;
private ZDO m_zdo;
private Container m_container;
private bool m_customMast;
private WearNTear m_wnt;
private GameObject m_beamMast;
private GameObject m_beamTent;
private GameObject m_beamMesh;
private GameObject m_beamTentCollider;
private GameObject m_beamSailCollider;
private GameObject m_insects;
private GameObject m_tent;
private GameObject m_lantern;
private GameObject m_holdersRight;
private GameObject m_holdersLeft;
private GameObject m_mastUpgrade;
private GameObject m_storageUpgrade;
private GameObject m_healthUpgrade;
private GameObject m_shieldsStyles;
private GameObject m_headStyles;
private GameObject m_turrets;
private GameObject m_turretsUpgrade;
private GameObject m_itemstandObject;
private GameObject m_wispUpgrade;
private GameObject m_mapTableUpgrade;
private GameObject m_mast;
private GameObject m_ropes;
private GameObject m_sail;
private GameObject m_wisp;
private GameObject m_mapTable;
private MeshRenderer m_lampRenderer;
private Light m_light;
private ParticleSystem m_flare;
private ShipTrophyStand m_trophyStand;
private EffectArea m_fireWarmth;
private GameObject[] m_containerPartsLvl1;
private GameObject[] m_containerPartsLvl2;
private GameObject[] m_protectiveParts;
private GameObject[] m_heads;
private bool m_containerUpgradedLvl1;
private bool m_containerUpgradedLvl2;
private bool m_healthUpgraded;
private bool m_ashlandsUpgraded;
private bool m_isLampLightDisabled;
private int m_headStyle;
private int m_shieldsStyle;
private int m_tentStyle;
private int m_sailStyle;
private GameObject m_destroyedLootPrefab;
public const string prefabName = "VikingShip";
public const string turretName = "piece_turret";
public const string moderBossStone = "BossStone_DragonQueen";
public const string wisptorchName = "piece_groundtorch_mist";
public const string mapTablePrefabName = "maptable";
private static bool prefabInitialized = false;
public static int prefabInt = StringExtensionMethods.GetStableHashCode("VikingShip");
private static Shader shaderStandard;
private static Material standSharedMaterial;
private static Material storageSharedMaterial;
private static Material plankSharedMaterial;
private static GameObject s_lanternPrefab;
private static GameObject s_turretPrefab;
private static GameObject s_standBossDragonPrefab;
private static GameObject s_wisptorchPrefab;
private static GameObject s_mapTablePrefab;
private static Color flareColor;
private static bool isNightTime;
private static bool isTimeToLight = true;
public static readonly int s_mastUpgraded = StringExtensionMethods.GetStableHashCode("MastUpgraded");
public static readonly int s_mastRemoved = StringExtensionMethods.GetStableHashCode("MastRemoved");
public static readonly int s_lanternUpgraded = StringExtensionMethods.GetStableHashCode("LanternUpgraded");
public static readonly int s_lanternDisabled = StringExtensionMethods.GetStableHashCode("LanternDisabled");
public static readonly int s_tentUpgraded = StringExtensionMethods.GetStableHashCode("TentUpgraded");
public static readonly int s_tentDisabled = StringExtensionMethods.GetStableHashCode("TentDisabled");
public static readonly int s_lightsDisabled = StringExtensionMethods.GetStableHashCode("LightDisabled");
public static readonly int s_wispUpgraded = StringExtensionMethods.GetStableHashCode("WispUpgraded");
public static readonly int s_wispRemoved = StringExtensionMethods.GetStableHashCode("WispRemoved");
public static readonly int s_mapTableUpgraded = StringExtensionMethods.GetStableHashCode("MapTableUpgraded");
public static readonly int s_mapDataCompressed = StringExtensionMethods.GetStableHashCode("MapDataCompressed");
public static readonly int s_containerUpgradedLvl1 = StringExtensionMethods.GetStableHashCode("ContainerUpgradedLvl1");
public static readonly int s_containerUpgradedLvl2 = StringExtensionMethods.GetStableHashCode("ContainerUpgradedLvl2");
public static readonly int s_healthUpgraded = StringExtensionMethods.GetStableHashCode("HealthUpgraded");
public static readonly int s_ashlandsUpgraded = StringExtensionMethods.GetStableHashCode("AshlandsUpgraded");
public static readonly int s_turretsUpgraded = StringExtensionMethods.GetStableHashCode("TurretsUpgraded");
public static readonly int s_turretsDisabled = StringExtensionMethods.GetStableHashCode("TurretsDisabled");
public static readonly int s_headStyle = StringExtensionMethods.GetStableHashCode("HeadStyle");
public static readonly int s_shieldsStyle = StringExtensionMethods.GetStableHashCode("ShieldsStyle");
public static readonly int s_tentStyle = StringExtensionMethods.GetStableHashCode("TentStyle");
public static readonly int s_sailStyle = StringExtensionMethods.GetStableHashCode("SailStyle");
public bool blocksIsDirty;
public readonly Dictionary<Renderer, MaterialPropertyBlock> s_propertyBlocks = new Dictionary<Renderer, MaterialPropertyBlock>();
public static Texture2D s_ashlandsHull = new Texture2D(2, 2);
public static Texture2D s_ashlandsHullDamaged = new Texture2D(2, 2);
public const int piece_nonsolid = 16;
public const int vehicle = 28;
public static List<Texture2D> customTents = new List<Texture2D>();
public static List<Texture2D> customSails = new List<Texture2D>();
public static List<Texture2D> customShields = new List<Texture2D>();
private static readonly Dictionary<string, EffectList> buildEffects = new Dictionary<string, EffectList>();
public static EffectList partEffects = new EffectList();
public const int fabricSwitch = 0;
public const int woodSwitch = 1;
public const int lampEnable = 2;
public const int lampDisable = 3;
public const int turretsEnable = 4;
public const int turretsDisable = 5;
public const int wisptorchEnable = 6;
private static readonly Dictionary<GameObject, LongshipCustomizableParts> s_allInstances = new Dictionary<GameObject, LongshipCustomizableParts>();
private static readonly List<DamageModPair> s_fireResistantModifiers = new List<DamageModPair>
{
new DamageModPair
{
m_type = (DamageType)32,
m_modifier = (DamageModifier)5
}
};
private static readonly int s_shipMapDataRevision = StringExtensionMethods.GetStableHashCode("ShipMapDataRevision");
private float m_nextShipMapDataRequestTime;
private int m_lastRequestedShipMapRevision;
private void Awake()
{
if (prefabInit)
{
return;
}
m_ship = ((Component)this).GetComponent<Ship>();
m_wnt = ((Component)this).GetComponent<WearNTear>();
m_nview = ((Component)this).GetComponent<ZNetView>();
ZNetView nview = m_nview;
m_zdo = ((nview != null) ? nview.GetZDO() : null);
((Behaviour)this).enabled = m_nview.IsValid();
if (((Behaviour)this).enabled)
{
m_nview.Register<int, int, int, string>("SetVariant", (Method<int, int, int, string>)RPC_SetVariant);
m_nview.Register<int, bool, int, string>("SetActive", (Method<int, bool, int, string>)RPC_SetActive);
m_nview.Register<int, string, string>("SetBuilt", (Action<long, int, string, string>)RPC_SetBuilt);
}
m_lastRequestedShipMapRevision = 0;
m_container = (from container in ((Component)this).GetComponentsInChildren<Container>()
where ((Object)((Component)container).gameObject).name == "piece_chest"
select container).FirstOrDefault();
m_destroyedLootPrefab = m_container?.m_destroyedLootPrefab;
if (Object.op_Implicit((Object)(object)m_wnt))
{
m_wnt.m_onDestroyed = (Action)Delegate.Combine(m_wnt.m_onDestroyed, new Action(OnDestroyed));
}
if (buildEffects.Count == 0)
{
ObjectDB instance = ObjectDB.instance;
if (instance != null)
{
CollectionExtensions.Do<Recipe>(instance.m_recipes.Where((Recipe recipe) => (Object)(object)recipe.m_craftingStation != (Object)null && recipe.m_craftingStation.m_craftItemEffects.HasEffects()), (Action<Recipe>)delegate(Recipe recipe)
{
buildEffects[recipe.m_craftingStation.m_name] = recipe.m_craftingStation.m_craftItemEffects;
});
}
}
CheckEffects();
GetHildirMapTable();
s_allInstances.Add(((Component)this).gameObject, this);
}
private void Start()
{
if (!prefabInit)
{
InitializeParts();
}
}
public void OnDestroy()
{
if (!prefabInit)
{
s_allInstances.Remove(((Component)this).gameObject);
}
}
private void FixedUpdate()
{
//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
//IL_061a: Unknown result type (might be due to invalid IL or missing references)
//IL_064e: Unknown result type (might be due to invalid IL or missing references)
//IL_0682: Unknown result type (might be due to invalid IL or missing references)
if (prefabInit || m_zdo == null || !Object.op_Implicit((Object)(object)m_ship))
{
return;
}
RequestMissingShipMapData();
m_customMast = LongshipUpgrades.mastEnabled.Value && m_zdo.GetBool(s_mastUpgraded, false);
GameObject mastUpgrade = m_mastUpgrade;
if (mastUpgrade != null)
{
mastUpgrade.SetActive((LongshipUpgrades.mastEnabled.Value && !m_customMast) || LongshipUpgrades.mastRemovable.Value);
}
GameObject mast = m_mast;
if (mast != null)
{
mast.SetActive(!m_zdo.GetBool(s_mastRemoved, false));
}
GameObject ropes = m_ropes;
if (ropes != null)
{
ropes.SetActive(m_mast.activeSelf);
}
GameObject wisp = m_wisp;
if (wisp != null)
{
wisp.SetActive(LongshipUpgrades.wispEnabled.Value && m_mast.activeSelf && m_zdo.GetBool(s_wispUpgraded, false) && !m_zdo.GetBool(s_wispRemoved, false));
}
GameObject mapTable = m_mapTable;
if (mapTable != null)
{
mapTable.SetActive(LongshipUpgrades.mapTableEnabled.Value && m_zdo.GetBool(s_mapTableUpgraded, false));
}
GameObject beamTent = m_beamTent;
if (beamTent != null)
{
beamTent.SetActive(m_customMast && (LongshipUpgrades.lanternEnabled.Value || LongshipUpgrades.tentEnabled.Value));
}
GameObject beamMast = m_beamMast;
if (beamMast != null)
{
beamMast.SetActive(!m_mast.activeSelf && (Object)(object)m_beamTent != (Object)null && m_beamTent.activeInHierarchy);
}
GameObject beamSailCollider = m_beamSailCollider;
if (beamSailCollider != null)
{
beamSailCollider.SetActive((!Object.op_Implicit((Object)(object)m_beamMast) || !m_beamMast.activeSelf) && m_mast.activeSelf);
}
GameObject wispUpgrade = m_wispUpgrade;
if (wispUpgrade != null)
{
wispUpgrade.SetActive(LongshipUpgrades.wispEnabled.Value && m_mast.activeSelf);
}
GameObject mapTableUpgrade = m_mapTableUpgrade;
if (mapTableUpgrade != null)
{
mapTableUpgrade.SetActive(LongshipUpgrades.mapTableEnabled.Value && !m_mapTable.activeSelf);
}
GameObject tent = m_tent;
if (tent != null)
{
tent.SetActive(m_customMast && LongshipUpgrades.tentEnabled.Value && m_zdo.GetBool(s_tentUpgraded, false) && !m_zdo.GetBool(s_tentDisabled, false));
}
GameObject lantern = m_lantern;
if (lantern != null)
{
lantern.SetActive(LongshipUpgrades.lanternEnabled.Value && m_customMast && m_zdo.GetBool(s_lanternUpgraded, false) && !m_zdo.GetBool(s_lanternDisabled, false));
}
GameObject holdersRight = m_holdersRight;
if (holdersRight != null)
{
holdersRight.SetActive(IsTentActive());
}
GameObject holdersLeft = m_holdersLeft;
if (holdersLeft != null)
{
holdersLeft.SetActive(IsTentActive());
}
if (Object.op_Implicit((Object)(object)m_fireWarmth) && m_fireWarmth.m_isHeatType != (m_fireWarmth.m_isHeatType = LongshipUpgrades.tentHeat.Value && Object.op_Implicit((Object)(object)m_lantern) && m_lantern.activeInHierarchy && IsTentActive()))
{
m_fireWarmth.m_type = (Type)(m_fireWarmth.m_isHeatType ? 3 : 0);
if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
if (m_fireWarmth.m_isHeatType && !m_fireWarmth.m_collidedWithCharacter.Contains((Character)(object)Player.m_localPlayer))
{
m_fireWarmth.m_collidedWithCharacter.Add((Character)(object)Player.m_localPlayer);
}
else if (!m_fireWarmth.m_isHeatType && m_fireWarmth.m_collidedWithCharacter.Contains((Character)(object)Player.m_localPlayer))
{
m_fireWarmth.m_collidedWithCharacter.Remove((Character)(object)Player.m_localPlayer);
}
}
}
GameObject turretsUpgrade = m_turretsUpgrade;
if (turretsUpgrade != null)
{
turretsUpgrade.SetActive(LongshipUpgrades.turretsEnabled.Value);
}
GameObject turrets = m_turrets;
if (turrets != null)
{
turrets.SetActive(LongshipUpgrades.turretsEnabled.Value && m_zdo.GetBool(s_turretsUpgraded, false));
}
GameObject itemstandObject = m_itemstandObject;
if (itemstandObject != null)
{
itemstandObject.SetActive(LongshipUpgrades.itemStandEnabled.Value);
}
bool flag = false;
if ((Object)(object)m_light != (Object)null && Object.op_Implicit((Object)(object)m_lantern) && m_lantern.activeInHierarchy && (m_isLampLightDisabled != m_zdo.GetBool(s_lightsDisabled, false) || (flag = isTimeToLight != IsTimeToLight()) || isNightTime != IsNightTime()))
{
isNightTime = IsNightTime();
isTimeToLight = IsTimeToLight();
if (LongshipUpgrades.lanternAutoSwtich.Value && flag && m_nview.IsValid() && m_nview.IsOwner())
{
m_zdo.Set(s_lightsDisabled, !isTimeToLight);
}
m_isLampLightDisabled = m_zdo.GetBool(s_lightsDisabled, false);
UpdateLights();
}
if (Object.op_Implicit((Object)(object)m_beamMesh))
{
m_beamMesh.transform.localPosition = new Vector3(0f, 0f, IsTentActive() ? 0f : (-0.9f));
m_beamMesh.transform.localScale = new Vector3(1f, 1f, IsTentActive() ? 1f : 0.5f);
m_beamTentCollider.transform.localPosition = new Vector3(0f, 1.58f, IsTentActive() ? 0.23f : (-0.49f));
m_beamTentCollider.transform.localScale = new Vector3(0.16f, 0.16f, IsTentActive() ? 2.05f : 0.6f);
}
if (LongshipUpgrades.containerEnabled.Value && Object.op_Implicit((Object)(object)m_storageUpgrade) && m_containerUpgradedLvl2 != m_zdo.GetBool(s_containerUpgradedLvl2, false))
{
m_containerUpgradedLvl2 = m_zdo.GetBool(s_containerUpgradedLvl2, false);
GameObject[] containerPartsLvl = m_containerPartsLvl2;
if (containerPartsLvl != null)
{
CollectionExtensions.Do<GameObject>((IEnumerable<GameObject>)containerPartsLvl, (Action<GameObject>)delegate(GameObject part)
{
if (part != null)
{
part.SetActive(m_containerUpgradedLvl2);
}
});
}
if (m_containerUpgradedLvl2 && m_container.m_height < LongshipUpgrades.containerHeight.Value)
{
string name = ((object)m_container).GetType().Name;
m_zdo.Set("HasFields", true);
m_zdo.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name), true);
m_zdo.Set(name + ".m_height", LongshipUpgrades.containerHeight.Value);
m_container.m_height = LongshipUpgrades.containerHeight.Value;
}
if (m_containerUpgradedLvl2 && m_container.GetInventory().GetHeight() < LongshipUpgrades.containerHeight.Value)
{
string name2 = ((object)m_container.GetInventory()).GetType().Name;
m_zdo.Set("HasFields", true);
m_zdo.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name2), true);
m_zdo.Set(name2 + ".m_height", LongshipUpgrades.containerHeight.Value);
m_container.GetInventory().m_height = LongshipUpgrades.containerHeight.Value;
}
}
if (LongshipUpgrades.containerEnabled.Value && Object.op_Implicit((Object)(object)m_storageUpgrade) && m_containerUpgradedLvl1 != m_zdo.GetBool(s_containerUpgradedLvl1, false))
{
m_containerUpgradedLvl1 = m_zdo.GetBool(s_containerUpgradedLvl1, false);
GameObject[] containerPartsLvl2 = m_containerPartsLvl1;
if (containerPartsLvl2 != null)
{
CollectionExtensions.Do<GameObject>((IEnumerable<GameObject>)containerPartsLvl2, (Action<GameObject>)delegate(GameObject part)
{
if (part != null)
{
part.SetActive(m_containerUpgradedLvl1);
}
});
}
if (m_containerUpgradedLvl1 && m_container.m_width < LongshipUpgrades.containerWidth.Value)
{
m_container.m_width = LongshipUpgrades.containerWidth.Value;
string name3 = ((object)m_container).GetType().Name;
m_zdo.Set("HasFields", true);
m_zdo.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name3), true);
m_zdo.Set(name3 + ".m_width", LongshipUpgrades.containerWidth.Value);
}
if (m_containerUpgradedLvl1 && m_container.GetInventory().GetWidth() < LongshipUpgrades.containerWidth.Value)
{
m_container.GetInventory().m_width = LongshipUpgrades.containerWidth.Value;
string name4 = ((object)m_container.GetInventory()).GetType().Name;
m_zdo.Set("HasFields", true);
m_zdo.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name4), true);
m_zdo.Set(name4 + ".m_width", LongshipUpgrades.containerWidth.Value);
}
}
GameObject storageUpgrade = m_storageUpgrade;
if (storageUpgrade != null)
{
storageUpgrade.SetActive(LongshipUpgrades.containerEnabled.Value && !m_containerUpgradedLvl2);
}
bool flag2 = false;
if (LongshipUpgrades.healthEnabled.Value && m_protectiveParts != null && Object.op_Implicit((Object)(object)m_wnt) && m_healthUpgraded != m_zdo.GetBool(s_healthUpgraded, false))
{
m_healthUpgraded = m_zdo.GetBool(s_healthUpgraded, false);
CollectionExtensions.Do<GameObject>((IEnumerable<GameObject>)m_protectiveParts, (Action<GameObject>)delegate(GameObject part)
{
if (part != null)
{
part.SetActive(m_healthUpgraded);
}
});
if (m_healthUpgraded && m_wnt.m_health < (float)LongshipUpgrades.healthUpgradeLvl1.Value)
{
m_wnt.m_health = LongshipUpgrades.healthUpgradeLvl1.Value;
flag2 = true;
}
}
if (LongshipUpgrades.healthEnabled.Value && Object.op_Implicit((Object)(object)m_wnt))
{
if (m_ashlandsUpgraded != (m_ashlandsUpgraded = m_zdo.GetBool(s_ashlandsUpgraded, false)))
{
if (m_ashlandsUpgraded && LongshipUpgrades.healthUpgradeLvl2.Value > 0 && m_wnt.m_health < (float)LongshipUpgrades.healthUpgradeLvl2.Value)
{
m_wnt.m_health = LongshipUpgrades.healthUpgradeLvl2.Value;
flag2 = true;
}
string name5 = ((object)m_ship).GetType().Name;
m_zdo.Set("HasFields", true);
m_zdo.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name5), true);
m_zdo.Set(name5 + ".m_ashlandsReady", true);
name5 = ((object)m_wnt).GetType().Name;
m_zdo.Set(StringExtensionMethods.GetStableHashCode("HasFields" + name5), true);
m_zdo.Set(name5 + ".m_ashDamageResist", true);
m_zdo.Set(name5 + ".m_burnable", false);
UpdateHullPropertyBlocks();
}
if (m_ashlandsUpgraded && LongshipUpgrades.ashlandsProtection.Value)
{
m_ship.m_ashlandsReady = true;
m_ship.m_ashlandsDmgTimer = 0f;
if (m_ship.m_ashdamageEffects.activeSelf)
{
m_ship.m_ashdamageEffects.SetActive(false);
CollectionExtensions.Do<AudioSource>((IEnumerable<AudioSource>)m_ship.m_ashlandsFxAudio, (Action<AudioSource>)delegate(AudioSource item)
{
item.Stop();
});
}
if (!m_wnt.m_ashDamageResist)
{
m_wnt.m_ashDamageResist = true;
m_wnt.m_burnable = false;
((DamageModifiers)(ref m_wnt.m_damages)).Apply(s_fireResistantModifiers);
}
}
}
if (flag2 && m_nview.IsValid() && m_nview.IsOwner())
{
m_nview.InvokeRPC(ZNetView.Everybody, "RPC_HealthChanged", new object[1] { m_nview.GetZDO().GetFloat(ZDOVars.s_health, m_wnt.m_health) });
}
GameObject healthUpgrade = m_healthUpgrade;
if (healthUpgrade != null)
{
healthUpgrade.SetActive(LongshipUpgrades.healthEnabled.Value && !m_ashlandsUpgraded);
}
if (LongshipUpgrades.changeShields.Value && LongshipUpgrades.healthEnabled.Value && m_protectiveParts != null && m_healthUpgraded && m_shieldsStyle != m_zdo.GetInt(s_shieldsStyle, 0))
{
m_shieldsStyle = m_zdo.GetInt(s_shieldsStyle, 0);
if (LongshipUpgrades.maxShields.Value != 0 && m_shieldsStyle > LongshipUpgrades.maxShields.Value && m_nview.IsValid() && m_nview.IsOwner())
{
m_shieldsStyle %= LongshipUpgrades.maxShields.Value;
m_zdo.Set(s_shieldsStyle, m_shieldsStyle, false);
}
UpdateShieldsPropertyBlocks();
}
GameObject shieldsStyles = m_shieldsStyles;
if (shieldsStyles != null)
{
shieldsStyles.SetActive(m_healthUpgraded);
}
if (LongshipUpgrades.changeTent.Value && IsTentActive() && m_tentStyle != m_zdo.GetInt(s_tentStyle, 0))
{
m_tentStyle = m_zdo.GetInt(s_tentStyle, 0);
UpdateTentPropertyBlocks();
}
if (LongshipUpgrades.changeSail.Value && (Object)(object)m_sail != (Object)null && m_sail.activeInHierarchy && m_sailStyle != m_zdo.GetInt(s_sailStyle, 0))
{
m_sailStyle = m_zdo.GetInt(s_sailStyle, 0);
UpdateSailPropertyBlocks();
}
if (LongshipUpgrades.changeHead.Value && m_heads != null && Object.op_Implicit((Object)(object)m_wnt) && m_headStyle != m_zdo.GetInt(s_headStyle, 0))
{
m_headStyle = m_zdo.GetInt(s_headStyle, 0);
for (int i = 0; i < m_heads.Length; i++)
{
m_heads[i].SetActive(m_headStyle == i + 1);
}
GameObject[] array = (GameObject[])(object)new GameObject[3]
{
((Component)m_wnt.m_new.transform.Find("skull_head")).gameObject,
((Component)m_wnt.m_worn.transform.Find("skull_head")).gameObject,
((Component)m_wnt.m_broken.transform.Find("skull_head")).gameObject
};
foreach (GameObject val in array)
{
val.SetActive(m_headStyle == 0);
}
}
GameObject headStyles = m_headStyles;
if (headStyles != null)
{
headStyles.SetActive(LongshipUpgrades.changeHead.Value);
}
SetPropertyBlocks();
}
public void RPC_SetVariant(long uid, int zdoVar, int variant, int effectVariant, string position)
{
//IL_0037: 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)
if (m_nview.IsValid() && m_nview.IsOwner())
{
m_zdo.Set(zdoVar, variant, false);
partEffects.Create(ParseVector3(position), Quaternion.identity, (Transform)null, 1f, effectVariant);
}
}
public void RPC_SetActive(long uid, int zdoVar, bool active, int effectVariant, string position)
{
//IL_0036: 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)
if (m_nview.IsValid() && m_nview.IsOwner())
{
m_zdo.Set(zdoVar, active);
partEffects.Create(ParseVector3(position), Quaternion.identity, (Transform)null, 1f, effectVariant);
}
}
public void RPC_SetBuilt(long uid, int zdoVar, string stationName, string position)
{
//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)
if (!m_nview.IsValid() || !m_nview.IsOwner())
{
return;
}
m_zdo.Set(zdoVar, true);
if (!string.IsNullOrWhiteSpace(stationName))
{
EffectList obj = buildEffects[stationName];
if (obj != null)
{
obj.Create(ParseVector3(position), Quaternion.identity, (Transform)null, 1f, -1);
}
}
}
private void RequestMissingShipMapData()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (!m_zdo.GetBool(s_mapTableUpgraded, false) || !m_zdo.GetBool(s_mapDataCompressed, false))
{
return;
}
int @int = m_zdo.GetInt(s_shipMapDataRevision, 0);
if (@int > 0)
{
if (LongshipUpgrades.TryGetShipMapData(m_zdo.m_uid, out var entry) && entry.Data != null && entry.Revision >= @int)
{
m_lastRequestedShipMapRevision = 0;
}
else if (!(Time.time < m_nextShipMapDataRequestTime) || m_lastRequestedShipMapRevision != @int)
{
m_lastRequestedShipMapRevision = @int;
m_nextShipMapDataRequestTime = Time.time + 2f;
LongshipUpgrades.RequestShipMapDataFromServer(m_zdo, @int);
}
}
}
private void UpdateSailPropertyBlocks()
{
GameObject sail = m_sail;
Renderer val = ((sail != null) ? sail.GetComponentInChildren<Renderer>() : null);
if (!((Object)(object)val == (Object)null))
{
if (m_sailStyle == 0 || customSails.Count == 0)
{
ResetPropertyBlock(val);
}
else
{
SetPropertyBlock(val, ShaderProps._MainTex, customSails[(m_sailStyle - 1) % ((LongshipUpgrades.maxSails.Value == 0) ? customSails.Count : Math.Min(LongshipUpgrades.maxSails.Value, customSails.Count))]);
}
}
}
private void UpdateTentPropertyBlocks()
{
GameObject tent = m_tent;
Renderer val = ((tent != null) ? tent.GetComponentInChildren<Renderer>() : null);
if (!((Object)(object)val == (Object)null))
{
if (m_tentStyle == 0 || customTents.Count == 0)
{
ResetPropertyBlock(val);
}
else
{
SetPropertyBlock(val, ShaderProps._MainTex, customTents[(m_tentStyle - 1) % ((LongshipUpgrades.maxTents.Value == 0) ? customTents.Count : Math.Min(LongshipUpgrades.maxTents.Value, customTents.Count))]);
}
}
}
private void UpdateHullPropertyBlocks()
{
if (!m_ashlandsUpgraded || LongshipUpgrades.healthUpgradeLvl2.Value <= 0 || !LongshipUpgrades.ashlandsProtection.Value)
{
return;
}
foreach (Renderer item in new List<Renderer>
{
((Component)m_wnt.m_new.transform.Find("hull")).gameObject.GetComponent<Renderer>(),
((Component)m_wnt.m_new.transform.Find("skull_head")).gameObject.GetComponent<Renderer>()
})
{
SetPropertyBlock(item, ShaderProps._MainTex, s_ashlandsHull);
}
foreach (Renderer item2 in new List<Renderer>
{
((Component)m_wnt.m_worn.transform.Find("hull")).gameObject.GetComponent<Renderer>(),
((Component)m_wnt.m_broken.transform.Find("hull")).gameObject.GetComponent<Renderer>(),
((Component)m_wnt.m_worn.transform.Find("skull_head")).gameObject.GetComponent<Renderer>(),
((Component)m_wnt.m_broken.transform.Find("skull_head")).gameObject.GetComponent<Renderer>()
})
{
SetPropertyBlock(item2, ShaderProps._MainTex, s_ashlandsHullDamaged);
}
if (m_heads == null)
{
return;
}
foreach (Renderer item3 in m_heads.Select((GameObject head) => head.GetComponent<Renderer>()))
{
SetPropertyBlock(item3, ShaderProps._MainTex, s_ashlandsHull);
}
}
private void UpdateShieldsPropertyBlocks()
{
if (!LongshipUpgrades.changeShields.Value || !LongshipUpgrades.healthEnabled.Value || m_protectiveParts == null || !m_healthUpgraded)
{
return;
}
int style = ((m_shieldsStyle > 3) ? ((m_shieldsStyle - 1) % 3 + 1) : m_shieldsStyle);
int num = ((m_shieldsStyle > 3) ? ((m_shieldsStyle - 4) / 3) : (-1));
foreach (Renderer item in m_protectiveParts.Select((GameObject head) => head.GetComponent<Renderer>()))
{
ResetPropertyBlock(item);
SetPropertyBlock(item, ShaderProps._Style, style);
if (-1 < num && num < customShields.Count)
{
SetPropertyBlock(item, LongshipPropertyBlocks._StyleTex, customShields[num]);
}
}
}
private void UpdatePropertyBlocks()
{
CollectionExtensions.Do<Renderer>((IEnumerable<Renderer>)s_propertyBlocks.Keys, (Action<Renderer>)delegate(Renderer renderer)
{
renderer.SetPropertyBlock((MaterialPropertyBlock)null);
});
s_propertyBlocks.Clear();
UpdateHullPropertyBlocks();
UpdateShieldsPropertyBlocks();
UpdateTentPropertyBlocks();
UpdateSailPropertyBlocks();
SetPropertyBlocks();
}
private void UpdateLights()
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: 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_0104: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
GameObject insects = m_insects;
if (insects != null)
{
insects.SetActive(isNightTime && !m_isLampLightDisabled);
}
if (Object.op_Implicit((Object)(object)m_light))
{
((Component)m_light).gameObject.SetActive(!m_isLampLightDisabled);
m_light.color = LongshipUpgrades.lanternLightColor.Value;
}
Color value = LongshipUpgrades.lanternLightColor.Value;
value.a = 0f;
if (Object.op_Implicit((Object)(object)m_flare))
{
((Component)m_flare).gameObject.SetActive(!m_isLampLightDisabled);
MainModule main = m_flare.main;
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.Lerp(flareColor, value, 0.5f));
}
if (Object.op_Implicit((Object)(object)m_lampRenderer))
{
SetPropertyBlock((Renderer)(object)m_lampRenderer, ShaderProps._EmissionColor, m_isLampLightDisabled ? Color.grey : (Color.white + value));
}
}
private void SetPropertyBlock(Renderer renderer, int nameID, Texture2D tex)
{
if (!((Object)(object)renderer == (Object)null))
{
GetPropertyBlock(renderer).SetTexture(nameID, (Texture)(object)tex);
}
}
private void SetPropertyBlock(Renderer renderer, int nameID, int style)
{
if (!((Object)(object)renderer == (Object)null))
{
GetPropertyBlock(renderer).SetInt(nameID, style);
}
}
private void SetPropertyBlock(Renderer renderer, int nameID, Color color)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)renderer == (Object)null))
{
GetPropertyBlock(renderer).SetColor(nameID, color);
}
}
private void ResetPropertyBlock(Renderer renderer)
{
if (s_propertyBlocks.ContainsKey(renderer))
{
renderer.SetPropertyBlock((MaterialPropertyBlock)null);
s_propertyBlocks.Remove(renderer);
blocksIsDirty = true;
}
}
private MaterialPropertyBlock GetPropertyBlock(Renderer renderer)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
blocksIsDirty = true;
if (!s_propertyBlocks.TryGetValue(renderer, out var value))
{
value = new MaterialPropertyBlock();
s_propertyBlocks[renderer] = value;
}
return value;
}
private void CombinePropertyBlocks(MaterialPropertyBlock propertyBlockToCombine)
{
//IL_003a: 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)
foreach (MaterialPropertyBlock value in s_propertyBlocks.Values)
{
if (propertyBlockToCombine.HasColor(ShaderProps._Color))
{
value.SetColor(ShaderProps._Color, propertyBlockToCombine.GetColor(ShaderProps._Color));
blocksIsDirty = true;
}
if (propertyBlockToCombine.HasColor(ShaderProps._EmissionColor))
{
value.SetColor(ShaderProps._EmissionColor, propertyBlockToCombine.GetColor(ShaderProps._EmissionColor));
blocksIsDirty = true;
}
}
SetPropertyBlocks();
}
private void SetPropertyBlocks()
{
if (blocksIsDirty)
{
CollectionExtensions.Do<KeyValuePair<Renderer, MaterialPropertyBlock>>((IEnumerable<KeyValuePair<Renderer, MaterialPropertyBlock>>)s_propertyBlocks, (Action<KeyValuePair<Renderer, MaterialPropertyBlock>>)delegate(KeyValuePair<Renderer, MaterialPropertyBlock> rendererBlock)
{
rendererBlock.Key.SetPropertyBlock(rendererBlock.Value.isEmpty ? null : rendererBlock.Value);
});
}
blocksIsDirty = false;
}
private void InitializeParts()
{
//IL_0596: Unknown result type (might be due to invalid IL or missing references)
//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
//IL_05af: Unknown result type (might be due to invalid IL or missing references)
//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0602: Unknown result type (might be due to invalid IL or missing references)
//IL_0607: Unknown result type (might be due to invalid IL or missing references)
//IL_066e: Unknown result type (might be due to invalid IL or missing references)
//IL_068a: Unknown result type (might be due to invalid IL or missing references)
//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
//IL_070c: Unknown result type (might be due to invalid IL or missing references)
//IL_0728: Unknown result type (might be due to invalid IL or missing references)
//IL_075b: Unknown result type (might be due to invalid IL or missing references)
//IL_0777: Unknown result type (might be due to invalid IL or missing references)
//IL_09ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
//IL_0a2f: Unknown result type (might be due to invalid IL or missing references)
//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
//IL_0a7f: Unknown result type (might be due to invalid IL or missing references)
//IL_0a9b: Unknown result type (might be due to invalid IL or missing references)
//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
//IL_0aeb: Unknown result type (might be due to invalid IL or missing references)
//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
//IL_0b23: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_0fd8: Unknown result type (might be due to invalid IL or missing references)
//IL_0fdf: Expected O, but got Unknown
//IL_0c22: Unknown result type (might be due to invalid IL or missing references)
//IL_0c27: Unknown result type (might be due to invalid IL or missing references)
//IL_0c35: Expected O, but got Unknown
//IL_0c4e: Unknown result type (might be due to invalid IL or missing references)
//IL_0c58: Unknown result type (might be due to invalid IL or missing references)
//IL_0c94: Unknown result type (might be due to invalid IL or missing references)
//IL_0cc6: Unknown result type (might be due to invalid IL or missing references)
//IL_0ce8: Unknown result type (might be due to invalid IL or missing references)
//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: 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_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0d67: Unknown result type (might be due to invalid IL or missing references)
//IL_0dad: Unknown result type (might be due to invalid IL or missing references)
//IL_0dc9: Unknown result type (might be due to invalid IL or missing references)
//IL_0de5: Unknown result type (might be due to invalid IL or missing references)
//IL_0d03: Unknown result type (might be due to invalid IL or missing references)
//IL_0d08: Unknown result type (might be due to invalid IL or missing references)
//IL_0d0c: Unknown result type (might be due to invalid IL or missing references)
//IL_0d11: Unknown result type (might be due to invalid IL or missing references)
//IL_0d15: Unknown result type (might be due to invalid IL or missing references)
//IL_0d1a: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0eda: Unknown result type (might be due to invalid IL or missing references)
//IL_0eec: Unknown result type (might be due to invalid IL or missing references)
//IL_0ef6: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
//IL_103e: Unknown result type (might be due to invalid IL or missing references)
//IL_105a: Unknown result type (might be due to invalid IL or missing references)
//IL_0e84: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0512: Unknown result type (might be due to invalid IL or missing references)
//IL_0517: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_045c: Unknown result type (might be due to invalid IL or missing references)
//IL_0484: Unknown result type (might be due to invalid IL or missing references)
//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_1190: Unknown result type (might be due to invalid IL or missing references)
//IL_11ac: Unknown result type (might be due to invalid IL or missing references)
//IL_11c8: Unknown result type (might be due to invalid IL or missing references)
//IL_11ed: Unknown result type (might be due to invalid IL or missing references)
//IL_11fc: Unknown result type (might be due to invalid IL or missing references)
//IL_1312: Unknown result type (might be due to invalid IL or missing references)
//IL_131c: Expected O, but got Unknown
//IL_1409: Unknown result type (might be due to invalid IL or missing references)
//IL_1413: Expected O, but got Unknown
//IL_1454: Unknown result type (might be due to invalid IL or missing references)
//IL_1470: Unknown result type (might be due to invalid IL or missing references)
//IL_148c: Unknown result type (might be due to invalid IL or missing references)
//IL_14c0: Unknown result type (might be due to invalid IL or missing references)
//IL_14dc: Unknown result type (might be due to invalid IL or missing references)
//IL_14f8: Unknown result type (might be due to invalid IL or missing references)
//IL_152c: Unknown result type (might be due to invalid IL or missing references)
//IL_1548: Unknown result type (might be due to invalid IL or missing references)
//IL_1564: Unknown result type (might be due to invalid IL or missing references)
//IL_1598: Unknown result type (might be due to invalid IL or missing references)
//IL_15b4: Unknown result type (might be due to invalid IL or missing references)
//IL_15d0: Unknown result type (might be due to invalid IL or missing references)
//IL_1604: Unknown result type (might be due to invalid IL or missing references)
//IL_1620: Unknown result type (might be due to invalid IL or missing references)
//IL_163c: Unknown result type (might be due to invalid IL or missing references)
//IL_1670: Unknown result type (might be due to invalid IL or missing references)
//IL_168c: Unknown result type (might be due to invalid IL or missing references)
//IL_16a8: Unknown result type (might be due to invalid IL or missing references)
//IL_1770: Unknown result type (might be due to invalid IL or missing references)
//IL_1777: Expected O, but got Unknown
//IL_18dd: Unknown result type (might be due to invalid IL or missing references)
//IL_18f9: Unknown result type (might be due to invalid IL or missing references)
//IL_1915: Unknown result type (might be due to invalid IL or missing references)
//IL_19f4: Unknown result type (might be due to invalid IL or missing references)
//IL_19f9: Unknown result type (might be due to invalid IL or missing references)
//IL_1a07: Expected O, but got Unknown
//IL_1a47: Unknown result type (might be due to invalid IL or missing references)
//IL_1a63: Unknown result type (might be due to invalid IL or missing references)
//IL_1b97: Unknown result type (might be due to invalid IL or missing references)
//IL_1ba1: Unknown result type (might be due to invalid IL or missing references)
//IL_1bc2: Unknown result type (might be due to invalid IL or missing references)
//IL_1be3: Unknown result type (might be due to invalid IL or missing references)
//IL_1c08: Unknown result type (might be due to invalid IL or missing references)
//IL_1c24: Unknown result type (might be due to invalid IL or missing references)
//IL_1c5e: Unknown result type (might be due to invalid IL or missing references)
//IL_1c7f: Unknown result type (might be due to invalid IL or missing references)
//IL_187d: Unknown result type (might be due to invalid IL or missing references)
//IL_1d8f: Unknown result type (might be due to invalid IL or missing references)
//IL_1d94: Unknown result type (might be due to invalid IL or missing references)
//IL_1da2: Expected O, but got Unknown
//IL_1e48: Unknown result type (might be due to invalid IL or missing references)
//IL_1e52: Unknown result type (might be due to invalid IL or missing references)
//IL_1ed4: Unknown result type (might be due to invalid IL or missing references)
//IL_1ee1: Unknown result type (might be due to invalid IL or missing references)
//IL_1eeb: Unknown result type (might be due to invalid IL or missing references)
//IL_1f29: Unknown result type (might be due to invalid IL or missing references)
//IL_1f4a: Unknown result type (might be due to invalid IL or missing references)
//IL_1f54: Unknown result type (might be due to invalid IL or missing references)
//IL_1f75: Unknown result type (might be due to invalid IL or missing references)
//IL_1f96: Unknown result type (might be due to invalid IL or missing references)
//IL_1fb7: Unknown result type (might be due to invalid IL or missing references)
//IL_1e9b: Unknown result type (might be due to invalid IL or missing references)
//IL_1ea0: Unknown result type (might be due to invalid IL or missing references)
//IL_1eb1: Expected O, but got Unknown
//IL_2120: Unknown result type (might be due to invalid IL or missing references)
//IL_212a: Unknown result type (might be due to invalid IL or missing references)
//IL_214f: Unknown result type (might be due to invalid IL or missing references)
//IL_21b6: Unknown result type (might be due to invalid IL or missing references)
//IL_21db: Unknown result type (might be due to invalid IL or missing references)
//IL_21e0: Unknown result type (might be due to invalid IL or missing references)
//IL_2359: Unknown result type (might be due to invalid IL or missing references)
//IL_2363: Unknown result type (might be due to invalid IL or missing references)
//IL_2388: Unknown result type (might be due to invalid IL or missing references)
//IL_23ad: Unknown result type (might be due to invalid IL or missing references)
//IL_2429: Unknown result type (might be due to invalid IL or missing references)
//IL_2433: Expected O, but got Unknown
//IL_2433: Unknown result type (might be due to invalid IL or missing references)
//IL_243d: Expected O, but got Unknown
//IL_2458: Unknown result type (might be due to invalid IL or missing references)
//IL_2462: Expected O, but got Unknown
//IL_2462: Unknown result type (might be due to invalid IL or missing references)
//IL_246c: Expected O, but got Unknown
//IL_24a4: Unknown result type (might be due to invalid IL or missing references)
//IL_24ae: Expected O, but got Unknown
//IL_24ae: Unknown result type (might be due to invalid IL or missing references)
//IL_24b8: Expected O, but got Unknown
//IL_24d3: Unknown result type (might be due to invalid IL or missing references)
//IL_24dd: Expected O, but got Unknown
//IL_24dd: Unknown result type (might be due to invalid IL or missing references)
//IL_24e7: Expected O, but got Unknown
//IL_2228: Unknown result type (might be due to invalid IL or missing references)
//IL_2244: Unknown result type (might be due to invalid IL or missing references)
//IL_2520: Unknown result type (might be due to invalid IL or missing references)
//IL_253c: Unknown result type (might be due to invalid IL or missing references)
//IL_2554: Unknown result type (might be due to invalid IL or missing references)
Transform obj = ((Component)this).transform.Find("ship/visual/Mast");
m_mast = ((obj != null) ? ((Component)obj).gameObject : null);
Transform obj2 = ((Component)this).transform.Find("ship/visual/ropes");
m_ropes = ((obj2 != null) ? ((Component)obj2).gameObject : null);
Transform obj3 = ((Component)this).transform.Find("ship/visual/Mast/Sail/sail_full");
m_sail = ((obj3 != null) ? ((Component)obj3).gameObject : null);
Transform val = ((Component)this).transform.Find("ship/visual/Customize");
if (!Object.op_Implicit((Object)(object)val))
{
return;
}
((Component)val).gameObject.SetActive(true);
Transform obj4 = val.Find("ShipTentHolders");
m_holdersRight = ((obj4 != null) ? ((Component)obj4).gameObject : null);
Transform obj5 = val.Find("ShipTentHolders (1)");
m_holdersLeft = ((obj5 != null) ? ((Component)obj5).gameObject : null);
GameObject holdersRight = m_holdersRight;
if (holdersRight != null)
{
holdersRight.SetActive(false);
}
GameObject holdersLeft = m_holdersLeft;
if (holdersLeft != null)
{
holdersLeft.SetActive(false);
}
Transform val2 = val.Find("storage");
if (Object.op_Implicit((Object)(object)val2))
{
List<GameObject> list = new List<GameObject>();
List<GameObject> list2 = new List<GameObject>();
List<GameObject> list3 = new List<GameObject>();
for (int j = 0; j < val2.childCount; j++)
{
GameObject gameObject = ((Component)val2.GetChild(j)).gameObject;
if (((Object)gameObject).name.StartsWith("barrel"))
{
list.Add(gameObject);
}
else if (((Object)gameObject).name.StartsWith("Shield"))
{
list3.Add(gameObject);
}
else
{
list2.Add(gameObject);
}
gameObject.SetActive(false);
}
m_containerPartsLvl1 = list.ToArray();
m_containerPartsLvl2 = list2.ToArray();
m_protectiveParts = list3.ToArray();
State state = Random.state;
Random.InitState((int)((ZDOID)(ref m_zdo.m_uid)).ID);
for (int k = 0; k < list.Count; k++)
{
Transform transform = list[k].transform;
transform.localEulerAngles += new Vector3(0f, Random.Range(0f, 360f), 0f);
switch (k)
{
case 0:
list[k].transform.localPosition = new Vector3(-0.69f, 0.18f, -0.88f);
break;
case 1:
list[k].transform.localPosition = new Vector3(-0.36f, 0.18f, -0.87f);
break;
}
BoxCollider componentInChildren = list[k].GetComponentInChildren<BoxCollider>();
GameObject gameObject2 = ((Component)componentInChildren).gameObject;
Object.Destroy((Object)(object)componentInChildren);
gameObject2.AddComponent<CapsuleCollider>();
}
for (int l = 0; l < list2.Count; l++)
{
switch (l)
{
case 0:
case 5:
{
Transform transform2 = new GameObject("ladder_TargetPoint").transform;
transform2.SetParent(list2[l].transform, false);
transform2.localPosition = new Vector3(0.4f, 0.82f, 0f);
transform2.localEulerAngles = new Vector3(0f, 270f, 0f);
Ladder val3 = list2[l].AddComponent<Ladder>();
val3.m_useDistance = 1.5f;
val3.m_targetPos = transform2;
val3.m_name = "$lu_box_name";
continue;
}
case 1:
list2[l].transform.localPosition = new Vector3(0.08f, 0f, -0.45f);
break;
case 3:
list2[l].transform.localPosition = new Vector3(0f, 0f, -0.84f);
list2[l].transform.localScale = new Vector3(0.35f, 0.4f, 0.35f);
break;
case 4:
list2[l].transform.localPosition = new Vector3(0.36f, -0.02f, -0.82f);
list2[l].transform.localScale = new Vector3(0.35f, 0.4f, 0.35f);
break;
case 6:
list2[l].transform.localPosition = new Vector3(0f, 0.26f, -0.57f);
break;
case 8:
list2[l].transform.localScale = new Vector3(0.35f, 0.4f, 0.35f);
break;
}
Transform transform3 = list2[l].transform;
transform3.localEulerAngles += new Vector3(0f, Random.Range(0f, 360f), 0f);
}
Random.state = state;
}
Transform val4 = val.Find("ShipTen2_beam");
if (Object.op_Implicit((Object)(object)val4))
{
m_beamMast = Object.Instantiate<GameObject>(((Component)val4).gameObject, val4.parent);
((Object)m_beamMast).name = "ShipTen2_mast";
Transform transform4 = m_beamMast.transform;
transform4.localEulerAngles += new Vector3(90f, 0.1f, 0f);
m_beamMast.transform.localPosition = new Vector3(0.58f, 0.35f, 0f);
m_beamMast.SetActive(false);
val4.localPosition += new Vector3(0.1f, 0f, 0f);
m_beamTent = ((Component)val4).gameObject;
m_beamTent.SetActive(false);
m_beamMesh = ((Component)((Component)val4).GetComponentInChildren<Renderer>()).gameObject;
Transform val5 = AddCollider(m_beamMast.transform, "mast_beam", typeof(BoxCollider));
val5.localPosition = new Vector3(0f, 1.58f, -0.48f);
val5.localScale = new Vector3(0.16f, 0.16f, 2.5f);
Transform val6 = AddCollider(val4, "lantern_beam", typeof(BoxCollider));
val6.localPosition = new Vector3(0f, 1.58f, -1.41f);
val6.localScale = new Vector3(0.16f, 0.16f, 0.8f);
Transform val7 = AddCollider(val4, "tent_beam", typeof(BoxCollider));
val7.localPosition = new Vector3(0f, 1.58f, 0.23f);
val7.localScale = new Vector3(0.16f, 0.16f, 2.05f);
Transform val8 = AddCollider(val4, "sail_beam", typeof(BoxCollider));
val8.localPosition = new Vector3(0f, 1.4f, -0.9f);
val8.localScale = new Vector3(0.23f, 0.55f, 0.2f);
m_beamTentCollider = ((Component)val7).gameObject;
m_beamSailCollider = ((Component)val8).gameObject;
if (LongshipUpgrades.lanternEnabled.Value)
{
LongshipPartController longshipPartController = ((Component)val6).gameObject.AddComponent<LongshipPartController>();
longshipPartController.m_name = "$lu_part_lantern_name";
longshipPartController.m_zdoPartDisabled = (LongshipUpgrades.lanternRemovable.Value ? s_lanternDisabled : 0);
longshipPartController.m_messageEnable = "$lu_part_lantern_enable";
longshipPartController.m_enableEffects = 1;
longshipPartController.m_messageDisable = "$lu_part_lantern_disable";
longshipPartController.m_disableEffects = 1;
longshipPartController.m_nview = m_nview;
longshipPartController.m_useDistance = 3f;
longshipPartController.AddUpgradeRequirement(s_lanternUpgraded, "$lu_part_lantern_upgrade", LongshipUpgrades.ParseRequirements(LongshipUpgrades.lanternUpgradeRecipe.Value), LongshipUpgrades.lanternStation.Value, LongshipUpgrades.lanternStationLvl.Value, LongshipUpgrades.lanternStationRange.Value);
}
if (LongshipUpgrades.tentEnabled.Value)
{
LongshipPartController longshipPartController2 = ((Component)val7).gameObject.AddComponent<LongshipPartController>();
longshipPartController2.m_name = "$lu_part_tent_name";
longshipPartController2.m_zdoPartDisabled = (LongshipUpgrades.tentRemovable.Value ? s_tentDisabled : 0);
longshipPartController2.m_messageEnable = "$lu_part_tent_enable";
longshipPartController2.m_enableEffects = 0;
longshipPartController2.m_messageDisable = "$lu_part_tent_disable";
longshipPartController2.m_disableEffects = 0;
longshipPartController2.m_nview = m_nview;
longshipPartController2.m_useDistance = 3f;
longshipPartController2.AddUpgradeRequirement(s_tentUpgraded, "$lu_part_tent_upgrade", LongshipUpgrades.ParseRequirements(LongshipUpgrades.tentUpgradeRecipe.Value), LongshipUpgrades.tentStation.Value, LongshipUpgrades.tentStationLvl.Value, LongshipUpgrades.tentStationRange.Value);
}
if (LongshipUpgrades.changeSail.Value)
{
LongshipPartController longshipPartController3 = ((Component)val8).gameObject.AddComponent<LongshipPartController>();
longshipPartController3.m_name = "$lu_part_sail_name";
longshipPartController3.m_nview = m_nview;
longshipPartController3.m_messageSwitch = "$lu_part_sail_switch";
longshipPartController3.m_zdoPartVariant = s_sailStyle;
longshipPartController3.m_variants = customSails.Count + 1;
longshipPartController3.m_switchEffects = 0;
}
}
Transform val9 = val.Find("ShipTen2 (1)");
if (Object.op_Implicit((Object)(object)val9))
{
m_tent = ((Component)val9).gameObject;
Transform transform5 = new GameObject("colliders").transform;
transform5.SetParent(m_tent.transform, false);
Transform val10 = AddCollider(transform5, "collider_right", typeof(BoxCollider));
val10.localPosition = new Vector3(1.58f, 1.18f, -0.65f);
val10.localScale = new Vector3(1.9f, 0.01f, 2.6f);
val10.localEulerAngles = new Vector3(0f, 0f, -6f);
Transform val11 = AddCollider(transform5, "collider_left", typeof(BoxCollider));
val11.localPosition = new Vector3(-1.05f, 0.95f, -0.65f);
val11.localScale = new Vector3(1f, 0.01f, 2.5f);
val11.localEulerAngles = new Vector3(0f, 0f, 23f);
Transform val12 = AddCollider(transform5, "collider_left (1)", typeof(BoxCollider));
val12.localPosition = new Vector3(-2.1f, 0.7f, -0.55f);
val12.localScale = new Vector3(1.15f, 0.01f, 3f);
val12.localEulerAngles = new Vector3(0f, 0f, 6f);
m_tent.SetActive(false);
if (LongshipUpgrades.changeTent.Value)
{
for (int m = 0; m < transform5.childCount; m++)
{
LongshipPartController longshipPartController4 = ((Component)transform5.GetChild(m)).gameObject.AddComponent<LongshipPartController>();
longshipPartController4.m_name = "$lu_part_tent_name";
longshipPartController4.m_nview = m_nview;
longshipPartController4.m_messageSwitch = "$lu_part_tent_switch";
longshipPartController4.m_zdoPartVariant = s_tentStyle;
longshipPartController4.m_variants = customTents.Count + 1;
longshipPartController4.m_switchEffects = 0;
}
}
}
if (s_lanternPrefab == null)
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Lantern");
object obj6;
if (itemPrefab == null)
{
obj6 = null;
}
else
{
Transform obj7 = itemPrefab.transform.Find("attach/equiped");
obj6 = ((obj7 != null) ? ((Component)obj7).gameObject : null);
}
s_lanternPrefab = (GameObject)obj6;
}
if (Object.op_Implicit((Object)(object)s_lanternPrefab))
{
m_lantern = new GameObject("Lantern")
{
layer = 28
};
Transform transform6 = m_lantern.transform;
transform6.SetParent(val, false);
transform6.localScale = Vector3.one * 0.45f;
Transform transform7 = Object.Instantiate<GameObject>(s_lanternPrefab, transform6).transform;
((Object)transform7).name = "Lamp";
transform7.localPosition = new Vector3(0.23f, 1.9f, 0f);
((Component)transform7).gameObject.layer = 28;
m_light = ((Component)transform7).GetComponentInChildren<Light>();
m_light.color = LongshipUpgrades.lanternLightColor.Value;
m_flare = ((Component)transform7.Find("flare")).GetComponent<ParticleSystem>();
if (flareColor == Color.clear)
{
MainModule main = m_flare.main;
MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
flareColor = ((MinMaxGradient)(ref startColor)).color;
}
m_lampRenderer = ((Component)transform7.Find("default")).GetComponent<MeshRenderer>();
ConfigurableJoint component = ((Component)transform7).GetComponent<ConfigurableJoint>();
((Joint)component).autoConfigureConnectedAnchor = false;
((Joint)component).connectedBody = ((Component)this).GetComponent<Rigidbody>();
((Joint)component).connectedAnchor = new Vector3(0f, 3.01f, -0.45f);
((Component)transform7).GetComponent<CapsuleCollider>().height = 0.44f;
Transform val13 = AddCollider(transform6, "collider", typeof(BoxCollider));
val13.localPosition = new Vector3(0.2f, 2f, 0f);
val13.localScale = new Vector3(0.02f, 0.02f, 0.5f);
val13.localEulerAngles = new Vector3(90f, 0f, 0f);
Transform val14 = val.Find("TraderLamp");
if (Object.op_Implicit((Object)(object)val14))
{
((Component)val14).gameObject.SetActive(false);
Transform val15 = val14.Find("insects");
if (Object.op_Implicit((Object)(object)val15))
{
m_insects = Object.Instantiate<GameObject>(((Component)val15).gameObject, transform6);
((Object)m_insects).name = "insects";
m_insects.SetActive(false);
m_insects.transform.localPosition = new Vector3(0.42f, 1.85f, 0f);
m_insects.layer = 8;
}
}
GameObject gameObject3 = ((Component)AddCollider(val, "FireWarmth", typeof(SphereCollider))).gameObject;
gameObject3.layer = 14;
gameObject3.transform.localPosition = new Vector3(-1f, 0f, 0f);
gameObject3.transform.localScale = Vector3.one * 0.45f;
SphereCollider component2 = gameObject3.GetComponent<SphereCollider>();
component2.radius = 3f;
((Collider)component2).isTrigger = true;
m_fireWarmth = gameObject3.gameObject.AddComponent<EffectArea>();
m_fireWarmth.m_playerOnly = true;
if (LongshipUpgrades.lanternSwitchable.Value)
{
LongshipPartController longshipPartController5 = ((Component)transform6).gameObject.AddComponent<LongshipPartController>();
longshipPartController5.m_name = "$lu_part_lamp_name";
longshipPartController5.m_zdoPartDisabled = s_lightsDisabled;
longshipPartController5.m_messageEnable = "$lu_part_lamp_enable";
longshipPartController5.m_messageDisable = "$lu_part_lamp_disable";
longshipPartController5.m_enableEffects = 2;
longshipPartController5.m_disableEffects = 3;
longshipPartController5.m_nview = m_nview;
longshipPartController5.m_useDistance = 2f;
}
((Component)transform7).gameObject.SetActive(true);
m_lantern.SetActive(false);
}
GameObject val16 = new GameObject("interactive");
Transform transform8 = val16.transform;
transform8.SetParent(val, false);
if (LongshipUpgrades.mastEnabled.Value || LongshipUpgrades.mastRemovable.Value)
{
Transform val17 = AddCollider(transform8, "mast_controller", typeof(BoxCollider));
val17.localPosition = new Vector3(-0.05f, 0.08f, 0f);
val17.localScale = new Vector3(0.6f, 0.17f, 0.26f);
m_mastUpgrade = ((Component)val17).gameObject;
m_mastUpgrade.layer = 16;
m_mastUpgrade.SetActive(true);
LongshipPartController longshipPartController6 = ((Component)val17).gameObject.AddComponent<LongshipPartController>();
longshipPartController6.m_name = "$lu_part_mast_name";
longshipPartController6.m_zdoPartDisabled = (LongshipUpgrades.mastRemovable.Value ? s_mastRemoved : 0);
longshipPartController6.m_messageEnable = "$lu_part_mast_enable";
longshipPartController6.m_messageDisable = "$lu_part_mast_disable";
longshipPartController6.m_enableEffects = 1;
longshipPartController6.m_disableEffects = 1;
longshipPartController6.m_nview = m_nview;
longshipPartController6.m_useDistance = 2.5f;
longshipPartController6.AddUpgradeRequirement(LongshipUpgrades.mastEnabled.Value ? s_mastUpgraded : 0, "$lu_part_mast_upgrade", LongshipUpgrades.ParseRequirements(LongshipUpgrades.mastUpgradeRecipe.Value), LongshipUpgrades.mastStation.Value, LongshipUpgrades.mastStationLvl.Value, LongshipUpgrades.mastStationRange.Value);
}
if (Object.op_Implicit((Object)(object)m_container))
{
Transform val18 = AddCollider(transform8, "storage_controller", typeof(BoxCollider));
val18.localPosition = new Vector3(-1.9f, -0.02f, 0f);
val18.localScale = new Vector3(0.45f, 0.45f, 0.18f);
val18.localEulerAngles = new Vector3(0f, 270f, 0f);
BoxCollider component3 = ((Component)m_container).GetComponent<BoxCollider>();
BoxCollider component4 = ((Component)val18).GetComponent<BoxCollider>();
component4.center = component3.center;
component4.size = component3.size;
LongshipPartController longshipPartController7 = ((Component)val18).gameObject.AddComponent<LongshipPartController>();
longshipPartController7.m_name = (m_container.m_name.StartsWith("$") ? m_container.m_name : "$msg_cart_storage");
longshipPartController7.m_nview = m_nview;
longshipPartController7.AddUpgradeRequirement(s_containerUpgradedLvl1, "$lu_part_container_upgrade1", LongshipUpgrades.ParseRequirements(LongshipUpgrades.containerLvl1UpgradeRecipe.Value), LongshipUpgrades.containerLvl1Station.Value, LongshipUpgrades.containerLvl1StationLvl.Value, LongshipUpgrades.containerLvl1StationRange.Value);
longshipPartController7.AddUpgradeRequirement(s_containerUpgradedLvl2, "$lu_part_container_upgrade2", LongshipUpgrades.ParseRequirements(LongshipUpgrades.containerLvl2UpgradeRecipe.Value), LongshipUpgrades.containerLvl2Station.Value, LongshipUpgrades.containerLvl2StationLvl.Value, LongshipUpgrades.containerLvl2StationRange.Value);
m_storageUpgrade = ((Component)val18).gameObject;
m_storageUpgrade.layer = 16;
m_storageUpgrade.SetActive(false);
}
Transform healthParent;
if (m_protectiveParts != null)
{
m_healthUpgrade = new GameObject("health");
healthParent = m_healthUpgrade.transform;
healthParent.SetParent(transform8, false);
Transform val19 = ((Component)this).transform.Find("ship/colliders/left_side");
if (Object.op_Implicit((Object)(object)val19))
{
for (int n = 1; n < Mathf.Min(val19.childCount, 5); n++)
{
AddHealthController(val19, n, "health_controller_left", 0.01f);
}
}
Transform val20 = ((Component)this).transform.Find("ship/colliders/left_side (1)");
if (Object.op_Implicit((Object)(object)val20))
{
for (int num = 1; num < Mathf.Min(val20.childCount, 5); num++)
{
AddHealthController(val20, num, "health_controller_right", -0.01f);
}
}
}
if (m_protectiveParts != null)
{
m_shieldsStyles = new GameObject("shields");
Transform transform9 = m_shieldsStyles.transform;
transform9.SetParent(transform8, false);
Transform val21 = AddCollider(transform9, "shield_controller_right", typeof(BoxCollider));
val21.localPosition = new Vector3(-1.16f, 0.2f, 1.11f);
val21.localScale = new Vector3(0.95f, 0.45f, 0.05f);
val21.localEulerAngles = new Vector3(3f, 355f, 0f);
Transform val22 = AddCollider(transform9, "shield_controller_right (1)", typeof(BoxCollider));
val22.localPosition = new Vector3(-0.23f, 0.2f, 1.16f);
val22.localScale = new Vector3(0.91f, 0.43f, 0.05f);
val22.localEulerAngles = new Vector3(3f, 0f, 0f);
Transform val23 = AddCollider(transform9, "shield_controller_right (2)", typeof(BoxCollider));
val23.localPosition = new Vector3(1.35f, 0.16f, 1.05f);
val23.localScale = new Vector3(1.5f, 0.45f, 0.05f);
val23.localEulerAngles = new Vector3(3f, 8f, 0f);
Transform val24 = AddCollider(transform9, "shield_controller_left", typeof(BoxCollider));
val24.localPosition = new Vector3(-1.18f, 0.27f, -1.11f);
val24.localScale = new Vector3(0.95f, 0.45f, 0.05f);
val24.localEulerAngles = new Vector3(0f, 4f, 0f);
Transform val25 = AddCollider(transform9, "shield_controller_left (1)", typeof(BoxCollider));
val25.localPosition = new Vector3(-0.25f, 0.27f, -1.16f);
val25.localScale = new Vector3(0.89f, 0.45f, 0.05f);
val25.localEulerAngles = new Vector3(0f, 2f, 0f);
Transform val26 = AddCollider(transform9, "shield_controller_left (2)", typeof(BoxCollider));
val26.localPosition = new Vector3(1.33f, 0.23f, -1.1f);
val26.localScale = new Vector3(1.37f, 0.45f, 0.05f);
val26.localEulerAngles = new Vector3(0f, 352f, 0f);
if (LongshipUpgrades.changeShields.Value)
{
for (int num2 = 0; num2 < transform9.childCount; num2++)
{
LongshipPartController longshipPartController8 = ((Component)transform9.GetChild(num2)).gameObject.AddComponent<LongshipPartController>();
longshipPartController8.m_name = "$lu_part_shields_name";
longshipPartController8.m_nview = m_nview;
longshipPartController8.m_messageSwitch = "$lu_part_shields_switch";
longshipPartController8.m_zdoPartVariant = s_shieldsStyle;
longshipPartController8.m_variants = 4 + 3 * customShields.Count;
longshipPartController8.m_switchEffects = 1;
}
}
}
Transform val27 = val.parent.Find("unused");
if (Object.op_Implicit((Object)(object)val27))
{
GameObject val28 = new GameObject("heads");
Transform transform10 = val28.transform;
transform10.SetParent(val, false);
List<GameObject> list4 = new List<GameObject>();
Transform val29 = val27.Find("carnyx_head");
if (Object.op_Implicit((Object)(object)val29))
{
GameObject val30 = Object.Instantiate<GameObject>(((Component)val29).gameObject, transform10, true);
((Object)val30).name = ((Object)val29).name;
val30.SetActive(false);
list4.Add(val30);
}
Transform val31 = val27.Find("dragon_head");
if (Object.op_Implicit((Object)(object)val31))
{
GameObject val32 = Object.Instantiate<GameObject>(((Component)val31).gameObject, transform10, true);
((Object)val32).name = ((Object)val31).name;
val32.SetActive(false);
list4.Add(val32);
}
Transform val33 = val27.Find("oseberg_head");
if (Object.op_Implicit((Object)(object)val33))
{
GameObject val34 = Object.Instantiate<GameObject>(((Component)val33).gameObject, transform10, true);
((Object)val34).name = ((Object)val33).name;
val34.SetActive(false);
val34.transform.localPosition = Vector3.zero;
list4.Add(val34);
}
m_heads = list4.ToArray();
}
if (m_heads != null)
{
Transform val35 = AddCollider(transform8, "heads_controller", typeof(BoxCollider));
val35.localPosition = new Vector3(-3.9f, 0.53f, 0f);
val35.localScale = new Vector3(0.1f, 0.45f, 0.4f);
val35.localEulerAngles = new Vector3(0f, 0f, 63f);
m_headStyles = ((Component)val35).gameObject;
m_headStyles.layer = 16;
m_headStyles.SetActive(true);
LongshipPartController longshipPartController9 = ((Component)val35).gameObject.AddComponent<LongshipPartController>();
longshipPartController9.m_name = "$lu_part_head_name";
longshipPartController9.m_nview = m_nview;
longshipPartController9.m_messageSwitch = "$lu_part_head_switch";
longshipPartController9.m_zdoPartVariant = s_headStyle;
longshipPartController9.m_variants = 4;
longshipPartController9.m_switchEffects = 1;
}
if (s_turretPrefab == null)
{
Turret? obj8 = ((IEnumerable<Turret>)Resources.FindObjectsOfTypeAll<Turret>()).FirstOrDefault((Func<Turret, bool>)((Turret ws) => ((Object)ws).name == "piece_turret"));
s_turretPrefab = ((obj8 != null) ? ((Component)obj8).gameObject : null);
}
if ((Object)(object)s_turretPrefab != (Object)null)
{
m_turrets = new GameObject("turrets")
{
layer = 28
};
Transform transform11 = m_turrets.transform;
transform11.SetParent(val, false);
Transform val36 = AddCollider(transform8, "turrets_controller", typeof(BoxCollider));
val36.localPosition = new Vector3(-3.35f, 0.1f, 0f);
val36.localScale = new Vector3(0.04f, 0.35f, 0.45f);
m_turretsUpgrade = ((Component)val36).gameObject;
m_turretsUpgrade.layer = 16;
m_turretsUpgrade.SetActive(true);
LongshipPartController longshipPartController10 = ((Component)val36).gameObject.AddComponent<LongshipPartController>();
longshipPartController10.m_name = "$lu_part_turrets_name";
longshipPartController10.m_nview = m_nview;
longshipPartController10.m_zdoPartDisabled = s_turretsDisabled;
longshipPartController10.m_messageEnable = "$lu_part_turrets_enable";
longshipPartController10.m_enableEffects = 4;
longshipPartController10.m_messageDisable = "$lu_part_turrets_disable";
longshipPartController10.m_disableEffects = 5;
longshipPartController10.AddUpgradeRequirement(s_turretsUpgraded, "$lu_part_turrets_upgrade", LongshipUpgrades.ParseRequirements(LongshipUpgrades.turretsUpgradeRecipe.Value), LongshipUpgrades.turretsStation.Value, LongshipUpgrades.turretsStationLvl.Value, LongshipUpgrades.turretsStationRange.Value);
GameObject val37 = Object.Instantiate<GameObject>(((Component)s_turretPrefab.transform.Find("New")).gameObject, transform11, false);
((Object)val37).name = "turret_right";
val37.layer = 16;
val37.SetActive(true);
((Component)val37.transform.Find("Base")).gameObject.SetActive(false);
val37.transform.localScale = Vector3.one * 0.25f;
val37.transform.localPosition = new Vector3(-3.3f, -0.01f, 0.53f);
val37.transform.localEulerAngles = new Vector3(0f, 350f, 0f);
BoxCollider val38 = val37.AddComponent<BoxCollider>();
val38.center = new Vector3(0f, 0.7f, 0.1f);
val38.size = new Vector3(1f, 2f, 1f);
GameObject val39 = Object.Instantiate<GameObject>(val37, transform11, true);
((Object)val39).name = "turret_left";
val39.transform.localPosition = new Vector3(-3.3f, -0.01f, -0.53f);
val39.transform.localEulerAngles = new Vector3(0f, 190f, 0f);
Turret component5 = s_turretPrefab.GetComponent<Turret>();
ShipTurret.m_shootEffect = component5.m_shootEffect;
ShipTurret.m_addAmmoEffect = component5.m_addAmmoEffect;
ShipTurret.m_reloadEffect = component5.m_reloadEffect;
ShipTurret.m_warmUpStartEffect = component5.m_warmUpStartEffect;
ShipTurret.m_newTargetEffect = component5.m_newTargetEffect;
ShipTurret.m_lostTargetEffect = component5.m_lostTargetEffect;
ShipTurret.m_setTargetEffect = component5.m_setTargetEffect;
val37.AddComponent<ShipTurret>().SetPositionAtShip(isLeft: false).FillAllowedAmmo(component5.m_allowedAmmo)
.m_destroyedLootPrefab = m_destroyedLootPrefab;
val39.AddComponent<ShipTurret>().SetPositionAtShip(isLeft: true).FillAllowedAmmo(component5.m_allowedAmmo)
.m_destroyedLootPrefab = m_destroyedLootPrefab;
}
if (s_standBossDragonPrefab == null)
{
ItemStand? obj9 = ((IEnumerable<ItemStand>)Resources.FindObjectsOfTypeAll<ItemStand>()).FirstOrDefault((Func<ItemStand, bool>)((ItemStand ws) => ((Object)((Component)((Component)ws).transform.root).gameObject).name == "BossStone_DragonQueen"));
s_standBossDragonPrefab = ((obj9 != null) ? ((Component)obj9).gameObject : null);
}
if ((Object)(object)s_standBossDragonPrefab != (Object)null)
{
m_itemstandObject = new GameObject("ItemStand_Bow")
{
layer = 28
};
Transform transform12 = m_itemstandObject.transform;
transform12.SetParent(val, false);
m_itemstandObject.SetActive(false);
GameObject val40 = Object.Instantiate<GameObject>(s_standBossDragonPrefab, transform12, false);
((Object)val40).name = "itemstand";
val40.layer = 16;
Object.Destroy((Object)(object)((Component)val40.transform.Find("model/wood_pole (2)")).gameObject);
Transform val41 = val40.transform.Find("model");
((Component)val41).gameObject.layer = 16;
((Component)val41).gameObject.SetActive(true);
Transform val42 = val41.Find("plate");
val42.localScale = Vector3.one * 0.3f;
((Component)val42).gameObject.layer = 16;
Object.Destroy((Object)(object)((Component)val42).GetComponent<MeshCollider>());
MeshRenderer component6 = ((Component)val42).GetComponent<MeshRenderer>();
if ((Object)(object)standSharedMaterial == (Object)null)
{
standSharedMaterial = new Material(((Renderer)component6).sharedMaterial)
{
shader = shaderStandard
};
}
((Renderer)component6).sharedMaterial = standSharedMaterial;
Transform val43 = val40.transform.Find("attach_trophie");
val43.localPosition = Vector3.zero;
val43.localScale = Vector3.one * 0.75f;
((Component)val43).gameObject.layer = 16;
Transform val44 = val40.transform.Find("dropspawn");
val44.localPosition = new Vector3(0.01f, 0.5f, -0.69f);
((Component)val44).gameObject.layer = 16;
val40.transform.localScale = Vector3.one * 0.45f;
val40.transform.localPosition = new Vector3(-4.6f, 0.7f, 0f);
val40.transform.localEulerAngles = new Vector3(0f, 270f, 0f);
val40.GetComponent<BoxCollider>().size = new Vector3(0.75f, 1f, 0.5f);
ItemStand component7 = val40.GetComponent<ItemStand>();
m_trophyStand = val40.AddComponent<ShipTrophyStand>();
m_trophyStand.m_activatePowerEffects = component7.m_activatePowerEffects;
m_trophyStand.m_activatePowerEffectsPlayer = component7.m_activatePowerEffectsPlayer;
m_trophyStand.m_attachOther = component7.m_attachOther;
m_trophyStand.m_dropSpawnPoint = component7.m_dropSpawnPoint;
m_trophyStand.m_effects = component7.m_effects;
m_trophyStand.m_destroyEffects = component7.m_destroyEffects;
Object.Destroy((Object)(object)component7);
if (LongshipUpgrades.itemStandDisableSpeaking.Value)
{
RandomSpeak componentInChildren2 = m_itemstandObject.GetComponentInChildren<RandomSpeak>();
if (componentInChildren2 != null)
{
((Component)componentInChildren2).gameObject.SetActive(false);
}
}
m_itemstandObject.SetActive(true);
}
if (s_wisptorchPrefab == null)
{
GameObject prefab = ZNetScene.instance.GetPrefab("piece_groundtorch_mist");
s_wisptorchPrefab = ((prefab != null) ? prefab.gameObject : null);
}
if ((Object)(object)s_wisptorchPrefab != (Object)null)
{
m_wisp = Object.Instantiate<GameObject>(((Component)s_wisptorchPrefab.transform.Find("_enabled")).gameObject, val, false);
((Object)m_wisp).name = "wisptorch";
m_wisp.layer = 16;
m_wisp.SetActive(false);
m_wisp.transform.localScale = Vector3.one * 0.35f;
m_wisp.transform.localPosition = new Vector3(-0.125f, 4.77f, -0.002f);
Transform val45 = m_wisp.transform.Find("Particle System Force Field");
Demister component8 = ((Component)val45).GetComponent<Demister>();
component8.m_disableForcefieldDelay = 0f;
((MonoBehaviour)component8).CancelInvoke("DisableForcefield");
((Component)val45).GetComponent<ParticleSystemForceField>().endRange = 13f;
val45.localPosition = new Vector3(-2f, -10f, 0f);
MainModule main2 = ((Component)m_wisp.transform.Find("sparcs_front")).GetComponent<ParticleSystem>().main;
((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1;
if (LongshipUpgrades.wispEnabled.Value)
{
Transform val46 = AddCollider(transform8, "wisp_controller", typeof(BoxCollider));
val46.localPosition = new Vector3(-0.13f, 1.22f, 0f);
val46.localScale = new Vector3(0.11f, 0.25f, 0.12f);
m_wispUpgrade = ((Component)val46).gameObject;
m_wispUpgrade.layer = 16;
m_wispUpgrade.SetActive(true);
LongshipPartController longshipPartController11 = ((Component)val46).gameObject.AddComponent<LongshipPartController>();
longshipPartController11.m_name = "$lu_part_wisp_name";
longshipPartController11.m_zdoPartDisabled = s_wispRemoved;
longshipPartController11.m_enableEffects = 6;
longshipPartController11.m_disableEffects = 1;
longshipPartController11.m_nview = m_nview;
longshipPartController11.AddUpgradeRequirement(s_wispUpgraded, "$lu_part_wisp_upgrade", LongshipUpgrades.ParseRequirements(LongshipUpgrades.wispUpgradeRecipe.Value), LongshipUpgrades.wispStation.Value, LongshipUpgrades.wispStationLvl.Value, LongshipUpgrades.wispStationRange.Value);
}
}
if ((Object)(object)s_mapTablePrefab != (Object)null)
{
m_mapTable = Object.Instantiate<GameObject>(s_mapTablePrefab, val, false);
((Object)m_mapTable).name = "maptable";
m_mapTable.layer = 16;
m_mapTable.SetActive(false);
m_mapTable.transform.localScale = Vector3.one * 0.45f;
m_mapTable.transform.localPosition = new Vector3(-1.14f, -0.05f, -0.73f);
m_mapTable.transform.localEulerAngles = new Vector3(0f, 342.6f, 0f);
MapTable component9 = m_mapTable.GetComponent<MapTable>();
component9.m_nview = m_nview;
component9.m_nview.Register<ZPackage>("MapData", (Action<long, ZPackage>)component9.RPC_MapData);
component9.m_readSwitch = ((Component)((Component)component9).transform.Find("ReadMap")).GetComponent<Switch>();
component9.m_readSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)component9.m_readSwitch.m_onUse, (Delegate?)new Callback(component9.OnRead));
component9.m_readSwitch.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)component9.m_readSwitch.m_onHover, (Delegate?)new TooltipCallback(component9.GetReadHoverText));
component9.m_writeSwitch = ((Component)((Component)component9).transform.Find("WriteMap")).GetComponent<Switch>();
component9.m_writeSwitch.m_onUse = (Callback)Delegate.Combine((Delegate?)(object)component9.m_writeSwitch.m_onUse, (Delegate?)new Callback(component9.OnWrite));
component9.m_writeSwitch.m_onHover = (TooltipCallback)Delegate.Combine((Delegate?)(object)component9.m_writeSwitch.m_onHover, (Delegate?)new TooltipCallback(component9.GetWriteHoverText));
if (LongshipUpgrades.mapTableEnabled.Value)
{
Transform val47 = AddCollider(transform8, "mapTable_controller", typeof(BoxCollider));
val47.localPosition = m_mapTable.transform.localPosition;
val47.localScale = new Vector3(0.27f, 0.04f, 0.27f);
val47.localEulerAngles = m_mapTable.transform.localEulerAngles;
m_mapTableUpgrade = ((Component)val47).gameObject;
m_mapTableUpgrade.layer = 16;
m_mapTableUpgrade.SetActive(true);
LongshipPartController longshipPartController12 = ((Component)val47).gameObject.AddComponent<LongshipPartController>();
longshipPartController12.m_name = "$lu_part_maptable_name";
longshipPartController12.m_nview = m_nview;
longshipPartController12.AddUpgradeRequirement(s_mapTableUpgraded, "$lu_part_maptable_upgrade", LongshipUpgrades.ParseRequirements(LongshipUpgrades.mapTableUpgradeRecipe.Value), LongshipUpgrades.mapTableStation.Value, LongshipUpgrades.mapTableStationLvl.Value, LongshipUpgrades.mapTableStationRange.Value);
}
}
void AddHealthController(Transform parent, int i, string name, float offset)
{
//IL_0040: 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)
GameObject val48 = Object.Instantiate<GameObject>(((Component)parent.GetChild(i)).gameObject, healthParent, true);
((Object)val48).name = ((i == 0) ? name : $"{name} ({i})");
Transform transform13 = val48.transform;
transform13.localPosition += new Vector3(0f, 0f, offset);
LongshipPartController longshipPartController13 = val48.gameObject.AddComponent<LongshipPartController>();
longshipPartController13.m_nview = m_nview;
longshipPartController13.m_name = "$lu_part_hull_name";
longshipPartController13.AddUpgradeRequirement(s_healthUpgraded, "$lu_part_hull_upgrade1", LongshipUpgrades.ParseRequirements(LongshipUpgrades.healthUpgradeRecipe.Value), LongshipUpgrades.healthLvl1Station.Value, LongshipUpgrades.healthLvl1StationLvl.Value, LongshipUpgrades.healthLvl1StationRange.Value);
if (LongshipUpgrades.healthUpgradeLvl2.Value != 0)
{
longshipPartController13.AddUpgradeRequirement(s_ashlandsUpgraded, Localization.instance.Localize("$lu_part_hull_upgrade2", new string[1] { LongshipUpgrades.ashlandsProtection.Value ? "\n$lu_part_hull_upgrade2_ashlands" : "" }), LongshipUpgrades.ParseRequirements(LongshipUpgrades.ashlandsUpgradeRecipe.Value), LongshipUpgrades.healthLvl2Station.Value, LongshipUpgrades.healthLvl2StationLvl.Value, LongshipUpgrades.healthLvl2StationRange.Value);
}
val48.gameObject.SetActive(true);
val48.gameObject.layer = 16;
}
}
public void OnDestroyed()
{
if (m_nview.IsValid() && m_nview.IsOwner())
{
DropItemStand();
DropSpentUpgrades();
}
}
private void DropItemStand()
{
//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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_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_00fa: 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_0138: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: 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 (!Object.op_Implicit((Object)(object)m_trophyStand) || !m_trophyStand.HaveAttachment())
{
return;
}
string @string = m_trophyStand.m_nview.GetZDO().GetString(ZDOVars.s_item, "");
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(@string);
if (!Object.op_Implicit((Object)(object)itemPrefab))
{
return;
}
Vector3 val = Vector3.zero;
Quaternion val2 = Quaternion.identity;
Transform val3 = itemPrefab.transform.Find("attach");
if (Object.op_Implicit((Object)(object)itemPrefab.transform.Find("attachobj")) && Object.op_Implicit((Object)(object)val3))
{
val2 = ((Component)val3).transform.localRotation;
val = ((Component)val3).transform.localPosition;
}
GameObject val4 = Object.Instantiate<GameObject>(itemPrefab, m_trophyStand.m_dropSpawnPoint.position + val, m_trophyStand.m_dropSpawnPoint.rotation * val2);
ItemDrop component = val4.GetComponent<ItemDrop>();
component.LoadFromExternalZDO(m_trophyStand.m_nview.GetZDO());
val4.GetComponent<Rigidbody>().linearVelocity = Vector3.up * 4f;
if (Object.op_Implicit((Object)(object)m_destroyedLootPrefab))
{
Inventory val5 = SpawnContainer(m_destroyedLootPrefab);
if (val5.AddItem(component.m_itemData))
{
ZNetScene.instance.Destroy(val4);
}
}
}
public void DropSpentUpgrades()
{
if (ZoneSystem.instance.GetGlobalKey((GlobalKeys)19))
{
return;
}
Dictionary<int, Requirement[]> dictionary = new Dictionary<int, Requirement[]>();
LongshipPartController[] componentsInChildren = ((Component)this).GetComponentsInChildren<LongshipPartController>(true);
foreach (LongshipPartController longshipPartController in componentsInChildren)
{
longshipPartController.AddSpentUpgrades(dictionary);
}
if (dictionary.Count != 0)
{
CollectionExtensions.Do<Requirement[]>((IEnumerable<Requirement[]>)dictionary.Values, (Action<Requirement[]>)delegate(Requirement[] itemsToDrop)
{
DropRequirements(itemsToDrop.ToList());
});
}
}
public void DropRequirements(List<Requirement> itemsToDrop)
{
//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_00e2: 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_00f6: 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_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_0135: 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)
if (Object.op_Implicit((Object)(object)m_destroyedLootPrefab))
{
Inventory val = SpawnContainer(m_destroyedLootPrefab);
while (itemsToDrop.Count > 0)
{
Requirement val2 = itemsToDrop[0];
if (val2.m_amount <= 0)
{
itemsToDrop.RemoveAt(0);
}
else if (val.AddItem(ObjectDB.instance.GetItemPrefab(((Object)val2.m_resItem).name), 1))
{
val2.m_amount--;
}
else if (!val.HaveEmptySlot())
{
val = SpawnContainer(m_destroyedLootPrefab);
}
else
{
itemsToDrop.RemoveAt(0);
}
}
return;
}
while (itemsToDrop.Count > 0)
{
Requirement val3 = itemsToDrop[0];
while (val3.m_amount > 0)
{
Vector3 val4 = ((Component)this).transform.position + Vector3.up * 0.5f + Random.insideUnitSphere * 0.3f;
Quaternion val5 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
ItemDrop component = Object.Instantiate<GameObject>(ObjectDB.instance.GetItemPrefab(((Object)val3.m_resItem).name), val4, val5).GetComponent<ItemDrop>();
if ((Object)(object)component == (Object)null)
{
break;
}
component.SetStack(val3.m_amount);
val3.m_amount -= component.m_itemData.m_stack;
}
itemsToDrop.RemoveAt(0);
}
}
public Inventory SpawnContainer(GameObject lootContainerPrefab)
{
//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_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_0020: 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)
Vector3 val = ((Component)this).transform.position + Random.insideUnitSphere * 1f;
return Object.Instantiate<GameObject>(lootContainerPrefab, val, Random.rotation).GetComponent<Container>().GetInventory();
}
public bool IsTentActive()
{
return (Object)(object)m_tent != (Object)null && m_tent.activeInHierarchy;
}
public bool IsHeatActive()
{
return (Object)(object)m_fireWarmth != (Object)null && m_fireWarmth.m_isHeatType;
}
private static bool IsNightTime()
{
return EnvMan.IsNight();
}
private static bool IsTimeToLight()
{
if (!EnvMan.IsDaylight() || !Object.op_Implicit((Object)(object)EnvMan.instance))
{
return true;
}
float dayFraction = EnvMan.instance.GetDayFraction();
if (!(dayFraction <= 0.28f))
{
return dayFraction >= 0.71f;
}
return true;
}
internal static void OnGlobalStart()
{
shaderStandard = null;
isNightTime = false;
isTimeToLight = true;
FixPrefab();
}
internal static void OnGlobalDestroy()
{
shaderStandard = null;
s_lanternPrefab = null;
s_turretPrefab = null;
s_standBossDragonPrefab = null;
s_wisptorchPrefab = null;
Object.Destroy((Object)(object)s_mapTablePrefab);
s_mapTablePrefab = null;
}
private static void FixPrefab()
{
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
ZNetScene instance = ZNetScene.instance;
object obj = ((instance != null) ? instance.GetPrefab("VikingShip") : null);
if (obj == null)
{
Ship? obj2 = ((IEnumerable<Ship>)Resources.FindObjectsOfTypeAll<Ship>()).FirstOrDefault((Func<Ship, bool>)((Ship ws) => ((Object)ws).name == "VikingShip"));
obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
}
GameObject val = (GameObject)obj;
if ((Object)(object)val == (Object)null)
{
return;
}
shaderStandard = ((Renderer)((Component)val.transform.Find("piece_chest/visual/Cube")).GetComponent<MeshRenderer>()).sharedMaterial.shader;
Transform val2 = val.transform.Find("ship/visual/Customize/storage");
for (int i = 0; i < val2.childCount; i++)
{
Transform child = val2.GetChild(i);
if (((Object)child).name.StartsWith("default"))
{
MeshRenderer component = ((Component)child).GetComponent<MeshRenderer>();
if ((Object)(object)storageSharedMaterial == (Object)null || storageSharedMaterial == null)
{
storageSharedMaterial = new Material(((Renderer)component).sharedMaterial)
{
shader = shaderStandard
};
}
else
{
storageSharedMaterial.shader = shaderStandard;
}
((Renderer)component).sharedMaterial = storageSharedMaterial;
}
}
MeshRenderer component2 = ((Component)val.transform.Find("ship/visual/hull_worn/plank")).GetComponent<MeshRenderer>();
if ((Object)(object)plankSharedMaterial == (Object)null || plankSharedMaterial == null)
{
plankSharedMaterial = new Material(((Renderer)component2).sharedMaterial)
{
shader = shaderStandard
};
}
else
{
plankSharedMaterial.shader = shaderStandard;
}
((Renderer)component2).sharedMaterial = plankSharedMaterial;
((Renderer)((Component)val.transform.Find("ship/visual/hull_worn/plank (1)")).GetComponent<MeshRenderer>()).sharedMaterial = plankSharedMaterial;
((Renderer)((Component)val.transform.Find("ship/visual/hull_broken/plank")).GetComponent<MeshRenderer>()).sharedMaterial = plankSharedMaterial;
((Renderer)((Component)val.transform.Find("ship/visual/hull_broken/plank (1)")).GetComponent<MeshRenderer>()).sharedMaterial = plankSharedMaterial;
if (!prefabInitialized)
{
prefabInitialized = true;
Transform val3 = val.transform.Find("ship/visual/Customize/ShipTen2_beam");
val3.localPosition += new Vector3(0f, 0.1f, 0f);
((Component)val3).gameObject.layer = 28;
Transform val4 = val.transform.Find("ship/visual/Customize/ShipTen2 (1)");
val4.localPosition += new Vector3(0f, 0.08f, 0f);
Transform val5 = val.transform.Find("OnboardTrigger");
val5.localScale += new Vector3(0.1f, 2f, 0f);
val5.localPosition += new Vector3(-0.05f, 1f, 0f);
Material sharedMaterial = ((Renderer)((Component)val4).GetComponentInChildren<MeshRenderer>()).sharedMaterial;
sharedMaterial.SetFloat("_RippleSpeed", 75f);
sharedMaterial.SetFloat("_RippleDistance", 1.25f);
Transform obj3 = val.transform.Find("ship/visual/Mast");
obj3.localPosition += new Vector3(0f, 0.21f, 0f);
Transform obj4 = val.transform.Find("ship/visual/Customize/ShipTentHolders");
obj4.localPosition += new Vector3(0f, 0.01f, 0f);
Transform val6 = val.transform.Find("ship/visual/Customize/ShipTentHolders (1)");
val6.localPosition += new Vector3(0.1f, -0.18f, 0.11f);
val6.localEulerAngles += new Vector3(0f, 5f, 6.6f);
Transform val7 = val.transform.Find("ship/visual/Customize/TraderLamp");
((Component)val7).gameObject.SetActive(false);
prefabInit = true;
val.AddComponent<LongshipCustomizableParts>();
prefabInit = false;
}
}
private static Transform AddCollider(Transform transform, string name, Type type)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
Transform transform2 = new GameObject(name, new Type[1] { type }).transform;
transform2.SetParent(transform, false);
((Component)transform2).gameObject.layer = 28;
return transform2;
}
internal static void AddCustomTent(string filename)
{
AddCustomTexture(customTents, filename);
}
internal static void AddCustomSail(string filename)
{
AddCustomTexture(customSails, filename);
}
internal static void AddCustomShields(string filename)
{
AddCustomTexture(customShields, filename);
}
private static void AddCustomTexture(List<Texture2D> list, string filename)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
Texture2D tex = new Texture2D(2, 2);
if (LongshipUpgrades.LoadTextureFromConfigDirectory(filename, ref tex))
{
list.Add(tex);
}
}
private static void CheckEffects()
{
List<EffectData> effectPrefabs;
if (!partEffects.HasEffects())
{
effectPrefabs = new List<EffectData>();
AddEffect(0, "vfx_Place_HildirFabricRoll");
AddEffect(1, "sfx_gui_repairitem_workbench");
AddEffect(2, "sfx_FireAddFuel");
AddEffect(3, "fx_candle_off");
AddEffect(4, "fx_guardstone_permitted_add");
AddEffect(5, "fx_guardstone_permitted_removed");
AddEffect(6, "sfx_demister_start");
partEffects.m_effectPrefabs = effectPrefabs.ToArray();
}
void AddEffect(int variant, string prefabName)
{
//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_0020: 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_0039: Expected O, but got Unknown
GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
effectPrefabs.Insert(variant, new EffectData
{
m_prefab = prefab,
m_enabled = ((Object)(object)prefab != (Object)null),
m_variant = variant
});
}
}
internal static void UpdatePropertyBlocks(GameObject go)
{
if (s_allInstances.TryGetValue(go, out var value))
{
value.UpdatePropertyBlocks();
}
}
internal static void CombinePropertyBlocks(GameObject go, MaterialPropertyBlock propertyBlockToCombine)
{
if (s_allInstances.TryGetValue(go, out var value))
{
value.CombinePropertyBlocks(propertyBlockToCombine);
}
}
internal static bool HasShipComponent(GameObject go)
{
return s_allInstances.ContainsKey(go);
}
internal static bool TryGetShipComponent(Ship ship, out LongshipCustomizableParts parts)
{
return s_allInstances.TryGetValue(((Component)ship).gameObject, out parts) || ((Component)ship).TryGetComponent<LongshipCustomizableParts>(ref parts);
}
public static Vector3 ParseVector3(string rString)
{
//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_005b: Unknown result type (might be due to invalid IL or missing references)
string[] array = rString.Substring(1, rString.Length - 2).Split(',');
float num = float.Parse(array[0].Replace('.', ','));
float num2 = float.Parse(array[1].Replace('.', ','));
float num3 = float.Parse(array[2].Replace('