using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("zabu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabumod")]
[assembly: AssemblyTitle("zabumod")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace REPOJP.DroneEffectAuraOverlay
{
[BepInPlugin("REPOJP.DroneEffectAuraOverlay", "DroneEffectAuraOverlay", "1.0.0")]
public sealed class DroneEffectAuraOverlayPlugin : BaseUnityPlugin
{
private enum AuraAnimationMode
{
Ink,
Gradient
}
private enum TargetKind
{
Unknown,
Player,
Enemy,
PhysObject
}
private sealed class ActiveTargetInfo
{
public int TargetId;
public TargetKind Kind;
public PlayerAvatar PlayerAvatar;
public EnemyParent EnemyParent;
public PhysGrabObject PhysGrabObject;
public string TargetName;
public List<Color> SourceColors;
public List<string> SourceNames;
}
private sealed class TargetVisualState
{
public int TargetId;
public TargetKind Kind;
public string TargetName;
public GameObject RootObject;
public readonly List<Renderer> Renderers = new List<Renderer>();
public readonly List<MaterialState> MaterialStates = new List<MaterialState>();
public readonly List<OverlayCloneState> CloneStates = new List<OverlayCloneState>();
}
private sealed class MaterialState
{
public Renderer Renderer;
public Material Material;
public int MaterialIndex;
public bool HasColorOverlay;
public bool HasColorOverlayAmount;
public bool HasEmissionColor;
public bool HasBaseColor;
public bool HasColor;
public bool HasAlbedoColor;
public Color OriginalColorOverlay;
public float OriginalColorOverlayAmount;
public Color OriginalEmissionColor;
public Color OriginalBaseColor;
public Color OriginalColor;
public Color OriginalAlbedoColor;
public bool EmissionKeywordEnabled;
}
private sealed class OverlayCloneState
{
public Renderer SourceRenderer;
public GameObject CloneObject;
public Renderer CloneRenderer;
public Material[] CloneMaterials;
}
private sealed class OverlayCloneMarker : MonoBehaviour
{
}
public const string PluginGuid = "REPOJP.DroneEffectAuraOverlay";
public const string PluginName = "DroneEffectAuraOverlay";
public const string PluginVersion = "1.0.0";
private ConfigEntry<bool> CfgEnableMod;
private ConfigEntry<float> CfgOverlayAlpha;
private ConfigEntry<float> CfgEmissionStrength;
private ConfigEntry<float> CfgUpdateIntervalSeconds;
private ConfigEntry<float> CfgRescanIntervalSeconds;
private ConfigEntry<string> CfgAnimationMode;
private ConfigEntry<bool> CfgUseOriginalMaterialOverlay;
private ConfigEntry<bool> CfgUseOverlayCloneRenderer;
private ConfigEntry<bool> CfgDebugLog;
private readonly Dictionary<int, TargetVisualState> targetStates = new Dictionary<int, TargetVisualState>();
private readonly Dictionary<int, string> lastSourceLogSignature = new Dictionary<int, string>();
private readonly Dictionary<string, float> rateLimitedLogTime = new Dictionary<string, float>();
private Shader overlayShader;
private float updateTimer;
private float rescanTimer;
private static FieldInfo FI_ItemOrb_objectAffected;
private static readonly int PropColorOverlay = Shader.PropertyToID("_ColorOverlay");
private static readonly int PropColorOverlayAmount = Shader.PropertyToID("_ColorOverlayAmount");
private static readonly int PropEmissionColor = Shader.PropertyToID("_EmissionColor");
private static readonly int PropBaseColor = Shader.PropertyToID("_BaseColor");
private static readonly int PropColor = Shader.PropertyToID("_Color");
private static readonly int PropAlbedoColor = Shader.PropertyToID("_AlbedoColor");
private void Awake()
{
try
{
((Component)this).transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)20;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
InitializeConfig();
InitializeReflection();
overlayShader = FindBestOverlayShader();
LogInfo("Loaded DroneEffectAuraOverlay v1.0.0");
if ((Object)(object)overlayShader != (Object)null)
{
LogInfo("Overlay shader: " + ((Object)overlayShader).name);
}
else
{
LogWarning("Overlay shader not found. Clone overlay will be skipped");
}
}
catch (Exception arg)
{
Debug.LogError((object)string.Format("[{0}] Awake failure\n{1}", "DroneEffectAuraOverlay", arg));
}
}
private void InitializeConfig()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Expected O, but got Unknown
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Expected O, but got Unknown
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Expected O, but got Unknown
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Expected O, but got Unknown
CfgEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("A General", "EnableMod", true, new ConfigDescription("Enable or disable this mod.このMODの有効無効", (AcceptableValueBase)null, Array.Empty<object>()));
CfgOverlayAlpha = ((BaseUnityPlugin)this).Config.Bind<float>("A General", "OverlayAlpha", 0.55f, new ConfigDescription("Overlay alpha for all drone and orb effects.全droneおよびオーブ効果オーバーレイの透明度", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
CfgEmissionStrength = ((BaseUnityPlugin)this).Config.Bind<float>("A General", "EmissionStrength", 5f, new ConfigDescription("Emission multiplier used when materials support emission.発光対応マテリアルに乗せる発光強度", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
CfgUpdateIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("A General", "UpdateIntervalSeconds", 0.05f, new ConfigDescription("How often target detection and visual updates run.対象検出と見た目更新の実行間隔秒", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>()));
CfgRescanIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("A General", "RescanIntervalSeconds", 1f, new ConfigDescription("How often renderer lists are rebuilt for active targets.アクティブ対象のRenderer一覧を再構築する間隔秒", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
CfgAnimationMode = ((BaseUnityPlugin)this).Config.Bind<string>("A General", "AnimationMode", "Gradient", new ConfigDescription("Animation mode selection. Ink / Gradient.アニメーションモード選択 Ink / Gradient", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Ink", "Gradient" }), Array.Empty<object>()));
CfgUseOriginalMaterialOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("A Fallback Paths", "UseOriginalMaterialOverlay", true, new ConfigDescription("Apply color/emission to original materials when supported.対応プロパティがある元マテリアルへ色と発光も適用", (AcceptableValueBase)null, Array.Empty<object>()));
CfgUseOverlayCloneRenderer = ((BaseUnityPlugin)this).Config.Bind<bool>("A Fallback Paths", "UseOverlayCloneRenderer", true, new ConfigDescription("Create dedicated transparent overlay clone renderers.専用透明オーバーレイクローンRenderer生成", (AcceptableValueBase)null, Array.Empty<object>()));
CfgDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Z Debug", "DebugLog", false, new ConfigDescription("Enable debug logs for target detection and visual application.対象検出と見た目適用のデバッグログ", (AcceptableValueBase)null, Array.Empty<object>()));
}
private void InitializeReflection()
{
FI_ItemOrb_objectAffected = AccessTools.Field(typeof(ItemOrb), "objectAffected");
}
private void Update()
{
try
{
if (!CfgEnableMod.Value)
{
RestoreAllTargets();
return;
}
updateTimer -= Time.unscaledDeltaTime;
rescanTimer -= Time.unscaledDeltaTime;
if (updateTimer > 0f)
{
return;
}
updateTimer = Mathf.Max(0.01f, CfgUpdateIntervalSeconds.Value);
bool forceRescan = false;
if (rescanTimer <= 0f)
{
rescanTimer = Mathf.Max(0.1f, CfgRescanIntervalSeconds.Value);
forceRescan = true;
}
Dictionary<int, ActiveTargetInfo> dictionary = CollectActiveTargets();
List<int> list = targetStates.Keys.ToList();
foreach (int item in list)
{
if (!dictionary.ContainsKey(item))
{
RestoreTarget(item, removeFromDictionary: true);
}
}
foreach (KeyValuePair<int, ActiveTargetInfo> item2 in dictionary)
{
EnsureTargetState(item2.Value, forceRescan);
UpdateTargetVisual(item2.Value);
}
}
catch (Exception ex)
{
RateLimitedError("UpdateLoop", ex);
}
}
private void OnDestroy()
{
try
{
RestoreAllTargets();
}
catch (Exception arg)
{
Debug.LogError((object)string.Format("[{0}] OnDestroy failure\n{1}", "DroneEffectAuraOverlay", arg));
}
}
private void RestoreAllTargets()
{
List<int> list = targetStates.Keys.ToList();
foreach (int item in list)
{
RestoreTarget(item, removeFromDictionary: false);
}
}
private void RestoreTarget(int targetId, bool removeFromDictionary)
{
if (!targetStates.TryGetValue(targetId, out TargetVisualState value))
{
return;
}
try
{
foreach (MaterialState materialState in value.MaterialStates)
{
if (materialState != null && !((Object)(object)materialState.Material == (Object)null))
{
RestoreMaterial(materialState);
}
}
foreach (OverlayCloneState cloneState in value.CloneStates)
{
if (cloneState != null && (Object)(object)cloneState.CloneObject != (Object)null)
{
Object.Destroy((Object)(object)cloneState.CloneObject);
}
}
if (CfgDebugLog.Value)
{
LogInfo($"Restore target [{value.TargetName}] kind={value.Kind} renderers={value.Renderers.Count} materials={value.MaterialStates.Count}");
}
}
catch (Exception ex)
{
RateLimitedError($"RestoreTarget:{targetId}", ex);
}
if (removeFromDictionary)
{
targetStates.Remove(targetId);
}
}
private Dictionary<int, ActiveTargetInfo> CollectActiveTargets()
{
Dictionary<int, ActiveTargetInfo> dictionary = new Dictionary<int, ActiveTargetInfo>();
CollectActiveTargetsFromDrones(dictionary);
CollectActiveTargetsFromZeroGravityOrbs(dictionary);
return dictionary;
}
private void CollectActiveTargetsFromDrones(Dictionary<int, ActiveTargetInfo> results)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
ItemDrone[] array = Object.FindObjectsByType<ItemDrone>((FindObjectsInactive)0, (FindObjectsSortMode)0);
ItemDrone[] array2 = array;
foreach (ItemDrone val in array2)
{
try
{
if ((Object)(object)val == (Object)null)
{
continue;
}
if (!val.itemActivated || !val.magnetActive)
{
MaybeLogSourceState(((Object)val).GetInstanceID(), "Drone:" + GetDroneTypeName(val), "inactive", val.droneColor);
continue;
}
Color val2 = SafeNormalizeColor(val.droneColor);
PlayerAvatar val3 = null;
if ((Object)(object)val.playerTumbleTarget != (Object)null && (Object)(object)val.playerTumbleTarget.playerAvatar != (Object)null)
{
val3 = val.playerTumbleTarget.playerAvatar;
}
else if ((Object)(object)val.playerAvatarTarget != (Object)null)
{
val3 = val.playerAvatarTarget;
}
if ((Object)(object)val3 != (Object)null)
{
AddOrUpdateTarget(results, ((Object)val3).GetInstanceID(), TargetKind.Player, BuildTargetName((Component)(object)val3), val2, "Drone:" + GetDroneTypeName(val), val3);
MaybeLogSourceState(((Object)val).GetInstanceID(), "Drone:" + GetDroneTypeName(val), "player:" + BuildTargetName((Component)(object)val3), val2);
}
else if ((Object)(object)val.magnetTargetPhysGrabObject != (Object)null)
{
PhysGrabObject magnetTargetPhysGrabObject = val.magnetTargetPhysGrabObject;
EnemyParent componentInParent = ((Component)magnetTargetPhysGrabObject).GetComponentInParent<EnemyParent>();
if ((Object)(object)componentInParent != (Object)null)
{
AddOrUpdateTarget(results, ((Object)componentInParent).GetInstanceID(), TargetKind.Enemy, BuildTargetName((Component)(object)componentInParent), val2, "Drone:" + GetDroneTypeName(val), null, componentInParent);
MaybeLogSourceState(((Object)val).GetInstanceID(), "Drone:" + GetDroneTypeName(val), "enemy:" + BuildTargetName((Component)(object)componentInParent), val2);
}
else
{
AddOrUpdateTarget(results, ((Object)magnetTargetPhysGrabObject).GetInstanceID(), TargetKind.PhysObject, BuildTargetName((Component)(object)magnetTargetPhysGrabObject), val2, "Drone:" + GetDroneTypeName(val), null, null, magnetTargetPhysGrabObject);
MaybeLogSourceState(((Object)val).GetInstanceID(), "Drone:" + GetDroneTypeName(val), "phys:" + BuildTargetName((Component)(object)magnetTargetPhysGrabObject), val2);
}
}
}
catch (Exception ex)
{
RateLimitedError("CollectActiveTargetsFromDrones:" + (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID().ToString() : "null"), ex);
}
}
}
private void CollectActiveTargetsFromZeroGravityOrbs(Dictionary<int, ActiveTargetInfo> results)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
ItemOrbZeroGravity[] array = Object.FindObjectsByType<ItemOrbZeroGravity>((FindObjectsInactive)0, (FindObjectsSortMode)0);
ItemOrbZeroGravity[] array2 = array;
foreach (ItemOrbZeroGravity val in array2)
{
try
{
if ((Object)(object)val == (Object)null)
{
continue;
}
ItemOrb component = ((Component)val).GetComponent<ItemOrb>();
if ((Object)(object)component == (Object)null)
{
continue;
}
if (!component.itemActive)
{
MaybeLogSourceState(((Object)val).GetInstanceID(), "Orb:ItemOrbZeroGravity", "inactive", component.orbColor);
continue;
}
Color val2 = SafeNormalizeColor(component.orbColor);
IList itemOrbAffectedObjects = GetItemOrbAffectedObjects(component);
if (itemOrbAffectedObjects == null)
{
continue;
}
int num = 0;
foreach (object item in itemOrbAffectedObjects)
{
PhysGrabObject val3 = (PhysGrabObject)((item is PhysGrabObject) ? item : null);
if (!((Object)(object)val3 == (Object)null))
{
num++;
EnemyParent componentInParent = ((Component)val3).GetComponentInParent<EnemyParent>();
if ((Object)(object)componentInParent != (Object)null)
{
AddOrUpdateTarget(results, ((Object)componentInParent).GetInstanceID(), TargetKind.Enemy, BuildTargetName((Component)(object)componentInParent), val2, "Orb:ItemOrbZeroGravity", null, componentInParent);
}
else
{
AddOrUpdateTarget(results, ((Object)val3).GetInstanceID(), TargetKind.PhysObject, BuildTargetName((Component)(object)val3), val2, "Orb:ItemOrbZeroGravity", null, null, val3);
}
}
}
if (CfgDebugLog.Value)
{
RateLimitedInfo($"OrbDetect:{((Object)val).GetInstanceID()}", $"Orb detect [{((Object)((Component)val).gameObject).name}#{((Object)val).GetInstanceID()}] affected={num} color=({val2.r:F2},{val2.g:F2},{val2.b:F2})");
}
}
catch (Exception ex)
{
RateLimitedError("CollectActiveTargetsFromZeroGravityOrbs:" + (((Object)(object)val != (Object)null) ? ((Object)val).GetInstanceID().ToString() : "null"), ex);
}
}
}
private IList GetItemOrbAffectedObjects(ItemOrb itemOrb)
{
try
{
if ((Object)(object)itemOrb == (Object)null || FI_ItemOrb_objectAffected == null)
{
return null;
}
return FI_ItemOrb_objectAffected.GetValue(itemOrb) as IList;
}
catch (Exception ex)
{
RateLimitedError("GetItemOrbAffectedObjects", ex);
return null;
}
}
private void AddOrUpdateTarget(Dictionary<int, ActiveTargetInfo> results, int targetId, TargetKind kind, string targetName, Color sourceColor, string sourceName, PlayerAvatar playerAvatar = null, EnemyParent enemyParent = null, PhysGrabObject physGrabObject = null)
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!results.TryGetValue(targetId, out ActiveTargetInfo value))
{
value = (results[targetId] = new ActiveTargetInfo
{
TargetId = targetId,
Kind = kind,
TargetName = targetName,
PlayerAvatar = playerAvatar,
EnemyParent = enemyParent,
PhysGrabObject = physGrabObject,
SourceColors = new List<Color>(),
SourceNames = new List<string>()
});
}
value.Kind = kind;
value.TargetName = targetName;
if ((Object)(object)playerAvatar != (Object)null)
{
value.PlayerAvatar = playerAvatar;
}
if ((Object)(object)enemyParent != (Object)null)
{
value.EnemyParent = enemyParent;
}
if ((Object)(object)physGrabObject != (Object)null)
{
value.PhysGrabObject = physGrabObject;
}
value.SourceColors.Add(sourceColor);
value.SourceNames.Add(sourceName);
}
private void EnsureTargetState(ActiveTargetInfo info, bool forceRescan)
{
if (!targetStates.TryGetValue(info.TargetId, out TargetVisualState value))
{
value = new TargetVisualState
{
TargetId = info.TargetId,
Kind = info.Kind,
TargetName = info.TargetName
};
targetStates[info.TargetId] = value;
}
value.Kind = info.Kind;
value.TargetName = info.TargetName;
bool flag = forceRescan || value.Renderers.Count == 0 || (Object)(object)value.RootObject == (Object)null;
if (!flag)
{
for (int num = value.Renderers.Count - 1; num >= 0; num--)
{
if ((Object)(object)value.Renderers[num] == (Object)null)
{
flag = true;
break;
}
}
}
if (flag)
{
RebuildTargetState(value, info);
}
}
private void RebuildTargetState(TargetVisualState state, ActiveTargetInfo info)
{
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: 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)
foreach (OverlayCloneState cloneState in state.CloneStates)
{
if (cloneState != null && (Object)(object)cloneState.CloneObject != (Object)null)
{
Object.Destroy((Object)(object)cloneState.CloneObject);
}
}
foreach (MaterialState materialState2 in state.MaterialStates)
{
if (materialState2 != null && (Object)(object)materialState2.Material != (Object)null)
{
RestoreMaterial(materialState2);
}
}
state.Renderers.Clear();
state.MaterialStates.Clear();
state.CloneStates.Clear();
state.RootObject = null;
GameObject rootObject;
List<Renderer> list = CollectTargetRenderers(info, out rootObject);
state.RootObject = rootObject;
foreach (Renderer item in list)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
state.Renderers.Add(item);
Material[] array = SafeGetRendererMaterials(item);
for (int i = 0; i < array.Length; i++)
{
Material val = array[i];
if (!((Object)(object)val == (Object)null))
{
MaterialState materialState = new MaterialState
{
Renderer = item,
Material = val,
MaterialIndex = i,
HasColorOverlay = val.HasProperty(PropColorOverlay),
HasColorOverlayAmount = val.HasProperty(PropColorOverlayAmount),
HasEmissionColor = val.HasProperty(PropEmissionColor),
HasBaseColor = val.HasProperty(PropBaseColor),
HasColor = val.HasProperty(PropColor),
HasAlbedoColor = val.HasProperty(PropAlbedoColor),
EmissionKeywordEnabled = val.IsKeywordEnabled("_EMISSION")
};
if (materialState.HasColorOverlay)
{
materialState.OriginalColorOverlay = val.GetColor(PropColorOverlay);
}
if (materialState.HasColorOverlayAmount)
{
materialState.OriginalColorOverlayAmount = val.GetFloat(PropColorOverlayAmount);
}
if (materialState.HasEmissionColor)
{
materialState.OriginalEmissionColor = val.GetColor(PropEmissionColor);
}
if (materialState.HasBaseColor)
{
materialState.OriginalBaseColor = val.GetColor(PropBaseColor);
}
if (materialState.HasColor)
{
materialState.OriginalColor = val.GetColor(PropColor);
}
if (materialState.HasAlbedoColor)
{
materialState.OriginalAlbedoColor = val.GetColor(PropAlbedoColor);
}
state.MaterialStates.Add(materialState);
}
}
if (CfgUseOverlayCloneRenderer.Value && (Object)(object)overlayShader != (Object)null)
{
OverlayCloneState overlayCloneState = CreateOverlayClone(item);
if (overlayCloneState != null)
{
state.CloneStates.Add(overlayCloneState);
}
}
}
if (CfgDebugLog.Value)
{
LogInfo(string.Format("Build target [{0}] kind={1} root={2} renderers={3} materials={4} clones={5}", state.TargetName, state.Kind, ((Object)(object)state.RootObject != (Object)null) ? ((Object)state.RootObject).name : "null", state.Renderers.Count, state.MaterialStates.Count, state.CloneStates.Count));
}
}
private void UpdateTargetVisual(ActiveTargetInfo info)
{
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: 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_00e8: 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)
if (!targetStates.TryGetValue(info.TargetId, out TargetVisualState value))
{
return;
}
AuraAnimationMode auraAnimationMode = ParseAnimationMode(CfgAnimationMode.Value);
float baseAlpha = Mathf.Clamp01(CfgOverlayAlpha.Value);
float emissionStrength = Mathf.Max(0f, CfgEmissionStrength.Value);
List<Color> list = NormalizeColorList(info.SourceColors);
if (list.Count == 0)
{
return;
}
if (CfgUseOriginalMaterialOverlay.Value)
{
for (int i = 0; i < value.MaterialStates.Count; i++)
{
MaterialState materialState = value.MaterialStates[i];
if (materialState != null && !((Object)(object)materialState.Material == (Object)null))
{
float rendererFlowCoordinate = GetRendererFlowCoordinate(materialState.Renderer);
Color color = EvaluateAnimatedColor(list, auraAnimationMode, i, Time.unscaledTime, rendererFlowCoordinate);
float alpha = EvaluateAnimatedAlpha(baseAlpha, auraAnimationMode, i, Time.unscaledTime, rendererFlowCoordinate);
ApplyOriginalMaterial(materialState, color, alpha, emissionStrength);
}
}
}
for (int j = 0; j < value.CloneStates.Count; j++)
{
OverlayCloneState overlayCloneState = value.CloneStates[j];
if (overlayCloneState != null && !((Object)(object)overlayCloneState.CloneRenderer == (Object)null))
{
float rendererFlowCoordinate2 = GetRendererFlowCoordinate(overlayCloneState.SourceRenderer);
Color color2 = EvaluateAnimatedColor(list, auraAnimationMode, j, Time.unscaledTime, rendererFlowCoordinate2);
float alpha2 = EvaluateAnimatedAlpha(baseAlpha, auraAnimationMode, j, Time.unscaledTime, rendererFlowCoordinate2);
ApplyCloneMaterial(overlayCloneState, color2, alpha2);
}
}
if (CfgDebugLog.Value)
{
string text = string.Join(", ", list.Select((Color c) => $"({c.r:F2},{c.g:F2},{c.b:F2})").ToArray());
string text2 = string.Join(", ", info.SourceNames.Distinct().ToArray());
RateLimitedInfo($"Apply:{info.TargetId}", $"Apply target [{info.TargetName}] kind={info.Kind} mode={auraAnimationMode} sources={text2} colors={text} renderers={value.Renderers.Count} materials={value.MaterialStates.Count} clones={value.CloneStates.Count}");
}
}
private void ApplyOriginalMaterial(MaterialState ms, Color color, float alpha, float emissionStrength)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
Material material = ms.Material;
if (!((Object)(object)material == (Object)null))
{
if (ms.HasColorOverlay)
{
material.SetColor(PropColorOverlay, color);
}
if (ms.HasColorOverlayAmount)
{
material.SetFloat(PropColorOverlayAmount, alpha);
}
if (ms.HasBaseColor)
{
Color val = Color.Lerp(ms.OriginalBaseColor, color, alpha * 0.35f);
val.a = ms.OriginalBaseColor.a;
material.SetColor(PropBaseColor, val);
}
if (ms.HasColor)
{
Color val2 = Color.Lerp(ms.OriginalColor, color, alpha * 0.25f);
val2.a = ms.OriginalColor.a;
material.SetColor(PropColor, val2);
}
if (ms.HasAlbedoColor)
{
Color val3 = Color.Lerp(ms.OriginalAlbedoColor, color, alpha * 0.25f);
val3.a = ms.OriginalAlbedoColor.a;
material.SetColor(PropAlbedoColor, val3);
}
if (ms.HasEmissionColor)
{
material.EnableKeyword("_EMISSION");
Color val4 = color * Mathf.Lerp(0.5f, 2f, alpha) * emissionStrength;
material.SetColor(PropEmissionColor, val4);
}
}
}
private void ApplyCloneMaterial(OverlayCloneState clone, Color color, float alpha)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
if (clone.CloneMaterials == null)
{
return;
}
for (int i = 0; i < clone.CloneMaterials.Length; i++)
{
Material val = clone.CloneMaterials[i];
if (!((Object)(object)val == (Object)null))
{
Color val2 = color;
val2.a = alpha;
if (val.HasProperty(PropColor))
{
val.SetColor(PropColor, val2);
}
if (val.HasProperty(PropBaseColor))
{
val.SetColor(PropBaseColor, val2);
}
if (val.HasProperty(PropEmissionColor))
{
val.EnableKeyword("_EMISSION");
val.SetColor(PropEmissionColor, new Color(val2.r, val2.g, val2.b, 1f) * Mathf.Lerp(0.25f, 1.5f, alpha));
}
}
}
}
private OverlayCloneState CreateOverlayClone(Renderer sourceRenderer)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)sourceRenderer == (Object)null)
{
return null;
}
if ((Object)(object)((Component)sourceRenderer).GetComponent<OverlayCloneMarker>() != (Object)null)
{
return null;
}
if (sourceRenderer is ParticleSystemRenderer)
{
return null;
}
GameObject val = new GameObject(((Object)((Component)sourceRenderer).gameObject).name + "_DroneAuraOverlay");
((Object)val).hideFlags = (HideFlags)20;
val.transform.SetParent(((Component)sourceRenderer).transform, false);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = Vector3.one;
val.layer = ((Component)sourceRenderer).gameObject.layer;
val.AddComponent<OverlayCloneMarker>();
Renderer val2 = null;
Material[] array = null;
MeshRenderer val3 = (MeshRenderer)(object)((sourceRenderer is MeshRenderer) ? sourceRenderer : null);
if ((Object)(object)val3 != (Object)null)
{
MeshFilter component = ((Component)sourceRenderer).GetComponent<MeshFilter>();
if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null)
{
Object.Destroy((Object)(object)val);
return null;
}
MeshFilter val4 = val.AddComponent<MeshFilter>();
val4.sharedMesh = component.sharedMesh;
MeshRenderer val5 = val.AddComponent<MeshRenderer>();
val2 = (Renderer)(object)val5;
array = (((Renderer)val5).sharedMaterials = BuildOverlayMaterialArray((((Renderer)val3).sharedMaterials == null) ? 1 : ((Renderer)val3).sharedMaterials.Length));
CopyRendererCommonSettings(sourceRenderer, (Renderer)(object)val5);
}
SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)(object)((sourceRenderer is SkinnedMeshRenderer) ? sourceRenderer : null);
if ((Object)(object)val6 != (Object)null)
{
if ((Object)(object)val6.sharedMesh == (Object)null)
{
Object.Destroy((Object)(object)val);
return null;
}
SkinnedMeshRenderer val7 = val.AddComponent<SkinnedMeshRenderer>();
val2 = (Renderer)(object)val7;
array = BuildOverlayMaterialArray((((Renderer)val6).sharedMaterials == null) ? 1 : ((Renderer)val6).sharedMaterials.Length);
val7.sharedMesh = val6.sharedMesh;
val7.rootBone = val6.rootBone;
val7.bones = val6.bones;
((Renderer)val7).localBounds = ((Renderer)val6).localBounds;
val7.updateWhenOffscreen = true;
val7.quality = val6.quality;
val7.skinnedMotionVectors = false;
((Renderer)val7).sharedMaterials = array;
CopyRendererCommonSettings(sourceRenderer, (Renderer)(object)val7);
}
if ((Object)(object)val2 == (Object)null || array == null)
{
Object.Destroy((Object)(object)val);
return null;
}
return new OverlayCloneState
{
SourceRenderer = sourceRenderer,
CloneObject = val,
CloneRenderer = val2,
CloneMaterials = array
};
}
catch (Exception ex)
{
RateLimitedError("CreateOverlayClone:" + (((Object)(object)sourceRenderer != (Object)null) ? ((Object)sourceRenderer).GetInstanceID().ToString() : "null"), ex);
return null;
}
}
private void CopyRendererCommonSettings(Renderer source, Renderer dest)
{
dest.shadowCastingMode = (ShadowCastingMode)0;
dest.receiveShadows = false;
dest.lightProbeUsage = (LightProbeUsage)0;
dest.reflectionProbeUsage = (ReflectionProbeUsage)0;
dest.motionVectorGenerationMode = (MotionVectorGenerationMode)2;
dest.allowOcclusionWhenDynamic = false;
dest.enabled = source.enabled;
Material[] sharedMaterials = dest.sharedMaterials;
for (int i = 0; i < sharedMaterials.Length; i++)
{
if ((Object)(object)sharedMaterials[i] != (Object)null)
{
sharedMaterials[i].renderQueue = 3100 + i;
}
}
dest.sharedMaterials = sharedMaterials;
}
private Material[] BuildOverlayMaterialArray(int count)
{
int num = Mathf.Max(1, count);
Material[] array = (Material[])(object)new Material[num];
for (int i = 0; i < num; i++)
{
array[i] = BuildOverlayMaterial();
}
return array;
}
private Material BuildOverlayMaterial()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
Shader val = (Shader)(((Object)(object)overlayShader != (Object)null) ? ((object)overlayShader) : ((object)Shader.Find("Standard")));
Material val2 = new Material(val);
((Object)val2).name = "DroneEffectAuraOverlayMaterial";
if ((Object)(object)val != (Object)null)
{
if (((Object)val).name == "Standard")
{
val2.SetFloat("_Mode", 3f);
val2.SetInt("_SrcBlend", 5);
val2.SetInt("_DstBlend", 10);
val2.SetInt("_ZWrite", 0);
val2.DisableKeyword("_ALPHATEST_ON");
val2.EnableKeyword("_ALPHABLEND_ON");
val2.DisableKeyword("_ALPHAPREMULTIPLY_ON");
val2.renderQueue = 3100;
}
else
{
val2.renderQueue = 3100;
}
}
Color val3 = default(Color);
((Color)(ref val3))..ctor(1f, 1f, 1f, 0.35f);
if (val2.HasProperty(PropColor))
{
val2.SetColor(PropColor, val3);
}
if (val2.HasProperty(PropBaseColor))
{
val2.SetColor(PropBaseColor, val3);
}
if (val2.HasProperty(PropEmissionColor))
{
val2.EnableKeyword("_EMISSION");
val2.SetColor(PropEmissionColor, Color.white * 0.5f);
}
return val2;
}
private Shader FindBestOverlayShader()
{
string[] array = new string[5] { "Standard", "Universal Render Pipeline/Unlit", "Unlit/Color", "Legacy Shaders/Transparent/Diffuse", "Sprites/Default" };
string[] array2 = array;
foreach (string text in array2)
{
Shader val = Shader.Find(text);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
private List<Renderer> CollectTargetRenderers(ActiveTargetInfo info, out GameObject rootObject)
{
rootObject = null;
HashSet<int> seen = new HashSet<int>();
List<Renderer> list = new List<Renderer>();
if (info.Kind == TargetKind.Player && (Object)(object)info.PlayerAvatar != (Object)null)
{
rootObject = ((Component)info.PlayerAvatar).gameObject;
if ((Object)(object)info.PlayerAvatar.playerHealth != (Object)null && (Object)(object)info.PlayerAvatar.playerHealth.meshParent != (Object)null)
{
AddRenderersFromRoot(((Component)info.PlayerAvatar.playerHealth.meshParent).gameObject, list, seen);
}
if ((Object)(object)info.PlayerAvatar.playerAvatarVisuals != (Object)null && (Object)(object)info.PlayerAvatar.playerAvatarVisuals.meshParent != (Object)null)
{
AddRenderersFromRoot(info.PlayerAvatar.playerAvatarVisuals.meshParent, list, seen);
}
if (list.Count == 0)
{
AddRenderersFromRoot(((Component)info.PlayerAvatar).gameObject, list, seen);
}
}
else if (info.Kind == TargetKind.Enemy && (Object)(object)info.EnemyParent != (Object)null)
{
rootObject = ((Component)info.EnemyParent).gameObject;
EnemyHealth componentInChildren = ((Component)info.EnemyParent).GetComponentInChildren<EnemyHealth>(true);
if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.meshParent != (Object)null)
{
AddRenderersFromRoot(((Component)componentInChildren.meshParent).gameObject, list, seen);
}
if (list.Count == 0)
{
Enemy componentInChildren2 = ((Component)info.EnemyParent).GetComponentInChildren<Enemy>(true);
if ((Object)(object)componentInChildren2 != (Object)null)
{
AddRenderersFromRoot(((Component)componentInChildren2).gameObject, list, seen);
}
}
if (list.Count == 0)
{
AddRenderersFromRoot(((Component)info.EnemyParent).gameObject, list, seen);
}
}
else if (info.Kind == TargetKind.PhysObject && (Object)(object)info.PhysGrabObject != (Object)null)
{
rootObject = ((Component)info.PhysGrabObject).gameObject;
AddRenderersFromRoot(((Component)info.PhysGrabObject).gameObject, list, seen);
if (IsZeroGravityOrbPhysObject(info.PhysGrabObject))
{
ExcludeZeroGravityOrbAreaEffectRenderers(list, info.PhysGrabObject);
}
}
return list;
}
private bool IsZeroGravityOrbPhysObject(PhysGrabObject physGrabObject)
{
if ((Object)(object)physGrabObject == (Object)null)
{
return false;
}
try
{
return (Object)(object)((Component)physGrabObject).GetComponent<ItemOrbZeroGravity>() != (Object)null || (Object)(object)((Component)physGrabObject).GetComponentInParent<ItemOrbZeroGravity>() != (Object)null || (Object)(object)((Component)physGrabObject).GetComponentInChildren<ItemOrbZeroGravity>(true) != (Object)null;
}
catch
{
return false;
}
}
private void ExcludeZeroGravityOrbAreaEffectRenderers(List<Renderer> renderers, PhysGrabObject physGrabObject)
{
if (renderers == null || renderers.Count == 0 || (Object)(object)physGrabObject == (Object)null)
{
return;
}
Transform areaEffect = ((Component)physGrabObject).transform.Find("sphere effect/AreaEffect");
if ((Object)(object)areaEffect == (Object)null)
{
ItemOrb component = ((Component)physGrabObject).GetComponent<ItemOrb>();
if ((Object)(object)component != (Object)null)
{
areaEffect = ((Component)component).transform.Find("sphere effect/AreaEffect");
}
}
if ((Object)(object)areaEffect == (Object)null)
{
if (CfgDebugLog.Value)
{
LogWarning($"ItemOrbZeroGravity AreaEffect path not found on [{((Object)((Component)physGrabObject).gameObject).name}#{((Object)physGrabObject).GetInstanceID()}]");
}
return;
}
int num = renderers.RemoveAll((Renderer renderer) => (Object)(object)renderer != (Object)null && (Object)(object)((Component)renderer).transform != (Object)null && ((Component)renderer).transform.IsChildOf(areaEffect));
if (CfgDebugLog.Value && num > 0)
{
LogInfo($"Exclude ItemOrbZeroGravity AreaEffect renderers [{((Object)((Component)physGrabObject).gameObject).name}#{((Object)physGrabObject).GetInstanceID()}] removed={num}");
}
}
private void AddRenderersFromRoot(GameObject root, List<Renderer> renderers, HashSet<int> seen)
{
if ((Object)(object)root == (Object)null)
{
return;
}
Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent<OverlayCloneMarker>() != (Object)null) && !(val is ParticleSystemRenderer) && !(val is LineRenderer) && ((Object)((Component)val).gameObject).name.IndexOf("particle", StringComparison.OrdinalIgnoreCase) < 0)
{
int instanceID = ((Object)val).GetInstanceID();
if (!seen.Contains(instanceID))
{
seen.Add(instanceID);
renderers.Add(val);
}
}
}
}
private void RestoreMaterial(MaterialState ms)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ms.Material == (Object)null)
{
return;
}
if (ms.HasColorOverlay)
{
ms.Material.SetColor(PropColorOverlay, ms.OriginalColorOverlay);
}
if (ms.HasColorOverlayAmount)
{
ms.Material.SetFloat(PropColorOverlayAmount, ms.OriginalColorOverlayAmount);
}
if (ms.HasEmissionColor)
{
ms.Material.SetColor(PropEmissionColor, ms.OriginalEmissionColor);
if (ms.EmissionKeywordEnabled)
{
ms.Material.EnableKeyword("_EMISSION");
}
else
{
ms.Material.DisableKeyword("_EMISSION");
}
}
if (ms.HasBaseColor)
{
ms.Material.SetColor(PropBaseColor, ms.OriginalBaseColor);
}
if (ms.HasColor)
{
ms.Material.SetColor(PropColor, ms.OriginalColor);
}
if (ms.HasAlbedoColor)
{
ms.Material.SetColor(PropAlbedoColor, ms.OriginalAlbedoColor);
}
}
private AuraAnimationMode ParseAnimationMode(string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return AuraAnimationMode.Ink;
}
if (Enum.TryParse<AuraAnimationMode>(value.Trim(), ignoreCase: true, out var result))
{
return result;
}
return AuraAnimationMode.Ink;
}
private Color EvaluateAnimatedColor(List<Color> colors, AuraAnimationMode mode, int index, float time, float flowCoord)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
if (colors == null || colors.Count == 0)
{
return Color.white;
}
if (colors.Count == 1)
{
return colors[0];
}
int count = colors.Count;
if (mode != 0 && mode == AuraAnimationMode.Gradient)
{
float num = Mathf.Repeat((0f - flowCoord) * 1.15f + time * 0.85f, (float)count);
int num2 = Mathf.FloorToInt(num) % count;
int index2 = (num2 + 1) % count;
float num3 = num - Mathf.Floor(num);
return Color.Lerp(colors[num2], colors[index2], num3);
}
float num4 = time * 1.9f + (float)index * 0.77f + flowCoord * 0.65f;
float num5 = Mathf.Sin(num4) * 0.5f + 0.5f;
int index3 = Mathf.Clamp(Mathf.FloorToInt(num5 * (float)count), 0, count - 1);
return colors[index3];
}
private float EvaluateAnimatedAlpha(float baseAlpha, AuraAnimationMode mode, int index, float time, float flowCoord)
{
baseAlpha = Mathf.Clamp01(baseAlpha);
if (mode != 0 && mode == AuraAnimationMode.Gradient)
{
return Mathf.Clamp01(baseAlpha * (0.82f + 0.18f * (Mathf.Sin(time * 1.7f + (float)index * 0.23f + flowCoord * 0.45f) * 0.5f + 0.5f)));
}
return Mathf.Clamp01(baseAlpha * (0.55f + 0.45f * (Mathf.Sin(time * 2.8f + (float)index * 0.59f + flowCoord * 0.35f) * 0.5f + 0.5f)));
}
private float GetRendererFlowCoordinate(Renderer renderer)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)renderer == (Object)null)
{
return 0f;
}
try
{
Bounds bounds = renderer.bounds;
return ((Bounds)(ref bounds)).center.y;
}
catch
{
return 0f;
}
}
private Material[] SafeGetRendererMaterials(Renderer renderer)
{
try
{
return ((Object)(object)renderer != (Object)null) ? renderer.materials : Array.Empty<Material>();
}
catch
{
return Array.Empty<Material>();
}
}
private List<Color> NormalizeColorList(List<Color> colors)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
List<Color> list = new List<Color>();
if (colors == null)
{
return list;
}
foreach (Color color2 in colors)
{
Color color = SafeNormalizeColor(color2);
if (!list.Any((Color x) => Mathf.Abs(x.r - color.r) < 0.01f && Mathf.Abs(x.g - color.g) < 0.01f && Mathf.Abs(x.b - color.b) < 0.01f))
{
list.Add(color);
}
}
return list;
}
private Color SafeNormalizeColor(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
return new Color(Mathf.Clamp01(color.r), Mathf.Clamp01(color.g), Mathf.Clamp01(color.b), 1f);
}
private string BuildTargetName(Component component)
{
if ((Object)(object)component == (Object)null)
{
return "null";
}
return ((Object)component.gameObject).name + "#" + ((Object)component).GetInstanceID();
}
private void MaybeLogSourceState(int sourceId, string sourceName, string state, Color color)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (CfgDebugLog.Value)
{
string text = $"{sourceName}|{state}|{color.r:F2},{color.g:F2},{color.b:F2}";
if (!lastSourceLogSignature.TryGetValue(sourceId, out string value) || !(value == text))
{
lastSourceLogSignature[sourceId] = text;
LogInfo($"Source detect [{sourceName}#{sourceId}] state={state} color=({color.r:F2},{color.g:F2},{color.b:F2})");
}
}
}
private string GetDroneTypeName(ItemDrone drone)
{
if ((Object)(object)drone == (Object)null)
{
return "null";
}
Component[] components = ((Component)drone).GetComponents<Component>();
Component[] array = components;
foreach (Component val in array)
{
if (!((Object)(object)val == (Object)null))
{
Type type = ((object)val).GetType();
if (type != typeof(ItemDrone) && type.Name.StartsWith("ItemDrone", StringComparison.Ordinal))
{
return type.Name;
}
}
}
return "ItemDrone";
}
private void LogInfo(string message)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)message);
}
private void LogWarning(string message)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)message);
}
private void RateLimitedInfo(string key, string message, float minInterval = 1f)
{
float unscaledTime = Time.unscaledTime;
if (!rateLimitedLogTime.TryGetValue("I:" + key, out var value) || !(unscaledTime - value < minInterval))
{
rateLimitedLogTime["I:" + key] = unscaledTime;
((BaseUnityPlugin)this).Logger.LogInfo((object)message);
}
}
private void RateLimitedError(string key, Exception ex, float minInterval = 1f)
{
float unscaledTime = Time.unscaledTime;
if (!rateLimitedLogTime.TryGetValue("E:" + key, out var value) || !(unscaledTime - value < minInterval))
{
rateLimitedLogTime["E:" + key] = unscaledTime;
((BaseUnityPlugin)this).Logger.LogError((object)$"{key}\n{ex}");
}
}
}
}