using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Drone;
using IL.EntityStates.Drone;
using IL.RoR2.Hologram;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.Hologram;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DroneRepairBeacon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eda0a1e0999df3582e8798c100a442798d0ba414")]
[assembly: AssemblyProduct("DroneRepairBeacon")]
[assembly: AssemblyTitle("DroneRepairBeacon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DroneRepairBeacon
{
public class deadDroneTracker : MonoBehaviour, IHologramContentProvider
{
public class recieveMessageID : INetMessage, ISerializableObject
{
private NetworkInstanceId trackerNetID;
private int messageID;
private bool useSpecificSprite;
public recieveMessageID(NetworkInstanceId netId, int num, bool useSpecific)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
trackerNetID = netId;
messageID = num;
useSpecificSprite = useSpecific;
}
public recieveMessageID()
{
}
public void Serialize(NetworkWriter writer)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
writer.Write(trackerNetID);
writer.Write(messageID);
writer.Write(useSpecificSprite);
}
public void Deserialize(NetworkReader reader)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
trackerNetID = reader.ReadNetworkId();
messageID = reader.ReadInt32();
useSpecificSprite = reader.ReadBoolean();
}
public void OnReceived()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active || messageID != -1)
{
return;
}
GameObject val = Util.FindNetworkObject(trackerNetID);
if (!Object.op_Implicit((Object)(object)val))
{
Log.Warning($"{typeof(recieveMessageID).FullName}: Could not retrieve GameObject with network ID {trackerNetID}");
return;
}
Log.Debug($"{val}");
deadDroneTracker component = val.GetComponent<deadDroneTracker>();
if (!Object.op_Implicit((Object)(object)component))
{
Log.Warning($"{typeof(recieveMessageID).FullName}: Retrieved GameObject {val} but the GameObject does not have a deadDroneTracker");
return;
}
component.messageID = messageID;
component.usingSpecificSprite = useSpecificSprite;
Log.Debug("recieved message id ! " + messageID);
component.UpdateSprite();
}
}
public class sendMessageID : INetMessage, ISerializableObject
{
private NetworkInstanceId trackerNetID;
private bool useSpecificSprites;
public sendMessageID(NetworkInstanceId netId, bool useSpecific)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
trackerNetID = netId;
useSpecificSprites = useSpecific;
}
public sendMessageID()
{
}
public void Serialize(NetworkWriter writer)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
writer.Write(trackerNetID);
writer.Write(useSpecificSprites);
}
public void Deserialize(NetworkReader reader)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
trackerNetID = reader.ReadNetworkId();
useSpecificSprites = reader.ReadBoolean();
}
public void OnReceived()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active)
{
Log.Debug("sending back proper message id ,..,");
GameObject val = Util.FindNetworkObject(trackerNetID);
if (!Object.op_Implicit((Object)(object)val))
{
Log.Warning($"{typeof(recieveMessageID).FullName}: Could not retrieve GameObject with network ID {trackerNetID}");
}
deadDroneTracker component = val.GetComponent<deadDroneTracker>();
if (!Object.op_Implicit((Object)(object)component))
{
Log.Warning($"{typeof(recieveMessageID).FullName}: Retrieved GameObject {val} but the GameObject does not have a deadDroneTracker");
}
else
{
NetMessageExtensions.Send((INetMessage)(object)new recieveMessageID(trackerNetID, component.messageID, component.usingSpecificSprite), (NetworkDestination)1);
}
}
}
}
public int messageID = -1;
public bool usingSpecificSprite;
[CompilerGenerated]
private GameObject <hologramContentPrefab>k__BackingField;
private GameObject hologramContentPrefab
{
get
{
if (Object.op_Implicit((Object)(object)<hologramContentPrefab>k__BackingField))
{
return <hologramContentPrefab>k__BackingField;
}
<hologramContentPrefab>k__BackingField = PrefabAPI.InstantiateClone(DroneRepairBeacon.DroneIndicatorVFX, "Drone Repair Beacon Hologram", false);
UpdateSprite();
return <hologramContentPrefab>k__BackingField;
}
}
public void Start()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
((Component)this).gameObject.transform.localScale = new Vector3(DroneRepairBeacon.helpScale.Value, DroneRepairBeacon.helpScale.Value, DroneRepairBeacon.helpScale.Value);
Vector3 position = ((Component)this).gameObject.transform.position;
position.y += 4f * DroneRepairBeacon.helpScale.Value;
((Component)this).gameObject.transform.position = position;
if (!NetworkServer.active)
{
NetMessageExtensions.Send((INetMessage)(object)new sendMessageID(((Component)this).GetComponent<NetworkIdentity>().netId, usingSpecificSprite), (NetworkDestination)2);
}
}
GameObject IHologramContentProvider.GetHologramContentPrefab()
{
if (messageID != -1)
{
return hologramContentPrefab;
}
return null;
}
public void UpdateSprite()
{
SpriteRenderer component = hologramContentPrefab.GetComponent<SpriteRenderer>();
if (usingSpecificSprite)
{
component.sprite = DroneRepairBeacon.specificDroneIndicatorSprites[messageID];
((Renderer)component).SetMaterial(DroneRepairBeacon.specificDroneIndicatorMaterials[messageID]);
}
else
{
component.sprite = DroneRepairBeacon.droneIndicatorSprites[messageID];
((Renderer)component).SetMaterial(DroneRepairBeacon.droneIndicatorMaterials[messageID]);
}
}
public void UpdateHologramContent(GameObject hologramContentObject, Transform viewerBody)
{
}
bool IHologramContentProvider.ShouldDisplayHologram(GameObject viewer)
{
//IL_0010: 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)
if (!Object.op_Implicit((Object)(object)viewer))
{
return false;
}
return Vector3.Distance(viewer.transform.position, ((Component)this).gameObject.transform.position) <= DroneRepairBeacon.displayDistance.Value;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("icebro.DroneRepairBeacon", "DroneRepairBeacon", "1.0.1")]
public class DroneRepairBeacon : BaseUnityPlugin
{
private const string PluginGUID = "icebro.DroneRepairBeacon";
private const string PluginAuthor = "icebro";
private const string PluginName = "DroneRepairBeacon";
private const string PluginVersion = "1.0.1";
private static GameObject DroneIndicatorHologram;
public static GameObject DroneIndicatorVFX;
public static List<Sprite> droneIndicatorSprites = new List<Sprite>();
public static Material[] droneIndicatorMaterials = Array.Empty<Material>();
public static List<Sprite> specificDroneIndicatorSprites = new List<Sprite>();
public static Material[] specificDroneIndicatorMaterials = Array.Empty<Material>();
public static ConfigEntry<float> displayDistance;
public static ConfigEntry<float> helpScale;
private static ConfigEntry<string> DeathTokenConfigs;
private static ConfigEntry<string> DroneSpecificDeathTokenConfigs;
public static ConfigEntry<string> droneSprites;
public static ConfigEntry<bool> customDroneSprites;
private static ConfigEntry<bool> alwaysShowHelp;
private static ConfigEntry<bool> alwaysShowHelpAllowTurrets;
public static AssetBundle assetbundle;
public static Material baseMat;
private static bool UHRInstalled => Chainloader.PluginInfos.ContainsKey("iDeathHD.UnityHotReload");
public void Awake()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
Log.Init(((BaseUnityPlugin)this).Logger);
assetbundle = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "dronevisibilitybundle")).assetBundle;
DroneIndicatorVFX = assetbundle.LoadAsset<GameObject>("DroneIndicatorVFX");
baseMat = assetbundle.LoadAsset<Material>("HGStandard");
Material[] array = assetbundle.LoadAllAssets<Material>();
foreach (Material val in array)
{
if (!(((Object)val).name != "HGStandard"))
{
val.shader = Addressables.LoadAssetAsync<Shader>((object)RoR2_Base_Shaders.HGStandard_shader).WaitForCompletion();
Log.Debug("swapped drone notif shader !");
}
}
DeathTokenConfigs = ((BaseUnityPlugin)this).Config.Bind<string>("drone repair beacon", "silly death strings ! split with /, ...,., set to nothing to disable !", "res me twin....,,./,HELP HELP MEEE HEEEEEELP/,ough ,.,.../,babe its {TIME},,, time for your drone reviving session,.,.,.,/,im not broken! im just.... napping... indefinitely..../,REQUESTING HELP.../,LOST CONNECTION.../,YOUR WARRANTY IS 3 DAYS EXPIRED./,oof ouch my bo lts..,/,FUCK", "byeah !");
DroneSpecificDeathTokenConfigs = ((BaseUnityPlugin)this).Config.Bind<string>("drone repair beacon", "specific drone death strings! formatting like (drone internal name);;(string,string);;!", "Drone1Body;;do your own DPS instead... im done...;'.;/,pls revive i had raygun/,drats,..,,almost had em,.,,,;;Drone2Body;;ill,,.,., miss you \ud83e\udd7a/,please don't leave me here.,.,./,I MISS_YOU ALREADY;;CopycatDrone;;i_i feel.,.., cold.,.,/,is it just me or is it f_f_freezing.,.,,;;BombardmentDrone;;ERR: HEAVY DAMAGE SUSTAINED/, RETRIEVING FINAL WISHES... UNDEFINED...;;RechargeDrone;;i've.,.,. failed you,..,./, come back,,,.. you're hurt,,.,,/,i'll always be watching over you,,...;;CleanupDrone;;cleanu;p on aisle,, 6.,.,./,what a mess i've gotten myself into.,,../,missed a spot,,,..;;EmergencyDrone;;i just wanted to protect everyone,,,...,...,,,, /, keep them safe.,,,.for me..,../,why can't we all be friends..?;;HaulerDrone;; i've,,.. lost my way..,.,/, it's the end of the road for me :(/,carry me back home, would you?;;EquipmentDrone;;i wasn't equipped to handle THIS!/,your gift was wasted on me..,../, you dropped something,..,,;;FlameDrone;;couldn't,, take the heat,,,,.,/,gimme a sec, just need to.,,,., cool down real quick,,,.,/,oohHAhothothot!!;;JailerDrone;;can't,,,, move...,./,h_hey, slow down..!/everything's so,,.,, still..,.;;JunkDrone;;i'm not junk,.,.,,,/,please don't scrap me..,.,/,wait.,.., i've still got more to give..,..;;MissileDrone;;target lost,..,,/,look's like team missile's blasting off again.,,.,,/,i can't see them, boss..,.,boss..?", "you can get them from debugtoolkit or wiki (wiki ones are missing body sometimes though ! like .,., Drone1Body = gunnerdrone ,.,. Drone2Body = healing drone .,.,,..");
displayDistance = ((BaseUnityPlugin)this).Config.Bind<float>("drone repair beacon", "how far should help be visible !!", 90f, "byeah !");
helpScale = ((BaseUnityPlugin)this).Config.Bind<float>("drone repair beacon", "how big help should be ! 1 equals 1x ,.,.,.", 1f, "byeah !");
alwaysShowHelp = ((BaseUnityPlugin)this).Config.Bind<bool>("drone repair beacon", "always show help ,.., like on unpurchased drones !!", false, "byeah !");
alwaysShowHelpAllowTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("drone repair beacon", "always show help allow turrets to be helped too !!", false, "byeah !");
droneSprites = ((BaseUnityPlugin)this).Config.Bind<string>("drone repair beacon", "what message sprites to use! randomizes with multiple ,..,. options in config desc !! seperate by , NEEDS RESTART !!", "BeaconVFXbrokenheart,BeaconVFXCog,BeaconVFXexplain,BeaconVFXowww,BeaconVFXplead,BeaconVFXresmetwin,BeaconVFXAnar,BeaconVFXLukas", "BeaconVFXbrokenheart,BeaconVFXCog,BeaconVFXexplain,BeaconVFXowww,BeaconVFXplead,BeaconVFXresmetwin,BeaconVFXAnar,BeaconVFXAnarColor,BeaconVFXLukas,BeaconVFXLukasColor");
customDroneSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("drone repair beacon", "if you have any custom images you wants to use !!! NEEDS RESTART !!", false, "should be in bepin config directory in DroneBeacon folder .,,. just add there and will appear in rotation !! ,.,., must end in .png !!!!!!!!!!!!!");
SpriteLoading.ChangeSprites();
Hook();
DroneIndicatorHologram = assetbundle.LoadAsset<GameObject>("DroneIndicatorHologram");
DroneIndicatorHologram.AddComponent<NetworkIdentity>();
HologramProjector component = DroneIndicatorHologram.GetComponent<HologramProjector>();
component.contentProvider = (IHologramContentProvider)(object)DroneIndicatorHologram.AddComponent<deadDroneTracker>();
component.displayDistance = displayDistance.Value;
PrefabAPI.RegisterNetworkPrefab(DroneIndicatorHologram);
NetworkingAPI.RegisterMessageType<deadDroneTracker.recieveMessageID>();
NetworkingAPI.RegisterMessageType<deadDroneTracker.sendMessageID>();
}
private void Hook()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
SummonMasterBehavior.OnEnable += new hook_OnEnable(SummonMasterBehaviorOnOnEnable);
DeathState.OnImpactServer += new Manipulator(DeathStateOnOnImpactServer);
HologramProjector.UpdateForViewer += new Manipulator(HologramProjectorOnUpdateForViewer);
}
private void SummonMasterBehaviorOnOnEnable(orig_OnEnable orig, SummonMasterBehavior self)
{
orig.Invoke(self);
if (alwaysShowHelp.Value && (alwaysShowHelpAllowTurrets.Value || !((Object)((Component)self).gameObject).name.Contains("Turret")))
{
Object.Instantiate<GameObject>(DroneIndicatorHologram, ((Component)self).transform);
}
}
private void HologramProjectorOnUpdateForViewer(ILContext il)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
Log.Debug("tryings il hook hologram updater ,,.");
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchRet(x),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchCall<HologramProjector>(x, "DestroyHologram")
}))
{
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<HologramProjector>>((Action<HologramProjector>)delegate(HologramProjector hologramProjector)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
if (((Object)hologramProjector).name == "DroneIndicatorHologram(Clone)")
{
Transform child = ((Component)hologramProjector).transform.GetChild(0).GetChild(0);
if ((Object)(object)child != (Object)null)
{
Quaternion rotation = Quaternion.Euler(new Vector3(0f, child.eulerAngles.y, 0f));
rotation.x = 0f;
rotation.z = 0f;
((Component)child).transform.rotation = rotation;
}
}
});
Log.Debug("added il hook to hologram updater !!");
}
private void DeathStateOnOnImpactServer(ILContext il)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
Log.Debug("tryings il hook dead drone ,,.");
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
(Instruction x) => ILPatternMatchingExt.MatchStfld<DeathState>(x, "spawnedRepairObject")
}))
{
return;
}
val.Emit(OpCodes.Ldarg_0);
val.Emit(OpCodes.Ldloc_S, (byte)4);
val.EmitDelegate<Action<DeathState, GameObject>>((Action<DeathState, GameObject>)delegate(DeathState deathState, GameObject deadDrone)
{
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Expected O, but got Unknown
int num = -1;
bool flag = false;
if (droneIndicatorSprites.Count != 0 || specificDroneIndicatorSprites.Count != 0)
{
List<int> list = new List<int>();
for (int i = 0; i < specificDroneIndicatorSprites.Count; i++)
{
Log.Debug("bweh " + ((Object)specificDroneIndicatorSprites[i]).name.Replace("Body", ""));
Log.Debug(((Object)((EntityState)deathState).characterBody).name.Replace("Body", "").Replace("(Clone)", ""));
if (!(((Object)specificDroneIndicatorSprites[i]).name.Split("_")[0].Replace("Body", "") != ((Object)((EntityState)deathState).characterBody).name.Replace("Body", "").Replace("(Clone)", "")))
{
Log.Debug("adding " + ((Object)specificDroneIndicatorSprites[i]).name);
list.Add(i);
}
}
Log.Debug(list.Count);
if (droneIndicatorSprites.Count != 0 || list.Count != 0)
{
num = Run.instance.runRNG.RangeInt(0, droneIndicatorSprites.Count + list.Count);
if (num >= droneIndicatorSprites.Count)
{
num = list[Run.instance.runRNG.RangeInt(0, list.Count)];
flag = true;
}
Log.Debug(num);
Log.Debug(flag);
if (!flag)
{
Log.Debug(droneIndicatorSprites[num]);
}
}
}
if (!alwaysShowHelp.Value)
{
GameObject obj = Object.Instantiate<GameObject>(DroneIndicatorHologram, deadDrone.transform);
deadDroneTracker component = obj.GetComponent<deadDroneTracker>();
component.messageID = num;
component.usingSpecificSprite = flag;
NetworkServer.Spawn(obj);
}
if (!(DeathTokenConfigs.Value == ""))
{
List<string> list2 = DeathTokenConfigs.Value.Split("/,").ToList();
string[] array = DroneSpecificDeathTokenConfigs.Value.Split(";;");
for (int j = 0; j < array.Length; j++)
{
if (!(array[j].Trim().Replace("Body", "") != ((Object)((EntityState)deathState).characterBody).name.Replace("Body", "").Replace("(Clone)", "")))
{
string[] collection = array[j + 1].Split("/,");
list2.AddRange(collection);
}
}
Log.Debug("drone name = " + ((Object)((EntityState)deathState).characterBody).name);
string text = list2[Run.instance.runRNG.RangeInt(0, list2.Count)];
if (text.Contains("{TIME}"))
{
string text2 = DateTime.Now.ToString("hh") + DateTime.Now.ToString("tt");
if (text2.StartsWith("0"))
{
text2 = text2.Substring(1, text2.Length - 1);
}
text = text.Replace("{TIME}", text2.ToLower());
}
text = text.Trim();
SimpleChatMessage val2 = new SimpleChatMessage();
val2.baseToken = "<style=cEvent>" + Language.GetStringFormatted(((EntityState)deathState).characterBody.baseNameToken, Array.Empty<object>()) + ": " + text + "</style>";
Chat.SendBroadcastChat((ChatMessageBase)(object)val2);
}
});
Log.Debug("added tracker to dead drones !!");
}
private void Update()
{
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
public class SpriteLoading
{
public static void ChangeSprites()
{
if (DroneRepairBeacon.droneSprites.Value != "")
{
string[] array = DroneRepairBeacon.droneSprites.Value.Split(",");
foreach (string text in array)
{
if (DroneRepairBeacon.assetbundle.Contains(text.Trim()))
{
DroneRepairBeacon.droneIndicatorSprites.Add(DroneRepairBeacon.assetbundle.LoadAsset<Sprite>(text.Trim()));
}
else
{
Log.Error("couldnt find sprite " + text.Trim() + " in asset bundle !!");
}
}
}
if (DroneRepairBeacon.customDroneSprites.Value)
{
string text2 = Path.Combine(Path.GetDirectoryName(Paths.ConfigPath), "config", "DroneBeacon");
if (!Directory.Exists(text2))
{
Directory.CreateDirectory(text2);
}
string text3 = Path.Combine(text2, "Specific");
if (!Directory.Exists(text3))
{
Directory.CreateDirectory(text3);
}
string[] array = Directory.GetFiles(text2, "*.*", SearchOption.AllDirectories);
foreach (string text4 in array)
{
string text5 = Path.Combine(text2, text4.Trim());
if (!text5.EndsWith(".png"))
{
Log.Debug("file " + text5 + " does not end in png ,..,,. skipping !!");
continue;
}
Sprite val = LoadSpriteFromFile(text5);
if ((Object)(object)val != (Object)null)
{
((Object)val).name = text4.Replace(".png", "").Split("\\").Last();
if (text5.Contains(text3))
{
Log.Debug($"specific sprite {val}!!!!!!");
DroneRepairBeacon.specificDroneIndicatorSprites.Add(val);
}
else
{
Log.Debug($"regualr sprite {val}!!!!!!");
DroneRepairBeacon.droneIndicatorSprites.Add(val);
}
}
else
{
Log.Error("couldnt find sprite " + text5.Trim() + " in files !!");
}
}
}
DroneRepairBeacon.droneIndicatorMaterials = (Material[])(object)new Material[DroneRepairBeacon.droneIndicatorSprites.Count];
for (int j = 0; j < DroneRepairBeacon.droneIndicatorMaterials.Length; j++)
{
DroneRepairBeacon.droneIndicatorMaterials[j] = Object.Instantiate<Material>(DroneRepairBeacon.baseMat);
((Object)DroneRepairBeacon.droneIndicatorMaterials[j]).name = ((Object)DroneRepairBeacon.droneIndicatorSprites[j]).name;
DroneRepairBeacon.droneIndicatorMaterials[j].SetTexture("_EmTex", (Texture)(object)DroneRepairBeacon.droneIndicatorSprites[j].texture);
}
DroneRepairBeacon.specificDroneIndicatorMaterials = (Material[])(object)new Material[DroneRepairBeacon.specificDroneIndicatorSprites.Count];
for (int k = 0; k < DroneRepairBeacon.specificDroneIndicatorMaterials.Length; k++)
{
DroneRepairBeacon.specificDroneIndicatorMaterials[k] = Object.Instantiate<Material>(DroneRepairBeacon.baseMat);
((Object)DroneRepairBeacon.specificDroneIndicatorMaterials[k]).name = ((Object)DroneRepairBeacon.specificDroneIndicatorSprites[k]).name;
DroneRepairBeacon.specificDroneIndicatorMaterials[k].SetTexture("_EmTex", (Texture)(object)DroneRepairBeacon.specificDroneIndicatorSprites[k].texture);
}
}
private static Sprite LoadSpriteFromFile(string path)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0048: 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)
if (string.IsNullOrEmpty(path) || !File.Exists(path))
{
return null;
}
int num = 100;
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(100, num, (TextureFormat)3, false);
ImageConversion.LoadImage(val, array);
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
}
}