using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using BepInEx;
using Gungeon;
using HarmonyLib;
using ItemAPI;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ImposterItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImposterItems")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("840a947f-ee72-47cf-8335-d5437a8b149b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 ItemAPI
{
public static class CompanionBuilder
{
public enum AnimationType
{
Move,
Idle,
Fidget,
Flight,
Hit,
Talk,
Other
}
private static GameObject behaviorSpeculatorPrefab;
public static Dictionary<string, GameObject> companionDictionary = new Dictionary<string, GameObject>();
public static void Init()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
string companionGuid = ((Component)Game.Items["dog"]).GetComponent<CompanionItem>().CompanionGuid;
AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(companionGuid);
behaviorSpeculatorPrefab = Object.Instantiate<GameObject>(((Component)orLoadByGuid).gameObject);
foreach (Transform item in behaviorSpeculatorPrefab.transform)
{
Transform val = item;
if ((Object)(object)val != (Object)(object)behaviorSpeculatorPrefab.transform)
{
Object.DestroyImmediate((Object)(object)val);
}
}
Component[] components = behaviorSpeculatorPrefab.GetComponents<Component>();
foreach (Component val2 in components)
{
if ((object)((object)val2).GetType() != typeof(BehaviorSpeculator))
{
Object.DestroyImmediate((Object)(object)val2);
}
}
Object.DontDestroyOnLoad((Object)(object)behaviorSpeculatorPrefab);
FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab);
behaviorSpeculatorPrefab.SetActive(false);
Hook val3 = new Hook((MethodBase)typeof(EnemyDatabase).GetMethod("GetOrLoadByGuid", BindingFlags.Static | BindingFlags.Public), typeof(CompanionBuilder).GetMethod("GetOrLoadByGuid"));
}
public static AIActor GetOrLoadByGuid(Func<string, AIActor> orig, string guid)
{
foreach (string key in companionDictionary.Keys)
{
if (key == guid)
{
return companionDictionary[key].GetComponent<AIActor>();
}
}
return orig(guid);
}
public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
if (companionDictionary.ContainsKey(guid))
{
ETGModConsole.Log((object)"CompanionBuilder: Tried to create two companion prefabs with the same GUID!", false);
return null;
}
GameObject val = Object.Instantiate<GameObject>(behaviorSpeculatorPrefab);
((Object)val).name = name;
tk2dSprite component = SpriteBuilder.SpriteFromResource(defaultSpritePath, val).GetComponent<tk2dSprite>();
component.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = false;
val.AddComponent<tk2dSpriteAnimator>();
val.AddComponent<AIAnimator>();
HealthHaver val2 = val.AddComponent<HealthHaver>();
val2.RegisterBodySprite((tk2dBaseSprite)(object)component, false, 0);
val2.PreventAllDamage = true;
val2.SetHealthMaximum(15000f, (float?)null, false);
val2.FullHeal();
AIActor val3 = val.AddComponent<AIActor>();
val3.State = (ActorState)2;
val3.EnemyGuid = guid;
BehaviorSpeculator component2 = val.GetComponent<BehaviorSpeculator>();
component2.MovementBehaviors = new List<MovementBehaviorBase>();
component2.AttackBehaviors = new List<AttackBehaviorBase>();
component2.TargetBehaviors = new List<TargetBehaviorBase>();
component2.OverrideBehaviors = new List<OverrideBehaviorBase>();
component2.OtherBehaviors = new List<BehaviorBase>();
EnemyDatabaseEntry item = new EnemyDatabaseEntry
{
myGuid = guid,
placeableWidth = 2,
placeableHeight = 2,
isNormalEnemy = false
};
((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries.Add(item);
companionDictionary.Add(guid, val);
Object.DontDestroyOnLoad((Object)(object)val);
FakePrefab.MarkAsFakePrefab(val);
val.SetActive(false);
return val;
}
public static tk2dSpriteAnimationClip AddAnimation(this GameObject obj, string name, string spriteDirectory, int fps, AnimationType type, DirectionType directionType = 0, FlipType flipType = 0, bool assignAnimation = true)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected I4, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_003c: 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)
AIAnimator orAddComponent = GameObjectExtensions.GetOrAddComponent<AIAnimator>(obj);
DirectionalAnimation val = orAddComponent.GetDirectionalAnimation(name, directionType, type);
if (val == null)
{
DirectionalAnimation val2 = new DirectionalAnimation();
val2.AnimNames = new string[0];
val2.Flipped = (FlipType[])(object)new FlipType[0];
val2.Type = directionType;
val2.Prefix = string.Empty;
val = val2;
}
val.AnimNames = val.AnimNames.Concat(new string[1] { name }).ToArray();
val.Flipped = val.Flipped.Concat((IEnumerable<FlipType>)(object)new FlipType[1] { (FlipType)(int)flipType }).ToArray();
if (assignAnimation)
{
orAddComponent.AssignDirectionalAnimation(name, val, type);
}
return BuildAnimation(orAddComponent, name, spriteDirectory, fps);
}
public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps)
{
tk2dSpriteCollectionData val = ((Component)aiAnimator).GetComponent<tk2dSpriteCollectionData>();
if (!Object.op_Implicit((Object)(object)val))
{
val = SpriteBuilder.ConstructCollection(((Component)aiAnimator).gameObject, ((Object)aiAnimator).name + "_collection");
}
string[] resourceNames = ResourceExtractor.GetResourceNames();
List<int> list = new List<int>();
for (int i = 0; i < resourceNames.Length; i++)
{
if (resourceNames[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase))
{
list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], val));
}
}
tk2dSpriteAnimationClip val2 = SpriteBuilder.AddAnimation(((BraveBehaviour)aiAnimator).spriteAnimator, val, list, name, (WrapMode)0);
val2.fps = fps;
return val2;
}
public static DirectionalAnimation GetDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionType directionType, AnimationType type)
{
DirectionalAnimation val = null;
switch (type)
{
case AnimationType.Idle:
val = aiAnimator.IdleAnimation;
break;
case AnimationType.Move:
val = aiAnimator.MoveAnimation;
break;
case AnimationType.Flight:
val = aiAnimator.FlightAnimation;
break;
case AnimationType.Hit:
val = aiAnimator.HitAnimation;
break;
case AnimationType.Talk:
val = aiAnimator.TalkAnimation;
break;
}
if (val != null)
{
return val;
}
return null;
}
public static void AssignDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionalAnimation animation, AnimationType type)
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
switch (type)
{
case AnimationType.Idle:
aiAnimator.IdleAnimation = animation;
return;
case AnimationType.Move:
aiAnimator.MoveAnimation = animation;
return;
case AnimationType.Flight:
aiAnimator.FlightAnimation = animation;
return;
case AnimationType.Hit:
aiAnimator.HitAnimation = animation;
return;
case AnimationType.Talk:
aiAnimator.TalkAnimation = animation;
return;
case AnimationType.Fidget:
aiAnimator.IdleFidgetAnimations.Add(animation);
return;
}
if (aiAnimator.OtherAnimations == null)
{
aiAnimator.OtherAnimations = new List<NamedDirectionalAnimation>();
}
aiAnimator.OtherAnimations.Add(new NamedDirectionalAnimation
{
anim = animation,
name = name
});
}
}
public class FakePrefab : Component
{
internal static HashSet<GameObject> ExistingFakePrefabs = new HashSet<GameObject>();
public static bool IsFakePrefab(Object o)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (o is GameObject)
{
return ExistingFakePrefabs.Contains((GameObject)o);
}
if (o is Component)
{
return ExistingFakePrefabs.Contains(((Component)o).gameObject);
}
return false;
}
public static void MarkAsFakePrefab(GameObject obj)
{
ExistingFakePrefabs.Add(obj);
}
public static GameObject Clone(GameObject obj)
{
bool flag = IsFakePrefab((Object)(object)obj);
bool activeSelf = obj.activeSelf;
if (activeSelf)
{
obj.SetActive(false);
}
GameObject val = Object.Instantiate<GameObject>(obj);
if (activeSelf)
{
obj.SetActive(true);
}
ExistingFakePrefabs.Add(val);
if (flag)
{
}
return val;
}
public static Object Instantiate(Object o, Object new_o)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (o is GameObject && ExistingFakePrefabs.Contains((GameObject)o))
{
((GameObject)new_o).SetActive(true);
}
else if (o is Component && ExistingFakePrefabs.Contains(((Component)o).gameObject))
{
((Component)new_o).gameObject.SetActive(true);
}
return new_o;
}
}
public static class FakePrefabHooks
{
public delegate TResult Func<T1, T2, T3, T4, T5, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
public static void Init()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Expected O, but got Unknown
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
Hook val = new Hook((MethodBase)typeof(PlayerController).GetMethod("AcquirePassiveItemPrefabDirectly"), typeof(FakePrefabHooks).GetMethod("AcquirePassiveItemPrefabDirectly"));
Hook val2 = new Hook((MethodBase)typeof(PlayerItem).GetMethod("Pickup"), typeof(FakePrefabHooks).GetMethod("ActivePickup"));
Hook val3 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3]
{
typeof(Object),
typeof(Transform),
typeof(bool)
}), typeof(FakePrefabHooks).GetMethod("InstantiateOPI"));
Hook val4 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[2]
{
typeof(Object),
typeof(Transform)
}), typeof(FakePrefabHooks).GetMethod("InstantiateOP"));
Hook val5 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[1] { typeof(Object) }), typeof(FakePrefabHooks).GetMethod("InstantiateO"));
Hook val6 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3]
{
typeof(Object),
typeof(Vector3),
typeof(Quaternion)
}), typeof(FakePrefabHooks).GetMethod("InstantiateOPR"));
Hook val7 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[4]
{
typeof(Object),
typeof(Vector3),
typeof(Quaternion),
typeof(Transform)
}), typeof(FakePrefabHooks).GetMethod("InstantiateOPRP"));
}
public static void AcquirePassiveItemPrefabDirectly(Action<PlayerController, PassiveItem> orig, PlayerController self, PassiveItem item)
{
bool flag = FakePrefab.IsFakePrefab((Object)(object)((Component)item).gameObject);
if (flag)
{
((Component)item).gameObject.SetActive(true);
}
orig(self, item);
if (flag)
{
((Component)item).gameObject.SetActive(false);
}
}
public static void ActivePickup(Action<PlayerItem, PlayerController> orig, PlayerItem self, PlayerController player)
{
bool flag = FakePrefab.IsFakePrefab((Object)(object)((Component)self).gameObject);
if (flag)
{
((Component)self).gameObject.SetActive(true);
}
orig(self, player);
if (flag)
{
((Component)self).gameObject.SetActive(false);
}
}
public static Object InstantiateOPI(Func<Object, Transform, bool, Object> orig, Object original, Transform parent, bool instantiateInWorldSpace)
{
return FakePrefab.Instantiate(original, orig(original, parent, instantiateInWorldSpace));
}
public static Object InstantiateOP(Func<Object, Transform, Object> orig, Object original, Transform parent)
{
return FakePrefab.Instantiate(original, orig(original, parent));
}
public static Object InstantiateO(Func<Object, Object> orig, Object original)
{
return FakePrefab.Instantiate(original, orig(original));
}
public static Object InstantiateOPR(Func<Object, Vector3, Quaternion, Object> orig, Object original, Vector3 position, Quaternion rotation)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return FakePrefab.Instantiate(original, orig(original, position, rotation));
}
public static Object InstantiateOPRP(Func<Object, Vector3, Quaternion, Transform, Object> orig, Object original, Vector3 position, Quaternion rotation, Transform parent)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return FakePrefab.Instantiate(original, orig(original, position, rotation, parent));
}
}
public static class ItemBuilder
{
public enum CooldownType
{
Timed,
Damage,
PerRoom,
None
}
public enum ShopType
{
Goopton,
Flynt,
Cursula,
Trorc,
OldRed
}
public static Dictionary<ShopType, GenericLootTable> shopInventories;
public static void Init()
{
FakePrefabHooks.Init();
CompanionBuilder.Init();
LoadShopTables();
}
private static void LoadShopTables()
{
shopInventories = new Dictionary<ShopType, GenericLootTable>();
shopInventories.Add(ShopType.Flynt, LoadShopTable("Shop_Key_Items_01"));
shopInventories.Add(ShopType.Trorc, LoadShopTable("Shop_Truck_Items_01"));
shopInventories.Add(ShopType.Cursula, LoadShopTable("Shop_Curse_Items_01"));
shopInventories.Add(ShopType.Goopton, LoadShopTable("Shop_Goop_Items_01"));
shopInventories.Add(ShopType.OldRed, LoadShopTable("Shop_Blank_Items_01"));
}
public static GenericLootTable LoadShopTable(string assetName)
{
return ResourceManager.LoadAssetBundle("shared_auto_001").LoadAsset<GenericLootTable>(assetName);
}
public static GameObject AddSpriteToObject(string name, string resourcePath, GameObject obj = null)
{
GameObject val = SpriteBuilder.SpriteFromResource(resourcePath, obj);
FakePrefab.MarkAsFakePrefab(val);
obj.SetActive(false);
((Object)val).name = name;
return val;
}
public static void SetupItem(this PickupObject item, string shortDesc, string longDesc, string idPool = "ItemAPI")
{
try
{
((BraveBehaviour)item).encounterTrackable = null;
Databases.Items.SetupItem(item, ((Object)item).name);
SpriteBuilder.AddToAmmonomicon(((BraveBehaviour)item).sprite.GetCurrentSpriteDef());
((BraveBehaviour)item).encounterTrackable.journalData.AmmonomiconSprite = ((BraveBehaviour)item).sprite.GetCurrentSpriteDef().name;
GunExt.SetName(item, ((Object)item).name);
GunExt.SetShortDescription(item, shortDesc);
GunExt.SetLongDescription(item, longDesc);
if (item is PlayerItem)
{
((PlayerItem)((item is PlayerItem) ? item : null)).consumable = false;
}
Game.Items.Add(idPool + ":" + ((Object)item).name.ToLower().Replace(" ", "_"), item);
Databases.Items.Add(item, false, "ANY");
}
catch (Exception ex)
{
ETGModConsole.Log((object)ex.Message, false);
ETGModConsole.Log((object)ex.StackTrace, false);
}
}
public static void AddToSubShop(this PickupObject po, ShopType type, float weight = 1f)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
WeightedGameObjectCollection defaultItemDrops = shopInventories[type].defaultItemDrops;
WeightedGameObject val = new WeightedGameObject();
val.pickupId = po.PickupObjectId;
val.weight = weight;
val.rawGameObject = ((Component)po).gameObject;
val.forceDuplicatesPossible = false;
val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
defaultItemDrops.Add(val);
}
public static void SetCooldownType(this PlayerItem item, CooldownType cooldownType, float value)
{
item.damageCooldown = -1f;
item.roomCooldown = -1;
item.timeCooldown = -1f;
switch (cooldownType)
{
case CooldownType.Timed:
item.timeCooldown = value;
break;
case CooldownType.Damage:
item.damageCooldown = value;
break;
case CooldownType.PerRoom:
item.roomCooldown = (int)value;
break;
}
}
public static StatModifier AddPassiveStatModifier(this PickupObject po, StatType statType, float amount, ModifyMethod method = 0)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
StatModifier val = new StatModifier();
val.amount = amount;
val.statToBoost = statType;
val.modifyType = method;
po.AddPassiveStatModifier(val);
return val;
}
public static void AddPassiveStatModifier(this PickupObject po, StatModifier modifier)
{
if (po is PlayerItem)
{
PlayerItem val = (PlayerItem)(object)((po is PlayerItem) ? po : null);
if (val.passiveStatModifiers == null)
{
val.passiveStatModifiers = (StatModifier[])(object)new StatModifier[1] { modifier };
}
else
{
val.passiveStatModifiers = val.passiveStatModifiers.Concat((IEnumerable<StatModifier>)(object)new StatModifier[1] { modifier }).ToArray();
}
return;
}
if (po is PassiveItem)
{
PassiveItem val2 = (PassiveItem)(object)((po is PassiveItem) ? po : null);
if (val2.passiveStatModifiers == null)
{
val2.passiveStatModifiers = (StatModifier[])(object)new StatModifier[1] { modifier };
}
else
{
val2.passiveStatModifiers = val2.passiveStatModifiers.Concat((IEnumerable<StatModifier>)(object)new StatModifier[1] { modifier }).ToArray();
}
return;
}
throw new NotSupportedException("Object must be of type PlayerItem or PassiveItem");
}
public static bool RemovePassiveStatModifier(this PickupObject po, StatModifier modifier)
{
bool flag = false;
if (po is PlayerItem)
{
PlayerItem val = (PlayerItem)(object)((po is PlayerItem) ? po : null);
if (val.passiveStatModifiers == null)
{
return false;
}
List<StatModifier> list = val.passiveStatModifiers.ToList();
flag = list.Remove(modifier);
val.passiveStatModifiers = list.ToArray();
}
else
{
if (!(po is PassiveItem))
{
throw new NotSupportedException("Object must be of type PlayerItem or PassiveItem");
}
PassiveItem val2 = (PassiveItem)(object)((po is PassiveItem) ? po : null);
if (val2.passiveStatModifiers == null)
{
return false;
}
List<StatModifier> list2 = val2.passiveStatModifiers.ToList();
flag = list2.Remove(modifier);
val2.passiveStatModifiers = list2.ToArray();
}
return flag;
}
public static IEnumerator HandleDuration(PlayerItem item, float duration, PlayerController user, Action<PlayerController> OnFinish)
{
if (!item.IsCurrentlyActive)
{
SetPrivateType<PlayerItem>(item, "m_isCurrentlyActive", value: true);
SetPrivateType<PlayerItem>(item, "m_activeElapsed", 0f);
SetPrivateType<PlayerItem>(item, "m_activeDuration", duration);
item.OnActivationStatusChanged?.Invoke(item);
GetPrivateType<PlayerItem, float>(item, "m_activeElapsed");
GetPrivateType<PlayerItem, float>(item, "m_activeDuration");
while (GetPrivateType<PlayerItem, float>(item, "m_activeElapsed") < GetPrivateType<PlayerItem, float>(item, "m_activeDuration") && item.IsCurrentlyActive)
{
yield return null;
}
SetPrivateType<PlayerItem>(item, "m_isCurrentlyActive", value: false);
item.OnActivationStatusChanged?.Invoke(item);
OnFinish?.Invoke(user);
}
}
private static void SetPrivateType<T>(T obj, string field, bool value)
{
FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic);
field2.SetValue(obj, value);
}
private static void SetPrivateType<T>(T obj, string field, float value)
{
FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic);
field2.SetValue(obj, value);
}
private static T2 GetPrivateType<T, T2>(T obj, string field)
{
FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic);
return (T2)field2.GetValue(obj);
}
}
public static class ResourceExtractor
{
private static string spritesDirectory = Path.Combine(ETGMod.ResourcesDirectory, "sprites");
public static List<Texture2D> GetTexturesFromDirectory(string directoryPath)
{
if (!Directory.Exists(directoryPath))
{
ETGModConsole.Log((object)(directoryPath + " not found."), false);
return null;
}
List<Texture2D> list = new List<Texture2D>();
string[] files = Directory.GetFiles(directoryPath);
foreach (string text in files)
{
if (text.EndsWith(".png"))
{
Texture2D item = BytesToTexture(File.ReadAllBytes(text), Path.GetFileName(text).Replace(".png", ""));
list.Add(item);
}
}
return list;
}
public static Texture2D GetTextureFromFile(string fileName, string extension = ".png")
{
fileName = fileName.Replace(extension, "");
string text = Path.Combine(spritesDirectory, fileName + extension);
if (!File.Exists(text))
{
ETGModConsole.Log((object)(text + " not found."), false);
return null;
}
return BytesToTexture(File.ReadAllBytes(text), fileName);
}
public static List<string> GetCollectionFiles()
{
List<string> list = new List<string>();
string[] files = Directory.GetFiles(spritesDirectory);
foreach (string text in files)
{
if (text.EndsWith(".png"))
{
list.Add(Path.GetFileName(text).Replace(".png", ""));
}
}
return list;
}
public static Texture2D BytesToTexture(byte[] bytes, string resourceName)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
ImageConversion.LoadImage(val, bytes);
((Texture)val).filterMode = (FilterMode)0;
((Object)val).name = resourceName;
return val;
}
public static string[] GetLinesFromEmbeddedResource(string filePath)
{
string text = BytesToString(ExtractEmbeddedResource(filePath));
return text.Split(new char[1] { '\n' });
}
public static string[] GetLinesFromFile(string filePath)
{
string text = BytesToString(File.ReadAllBytes(filePath));
return text.Split(new char[1] { '\n' });
}
public static string BytesToString(byte[] bytes)
{
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
}
public static List<string> GetResourceFolders()
{
List<string> list = new List<string>();
string path = Path.Combine(ETGMod.ResourcesDirectory, "sprites");
if (Directory.Exists(path))
{
string[] directories = Directory.GetDirectories(path);
foreach (string path2 in directories)
{
list.Add(Path.GetFileName(path2));
}
}
return list;
}
public static byte[] ExtractEmbeddedResource(string filePath)
{
filePath = filePath.Replace("/", ".");
filePath = filePath.Replace("\\", ".");
Assembly callingAssembly = Assembly.GetCallingAssembly();
using Stream stream = callingAssembly.GetManifestResourceStream(filePath);
if (stream == null)
{
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return array;
}
public static Texture2D GetTextureFromResource(string resourceName)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
byte[] array = ExtractEmbeddedResource(resourceName);
if (array == null)
{
ETGModConsole.Log((object)("No bytes found in " + resourceName), false);
return null;
}
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
ImageConversion.LoadImage(val, array);
((Texture)val).filterMode = (FilterMode)0;
string text = resourceName.Substring(0, resourceName.LastIndexOf('.'));
if (text.LastIndexOf('.') >= 0)
{
text = text.Substring(text.LastIndexOf('.') + 1);
}
((Object)val).name = text;
return val;
}
public static string[] GetResourceNames()
{
Assembly callingAssembly = Assembly.GetCallingAssembly();
string[] manifestResourceNames = callingAssembly.GetManifestResourceNames();
if (manifestResourceNames == null)
{
ETGModConsole.Log((object)"No manifest resources found.", false);
return null;
}
return manifestResourceNames;
}
}
public static class SpriteBuilder
{
private static tk2dSpriteCollectionData itemCollection = ((BraveBehaviour)PickupObjectDatabase.GetById(155)).sprite.Collection;
private static tk2dSpriteCollectionData ammonomiconCollection = AmmonomiconController.ForceInstance.EncounterIconCollection;
private static tk2dSprite baseSprite = ((Component)PickupObjectDatabase.GetById(155)).GetComponent<tk2dSprite>();
public static GameObject SpriteFromFile(string spriteName, GameObject obj = null)
{
string fileName = spriteName.Replace(".png", "");
Texture2D textureFromFile = ResourceExtractor.GetTextureFromFile(fileName);
if ((Object)(object)textureFromFile == (Object)null)
{
return null;
}
return SpriteFromTexture(textureFromFile, spriteName, obj);
}
public static GameObject SpriteFromResource(string spriteName, GameObject obj = null)
{
string text = ((!spriteName.EndsWith(".png")) ? ".png" : "");
string text2 = spriteName + text;
Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(text2);
if ((Object)(object)textureFromResource == (Object)null)
{
return null;
}
return SpriteFromTexture(textureFromResource, text2, obj);
}
public static GameObject SpriteFromTexture(Texture2D texture, string spriteName, GameObject obj = null)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
if ((Object)(object)obj == (Object)null)
{
obj = new GameObject();
}
tk2dSprite val = obj.AddComponent<tk2dSprite>();
int num = AddSpriteToCollection(spriteName, itemCollection);
((tk2dBaseSprite)val).SetSprite(itemCollection, num);
((tk2dBaseSprite)val).SortingOrder = 0;
((tk2dBaseSprite)val).IsPerpendicular = true;
obj.GetComponent<BraveBehaviour>().sprite = (tk2dBaseSprite)(object)val;
return obj;
}
public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection)
{
string text = ((!resourcePath.EndsWith(".png")) ? ".png" : "");
resourcePath += text;
Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(resourcePath);
tk2dSpriteDefinition val = ConstructDefinition(textureFromResource);
val.name = ((Object)textureFromResource).name;
return AddSpriteToCollection(val, collection);
}
public static int AddSpriteToCollection(tk2dSpriteDefinition spriteDefinition, tk2dSpriteCollectionData collection)
{
tk2dSpriteDefinition[] spriteDefinitions = collection.spriteDefinitions;
tk2dSpriteDefinition[] array = (collection.spriteDefinitions = spriteDefinitions.Concat((IEnumerable<tk2dSpriteDefinition>)(object)new tk2dSpriteDefinition[1] { spriteDefinition }).ToArray());
FieldInfo field = typeof(tk2dSpriteCollectionData).GetField("spriteNameLookupDict", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(collection, null);
collection.InitDictionary();
return array.Length - 1;
}
public static int AddToAmmonomicon(tk2dSpriteDefinition spriteDefinition)
{
return AddSpriteToCollection(spriteDefinition, ammonomiconCollection);
}
public static tk2dSpriteAnimationClip AddAnimation(tk2dSpriteAnimator animator, tk2dSpriteCollectionData collection, List<int> spriteIDs, string clipName, WrapMode wrapMode = 0)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
if ((Object)(object)animator.Library == (Object)null)
{
animator.Library = ((Component)animator).gameObject.AddComponent<tk2dSpriteAnimation>();
animator.Library.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0];
((Behaviour)animator.Library).enabled = true;
}
List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>();
for (int i = 0; i < spriteIDs.Count; i++)
{
tk2dSpriteDefinition val = collection.spriteDefinitions[spriteIDs[i]];
if (val.Valid)
{
list.Add(new tk2dSpriteAnimationFrame
{
spriteCollection = collection,
spriteId = spriteIDs[i]
});
}
}
tk2dSpriteAnimationClip val2 = new tk2dSpriteAnimationClip();
val2.name = clipName;
val2.fps = 15f;
val2.wrapMode = wrapMode;
Array.Resize(ref animator.Library.clips, animator.Library.clips.Length + 1);
animator.Library.clips[animator.Library.clips.Length - 1] = val2;
val2.frames = list.ToArray();
return val2;
}
public static SpeculativeRigidbody SetUpSpeculativeRigidbody(this tk2dSprite sprite, IntVector2 offset, IntVector2 dimensions)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
SpeculativeRigidbody orAddComponent = GameObjectExtensions.GetOrAddComponent<SpeculativeRigidbody>(((Component)sprite).gameObject);
PixelCollider val = new PixelCollider();
val.ColliderGenerationMode = (PixelColliderGeneration)0;
val.CollisionLayer = (CollisionLayer)3;
val.ManualWidth = dimensions.x;
val.ManualHeight = dimensions.y;
val.ManualOffsetX = offset.x;
val.ManualOffsetY = offset.y;
orAddComponent.PixelColliders = new List<PixelCollider> { val };
return orAddComponent;
}
public static tk2dSpriteDefinition ConstructDefinition(Texture2D texture)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: 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)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: 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_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
RuntimeAtlasSegment val = Assets.Packer.Pack(texture, false);
Material val2 = new Material(ShaderCache.Acquire(PlayerController.DefaultShaderName));
val2.mainTexture = (Texture)(object)val.texture;
int width = ((Texture)texture).width;
int height = ((Texture)texture).height;
float num = 0f;
float num2 = 0f;
float num3 = (float)width / 16f;
float num4 = (float)height / 16f;
tk2dSpriteDefinition val3 = new tk2dSpriteDefinition();
val3.normals = (Vector3[])(object)new Vector3[4]
{
new Vector3(0f, 0f, -1f),
new Vector3(0f, 0f, -1f),
new Vector3(0f, 0f, -1f),
new Vector3(0f, 0f, -1f)
};
val3.tangents = (Vector4[])(object)new Vector4[4]
{
new Vector4(1f, 0f, 0f, 1f),
new Vector4(1f, 0f, 0f, 1f),
new Vector4(1f, 0f, 0f, 1f),
new Vector4(1f, 0f, 0f, 1f)
};
val3.texelSize = new Vector2(0.0625f, 0.0625f);
val3.extractRegion = false;
val3.regionX = 0;
val3.regionY = 0;
val3.regionW = 0;
val3.regionH = 0;
val3.flipped = (FlipMode)0;
val3.complexGeometry = false;
val3.physicsEngine = (PhysicsEngine)0;
val3.colliderType = (ColliderType)1;
val3.collisionLayer = (CollisionLayer)6;
val3.position0 = new Vector3(num, num2, 0f);
val3.position1 = new Vector3(num + num3, num2, 0f);
val3.position2 = new Vector3(num, num2 + num4, 0f);
val3.position3 = new Vector3(num + num3, num2 + num4, 0f);
val3.material = val2;
val3.materialInst = val2;
val3.materialId = 0;
val3.uvs = val.uvs;
val3.boundsDataCenter = new Vector3(num3 / 2f, num4 / 2f, 0f);
val3.boundsDataExtents = new Vector3(num3, num4, 0f);
val3.untrimmedBoundsDataCenter = new Vector3(num3 / 2f, num4 / 2f, 0f);
val3.untrimmedBoundsDataExtents = new Vector3(num3, num4, 0f);
tk2dSpriteDefinition val4 = val3;
val4.name = ((Object)texture).name;
return val4;
}
public static tk2dSpriteCollectionData ConstructCollection(GameObject obj, string name)
{
tk2dSpriteCollectionData val = obj.AddComponent<tk2dSpriteCollectionData>();
Object.DontDestroyOnLoad((Object)(object)val);
val.assetName = name;
val.spriteCollectionGUID = name;
val.spriteCollectionName = name;
val.spriteDefinitions = (tk2dSpriteDefinition[])(object)new tk2dSpriteDefinition[0];
return val;
}
public static T CopyFrom<T>(this Component comp, T other) where T : Component
{
Type type = ((object)comp).GetType();
if ((object)type != ((object)other).GetType())
{
return default(T);
}
PropertyInfo[] properties = type.GetProperties();
PropertyInfo[] array = properties;
foreach (PropertyInfo propertyInfo in array)
{
if (propertyInfo.CanWrite)
{
try
{
propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
}
catch
{
}
}
}
FieldInfo[] fields = type.GetFields();
FieldInfo[] array2 = fields;
foreach (FieldInfo fieldInfo in array2)
{
fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
}
return (T)(object)((comp is T) ? comp : null);
}
public static void SetColor(this tk2dSprite sprite, Color color)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
((BraveBehaviour)sprite).renderer.material.SetColor("_OverrideColor", color);
}
public static T AddComponent<T>(this GameObject go, T toAdd) where T : Component
{
return ((Component)(object)go.AddComponent<T>()).CopyFrom(toAdd);
}
}
}
namespace ImposterItems
{
public class ImpostersKnife : PlayerItem
{
private Material m_material;
public static int ImpostersKnifeId;
public Shader DarknessEffectShader;
public bool isStabbing;
public VFXPool stabVfx;
public static void Init()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Expected O, but got Unknown
string text = "Imposter's Knife";
string resourcePath = "ImposterItems/Resources/imposter_knife";
GameObject val = new GameObject(text);
ImpostersKnife impostersKnife = val.AddComponent<ImpostersKnife>();
ItemBuilder.AddSpriteToObject(text, resourcePath, val);
string shortDesc = "Wasn't me";
string longDesc = "On use, deliver a quick short range, high damage stab towards a direction of your choosing.\n\nSharp, quick, reliable, and most importantly never runs out of ammo. It's no wonder why the knife is such an effective killing device, held back only for it's short range..maybe there's some kind of workaround to that...";
((PickupObject)(object)impostersKnife).SetupItem(shortDesc, longDesc, "spapi");
((PlayerItem)(object)impostersKnife).SetCooldownType(ItemBuilder.CooldownType.Damage, 500f);
((PlayerItem)impostersKnife).consumable = false;
((PickupObject)impostersKnife).quality = (ItemQuality)(-50);
impostersKnife.DarknessEffectShader = ShaderCache.Acquire("Hidden/DarknessChallengeShader");
GameObject val2 = SpriteBuilder.SpriteFromResource("ImposterItems/Resources/imposter_knife_stab", new GameObject("ImposterKnifeStab"));
val2.SetActive(false);
FakePrefab.MarkAsFakePrefab(val2);
Object.DontDestroyOnLoad((Object)(object)val2);
tk2dSpriteAnimator val3 = val2.AddComponent<tk2dSpriteAnimator>();
SpriteBuilder.AddAnimation(val3, val2.GetComponent<tk2dBaseSprite>().Collection, new List<int>(1) { val2.GetComponent<tk2dBaseSprite>().spriteId }, "stab", (WrapMode)2).fps = 1f;
val3.playAutomatically = true;
val3.DefaultClipId = val3.GetClipIdByName("stab");
SpriteAnimatorKiller val4 = val2.AddComponent<SpriteAnimatorKiller>();
val4.fadeTime = -1f;
val4.delayDestructionTime = -1f;
val4.animator = val3;
ConstructOffsetsFromAnchor(val2.GetComponent<tk2dBaseSprite>().GetCurrentSpriteDef(), (Anchor)3);
VFXPool val5 = new VFXPool();
val5.type = (VFXPoolType)1;
VFXComplex[] array = new VFXComplex[1];
VFXComplex val6 = new VFXComplex();
val6.effects = (VFXObject[])(object)new VFXObject[1]
{
new VFXObject
{
alignment = (VFXAlignment)0,
attached = true,
orphaned = false,
persistsOnDeath = false,
destructible = true,
usesZHeight = true,
zHeight = -0.25f,
effect = val2
}
};
array[0] = val6;
val5.effects = (VFXComplex[])(object)array;
impostersKnife.stabVfx = val5;
ImpostersKnifeId = ((PickupObject)impostersKnife).PickupObjectId;
Game.Items.Rename("spapi:imposter's_knife", "spapi:imposters_knife");
}
public static void ConstructOffsetsFromAnchor(tk2dSpriteDefinition def, Anchor anchor, Vector2? scale = null, bool fixesScale = false, bool changesCollider = true)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected I4, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected I4, but got Unknown
//IL_007b: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
Vector2 valueOrDefault = scale.GetValueOrDefault();
if (!scale.HasValue)
{
valueOrDefault = Vector2.op_Implicit(def.position3);
scale = valueOrDefault;
}
if (fixesScale)
{
scale = scale.GetValueOrDefault() - Vector3Extensions.XY(def.position0);
}
int num = anchor % 3;
if (1 == 0)
{
}
float num2 = num switch
{
1 => 0f - scale.Value.x / 2f,
2 => 0f - scale.Value.x,
_ => 0f,
};
if (1 == 0)
{
}
float num3 = num2;
int num4 = anchor / 3;
if (1 == 0)
{
}
num2 = num4 switch
{
1 => 0f - scale.Value.y / 2f,
2 => 0f - scale.Value.y,
_ => 0f,
};
if (1 == 0)
{
}
float num5 = num2;
MakeOffset(def, new Vector2(num3, num5), changesCollider);
}
public static void MakeOffset(tk2dSpriteDefinition def, Vector2 offset, bool changesCollider = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00b8: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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_00ed: 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_0122: 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_0133: 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)
float x = offset.x;
float y = offset.y;
def.position0 += new Vector3(x, y, 0f);
def.position1 += new Vector3(x, y, 0f);
def.position2 += new Vector3(x, y, 0f);
def.position3 += new Vector3(x, y, 0f);
def.boundsDataCenter += new Vector3(x, y, 0f);
def.boundsDataExtents += new Vector3(x, y, 0f);
def.untrimmedBoundsDataCenter += new Vector3(x, y, 0f);
def.untrimmedBoundsDataExtents += new Vector3(x, y, 0f);
if (def.colliderVertices != null && def.colliderVertices.Length != 0 && changesCollider)
{
ref Vector3 reference = ref def.colliderVertices[0];
reference += new Vector3(x, y, 0f);
}
}
public Vector4 GetCenterPointInScreenUV(Vector2 centerPoint)
{
//IL_0010: 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_0021: 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_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)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = GameManager.Instance.MainCameraController.Camera.WorldToViewportPoint(Vector2Extensions.ToVector3ZUp(centerPoint, 0f));
return new Vector4(val.x, val.y, 0f, 0f);
}
public void LateUpdate()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Invalid comparison between Unknown and I4
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)m_material == (Object)null || !base.m_isCurrentlyActive)
{
return;
}
float num = ((GameActor)GameManager.Instance.PrimaryPlayer).FacingDirection;
if (num > 270f)
{
num -= 360f;
}
if (num < -270f)
{
num += 360f;
}
m_material.SetFloat("_ConeAngle", 0f);
Vector4 centerPointInScreenUV = GetCenterPointInScreenUV(((GameActor)GameManager.Instance.PrimaryPlayer).CenterPosition);
centerPointInScreenUV.z = num;
Vector4 val = centerPointInScreenUV;
if ((int)GameManager.Instance.CurrentGameType == 1)
{
float num2 = ((GameActor)GameManager.Instance.SecondaryPlayer).FacingDirection;
if (num2 > 270f)
{
num2 -= 360f;
}
if (num2 < -270f)
{
num2 += 360f;
}
val = GetCenterPointInScreenUV(((GameActor)GameManager.Instance.SecondaryPlayer).CenterPosition);
val.z = num2;
}
m_material.SetVector("_Player1ScreenPosition", centerPointInScreenUV);
m_material.SetVector("_Player2ScreenPosition", val);
}
public override void OnPreDrop(PlayerController user)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
((MonoBehaviour)this).StopAllCoroutines();
if (base.m_isCurrentlyActive)
{
if (Object.op_Implicit((Object)(object)Pixelator.Instance))
{
Pixelator.Instance.AdditionalCoreStackRenderPass = null;
}
((BraveBehaviour)user).specRigidbody.RemoveCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2, (CollisionLayer)3));
user.ChangeSpecialShaderFlag(1, 0f);
((GameActor)user).SetIsStealthed(false, "voting interface");
user.SetCapableOfStealing(false, "VotingInterface", (float?)null);
}
EncounterTrackable.SuppressNextNotification = true;
PlayerItem component = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(VotingInterface.VotingInterfaceId)).gameObject, Vector2.op_Implicit(Vector2.zero), Quaternion.identity).GetComponent<PlayerItem>();
component.ForceAsExtant = true;
((PickupObject)component).Pickup(user);
EncounterTrackable.SuppressNextNotification = false;
foreach (PlayerItem activeItem in user.activeItems)
{
if (!(activeItem is VotingInterface))
{
continue;
}
activeItem.ForceApplyCooldown(user);
user.DropActiveItem(activeItem, 4f, false);
break;
}
user.RemoveActiveItem(((PickupObject)this).PickupObjectId);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
public override void DoEffect(PlayerController user)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
AkSoundEngine.PostEvent("Play_ENV_puddle_zap_01", ((Component)user).gameObject);
m_material = new Material(DarknessEffectShader);
Pixelator.Instance.AdditionalCoreStackRenderPass = m_material;
user.ChangeSpecialShaderFlag(1, 1f);
((GameActor)user).SetIsStealthed(true, "voting interface");
user.SetCapableOfStealing(true, "VotingInterface", (float?)null);
((BraveBehaviour)user).specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2, (CollisionLayer)3));
((MonoBehaviour)this).StartCoroutine(ItemBuilder.HandleDuration((PlayerItem)(object)this, 6.5f, user, EndEffect));
}
public void EndEffect(PlayerController user)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)Pixelator.Instance))
{
Pixelator.Instance.AdditionalCoreStackRenderPass = null;
}
((BraveBehaviour)user).specRigidbody.RemoveCollisionLayerIgnoreOverride(CollisionMask.LayerToMask((CollisionLayer)2, (CollisionLayer)3));
user.ChangeSpecialShaderFlag(1, 0f);
((GameActor)user).SetIsStealthed(false, "voting interface");
user.SetCapableOfStealing(false, "VotingInterface", (float?)null);
user.RemoveActiveItem(((PickupObject)this).PickupObjectId);
EncounterTrackable.SuppressNextNotification = true;
PlayerItem component = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(VotingInterface.VotingInterfaceId)).gameObject, Vector2.op_Implicit(Vector2.zero), Quaternion.identity).GetComponent<PlayerItem>();
component.ForceAsExtant = true;
((PickupObject)component).Pickup(user);
EncounterTrackable.SuppressNextNotification = false;
foreach (PlayerItem activeItem in user.activeItems)
{
if (activeItem is VotingInterface)
{
activeItem.ForceApplyCooldown(user);
}
}
}
public override void DoActiveEffect(PlayerController user)
{
//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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
((PlayerItem)this).DoActiveEffect(user);
if (!isStabbing)
{
Vector2 val = Vector3Extensions.XY(user.unadjustedAimPoint) - ((GameActor)user).CenterPosition;
float num = Vector2Extensions.ToAngle(val);
stabVfx.SpawnAtPosition(Vector2.op_Implicit(((GameActor)user).CenterPosition), num, ((BraveBehaviour)user).transform, (Vector2?)null, (Vector2?)null, (float?)1f, false, (SpawnMethod)null, ((BraveBehaviour)user).sprite, true);
float rayDamagePerSecond = 300f;
float rayLength = 1.6875f;
((MonoBehaviour)user).StartCoroutine(HandleSwing(user, val, rayDamagePerSecond, rayLength));
}
}
public IEnumerator HandleSwing(PlayerController user, Vector2 aimVec, float rayDamagePerSecond, float rayLength)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
isStabbing = true;
float elapsed = 0f;
while (elapsed < 1f)
{
elapsed += BraveTime.DeltaTime;
SpeculativeRigidbody hitRigidbody = IterativeRaycast(((GameActor)user).CenterPosition, aimVec, rayLength, int.MaxValue, ((BraveBehaviour)user).specRigidbody);
if (Object.op_Implicit((Object)(object)hitRigidbody) && Object.op_Implicit((Object)(object)((BraveBehaviour)hitRigidbody).aiActor) && ((BraveBehaviour)hitRigidbody).aiActor.IsNormalEnemy)
{
((BraveBehaviour)((BraveBehaviour)hitRigidbody).aiActor).healthHaver.ApplyDamage(rayDamagePerSecond * BraveTime.DeltaTime, aimVec, "Imposter's Knife", (CoreDamageTypes)0, (DamageCategory)0, false, (PixelCollider)null, false);
}
yield return null;
}
isStabbing = false;
}
public SpeculativeRigidbody IterativeRaycast(Vector2 rayOrigin, Vector2 rayDirection, float rayDistance, int collisionMask, SpeculativeRigidbody ignoreRigidbody)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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)
int num = 0;
RaycastResult val = default(RaycastResult);
while (PhysicsEngine.Instance.Raycast(rayOrigin, rayDirection, rayDistance, ref val, true, true, collisionMask, (CollisionLayer?)(CollisionLayer)4, false, (Func<SpeculativeRigidbody, bool>)null, ignoreRigidbody))
{
num++;
SpeculativeRigidbody speculativeRigidbody = val.SpeculativeRigidbody;
if (num < 3 && (Object)(object)speculativeRigidbody != (Object)null)
{
MinorBreakable component = ((Component)speculativeRigidbody).GetComponent<MinorBreakable>();
if ((Object)(object)component != (Object)null)
{
component.Break(((Vector2)(ref rayDirection)).normalized * 3f);
RaycastResult.Pool.Free(ref val);
continue;
}
}
RaycastResult.Pool.Free(ref val);
return speculativeRigidbody;
}
return null;
}
}
public class ImpostersSidearm : GunBehaviour
{
public static List<IntVector2> fireOffsets = new List<IntVector2>
{
new IntVector2(-4, 1),
new IntVector2(-3, 0),
new IntVector2(-2, 0),
new IntVector2(-1, 0),
new IntVector2(0, 0)
};
public static List<IntVector2> reloadOffsets = new List<IntVector2>
{
new IntVector2(-4, 0),
new IntVector2(-4, 2),
new IntVector2(-4, 7),
new IntVector2(-4, 8),
new IntVector2(-4, -3),
new IntVector2(-4, 0),
new IntVector2(4, 0),
new IntVector2(2, 0),
new IntVector2(1, 0)
};
public static List<IntVector2> introOffsets = new List<IntVector2>
{
new IntVector2(0, 3),
new IntVector2(-1, 0),
new IntVector2(2, -2),
new IntVector2(3, -8),
new IntVector2(3, -3),
new IntVector2(3, 6),
new IntVector2(3, 5),
new IntVector2(0, -5),
new IntVector2(2, -7),
new IntVector2(4, -6),
new IntVector2(4, -7)
};
public static List<IntVector2> emptyOffsets = new List<IntVector2>
{
new IntVector2(-4, 0)
};
public static void Init()
{
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_0390: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
Gun val = Databases.Items.NewGun("Impostor's Sidearm", "impgun");
Game.Items.Rename("outdated_gun_mods:impostor's_sidearm", "spapi:impostors_sidearm");
GunExt.SetShortDescription((PickupObject)(object)val, "No!! Please!");
GunExt.SetLongDescription((PickupObject)(object)val, "\n\nNormally locked up in the weapons cache, This gun my be responsible for countless accounts of cold blooded murder. Now why would a mere crewmate need such a bulky, powerful weapon.. as one fellow crewmate once stated \"That's kind of sus\"");
GunExt.SetupSprite(val, (tk2dSpriteCollectionData)null, "impgun_idle_001", 12);
GunExt.AddProjectileModuleFrom(val, "klobb", true, false);
PickupObject byId = PickupObjectDatabase.GetById(56);
Projectile val2 = Object.Instantiate<Projectile>(((Gun)((byId is Gun) ? byId : null)).DefaultModule.projectiles[0]);
((Component)val2).gameObject.SetActive(false);
FakePrefab.MarkAsFakePrefab(((Component)val2).gameObject);
Object.DontDestroyOnLoad((Object)(object)val2);
val.DefaultModule.projectiles[0] = val2;
val2.baseData.damage = 12f;
((Object)val2).name = "ImposterGun_Projectile";
val.DefaultModule.shootStyle = (ShootStyle)0;
val.DefaultModule.angleVariance = 0f;
val.DefaultModule.ammoType = (AmmoType)1;
val.DefaultModule.cooldownTime = 0.5f;
val.DefaultModule.numberOfShotsInClip = 8;
((Component)val).gameObject.AddComponent<ImpostersSidearm>();
val.reloadTime = 1.89f;
val.InfiniteAmmo = true;
((PickupObject)val).quality = (ItemQuality)(-50);
ref VFXPool muzzleFlashEffects = ref val.muzzleFlashEffects;
PickupObject byId2 = PickupObjectDatabase.GetById(56);
muzzleFlashEffects = ((Gun)((byId2 is Gun) ? byId2 : null)).muzzleFlashEffects;
((Component)val.barrelOffset).transform.localPosition = new Vector3(1.0625f, 0.5625f, 0f);
val.gunClass = (GunClass)1;
tk2dSpriteAnimator component = ((Component)val).GetComponent<tk2dSpriteAnimator>();
tk2dSpriteAnimationClip clipByName = component.GetClipByName(val.shootAnimation);
tk2dSpriteAnimationClip clipByName2 = component.GetClipByName(val.reloadAnimation);
tk2dSpriteAnimationClip clipByName3 = component.GetClipByName(val.introAnimation);
tk2dSpriteAnimationClip clipByName4 = component.GetClipByName(val.emptyAnimation);
Vector2 offset = default(Vector2);
for (int i = 0; i < clipByName.frames.Length; i++)
{
tk2dSpriteAnimationFrame val3 = clipByName.frames[i];
tk2dSpriteDefinition def = val3.spriteCollection.spriteDefinitions[val3.spriteId];
((Vector2)(ref offset))..ctor((float)fireOffsets[i].x / 16f, (float)fireOffsets[i].y / 16f);
ImpostersKnife.MakeOffset(def, offset);
}
Vector2 offset2 = default(Vector2);
for (int j = 0; j < clipByName2.frames.Length; j++)
{
tk2dSpriteAnimationFrame val4 = clipByName2.frames[j];
tk2dSpriteDefinition def2 = val4.spriteCollection.spriteDefinitions[val4.spriteId];
((Vector2)(ref offset2))..ctor((float)reloadOffsets[j].x / 16f, (float)reloadOffsets[j].y / 16f);
ImpostersKnife.MakeOffset(def2, offset2);
}
Vector2 offset3 = default(Vector2);
for (int k = 0; k < clipByName3.frames.Length; k++)
{
tk2dSpriteAnimationFrame val5 = clipByName3.frames[k];
tk2dSpriteDefinition def3 = val5.spriteCollection.spriteDefinitions[val5.spriteId];
((Vector2)(ref offset3))..ctor((float)introOffsets[k].x / 16f, (float)introOffsets[k].y / 16f);
ImpostersKnife.MakeOffset(def3, offset3);
}
Vector2 offset4 = default(Vector2);
for (int l = 0; l < clipByName4.frames.Length; l++)
{
tk2dSpriteAnimationFrame val6 = clipByName4.frames[l];
tk2dSpriteDefinition def4 = val6.spriteCollection.spriteDefinitions[val6.spriteId];
((Vector2)(ref offset4))..ctor((float)emptyOffsets[l].x / 16f, (float)emptyOffsets[l].y / 16f);
ImpostersKnife.MakeOffset(def4, offset4);
}
Databases.Items.Add(val, (tk2dSpriteCollectionData)null, "ANY");
}
public override void Update()
{
if ((Object)(object)base.gun != (Object)null)
{
if (!base.gun.PreventNormalFireAudio)
{
base.gun.PreventNormalFireAudio = true;
}
if (base.gun.OverrideNormalFireAudioEvent != "Play_WPN_sniperrifle_shot_01")
{
base.gun.OverrideNormalFireAudioEvent = "Play_WPN_sniperrifle_shot_01";
}
}
}
}
[HarmonyPatch]
public class PetOffsetHolder : MonoBehaviour
{
public Vector2 petOffsetRight;
public Vector2 petOffsetLeft;
[HarmonyPatch(typeof(CompanionController), "DoPet")]
[HarmonyPostfix]
public static void ApplyOverridePetOffset_Postfix(CompanionController __instance, PlayerController player)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0042: Unknown result type (might be due to invalid IL or missing references)
PetOffsetHolder component = ((Component)__instance).GetComponent<PetOffsetHolder>();
if (!((Object)(object)component == (Object)null))
{
if (((BraveBehaviour)__instance).specRigidbody.UnitCenter.x > ((BraveBehaviour)player).specRigidbody.UnitCenter.x)
{
__instance.m_petOffset = component.petOffsetRight;
}
else
{
__instance.m_petOffset = component.petOffsetLeft;
}
}
}
}
public class VotingInterface : PlayerItem
{
public static int VotingInterfaceId;
public static void Init()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
string text = "Voting Interface";
string resourcePath = "ImposterItems/Resources/busted_interface";
GameObject val = new GameObject(text);
VotingInterface votingInterface = val.AddComponent<VotingInterface>();
ItemBuilder.AddSpriteToObject(text, resourcePath, val);
string shortDesc = "Sabotage";
string longDesc = "Allows the user to remotely turn off the lights and slip into darkness. While the lights are dimmed gain stealth.\n\nThis tablet was issued to you and the rest of your crew in tact with multiple apps, most notably ones allowing you to anomalously vote in crew meetings, view your surroundings, and remotely control linked electronics. Luckily The Gungeon doesn't have a great firewall...";
((PickupObject)(object)votingInterface).SetupItem(shortDesc, longDesc, "spapi");
((PlayerItem)(object)votingInterface).SetCooldownType(ItemBuilder.CooldownType.Damage, 500f);
((PlayerItem)votingInterface).consumable = false;
((PickupObject)votingInterface).quality = (ItemQuality)(-50);
VotingInterfaceId = ((PickupObject)votingInterface).PickupObjectId;
}
public override void DoEffect(PlayerController user)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
user.RemoveActiveItem(((PickupObject)this).PickupObjectId);
EncounterTrackable.SuppressNextNotification = true;
PlayerItem component = Object.Instantiate<GameObject>(((Component)PickupObjectDatabase.GetById(ImpostersKnife.ImpostersKnifeId)).gameObject, Vector2.op_Implicit(Vector2.zero), Quaternion.identity).GetComponent<PlayerItem>();
component.ForceAsExtant = true;
((PickupObject)component).Pickup(user);
EncounterTrackable.SuppressNextNotification = false;
float num = default(float);
foreach (PlayerItem activeItem in user.activeItems)
{
if (!(activeItem is ImpostersKnife))
{
continue;
}
activeItem.Use(user, ref num);
break;
}
}
}
public class LilCrewmate
{
public static GameObject prefab;
public static void Init()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
string text = "Lil' Crewmate";
string resourcePath = "ImposterItems/Resources/lilcrewmate";
GameObject val = new GameObject(text);
CompanionItem val2 = val.AddComponent<CompanionItem>();
ItemBuilder.AddSpriteToObject(text, resourcePath, val);
string shortDesc = "Just look at him!";
string longDesc = "This little crewmate went with the imposter when they where both ejected off the ship.\n\nHe doesn’t talk, he doesn’t fight, he honestly doesn’t do much of anything aside from being cute. At least the company must be nice.";
((PickupObject)(object)val2).SetupItem(shortDesc, longDesc, "spapi");
Game.Items.Rename("spapi:lil'_crewmate", "spapi:lil_crewmate");
((PickupObject)val2).quality = (ItemQuality)(-50);
val2.CompanionGuid = "lil_crewmate";
val2.Synergies = (CompanionTransformSynergy[])(object)new CompanionTransformSynergy[0];
BuildPrefab();
}
public static void BuildPrefab()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: 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_00a4: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Expected O, but got Unknown
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Expected O, but got Unknown
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: 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)
if (!((Object)(object)prefab != (Object)null) && !CompanionBuilder.companionDictionary.ContainsKey("lil_crewmate"))
{
prefab = CompanionBuilder.BuildPrefab("Lil Crewmate", "lil_crewmate", "ImposterItems/Resources/Crewmate/IdleRight/lilguy_idle_right_001", new IntVector2(0, 0), new IntVector2(7, 9));
CompanionController val = prefab.AddComponent<CompanionController>();
val.CanBePet = true;
val.CanInterceptBullets = true;
SpeculativeRigidbody specRigidbody = ((BraveBehaviour)val).specRigidbody;
PixelCollider item = new PixelCollider
{
ColliderGenerationMode = (PixelColliderGeneration)0,
CollisionLayer = (CollisionLayer)3,
ManualWidth = 7,
ManualHeight = 9,
ManualOffsetX = 0,
ManualOffsetY = 0
};
PixelCollider item2 = new PixelCollider
{
ColliderGenerationMode = (PixelColliderGeneration)0,
CollisionLayer = (CollisionLayer)0,
ManualWidth = 7,
ManualHeight = 9,
ManualOffsetX = 0,
ManualOffsetY = 0
};
specRigidbody.PixelColliders = new List<PixelCollider> { item, item2 };
specRigidbody.CollideWithOthers = true;
AIActor aiActor = ((BraveBehaviour)val).aiActor;
aiActor.IsNormalEnemy = false;
aiActor.CollisionDamage = 0f;
aiActor.MovementSpeed = 7.2f;
aiActor.CanDropCurrency = false;
prefab.AddAnimation("idle_right", "ImposterItems/Resources/Crewmate/IdleRight", 5, CompanionBuilder.AnimationType.Idle, (DirectionType)2, (FlipType)0);
prefab.AddAnimation("idle_left", "ImposterItems/Resources/Crewmate/IdleLeft", 5, CompanionBuilder.AnimationType.Idle, (DirectionType)2, (FlipType)0);
prefab.AddAnimation("run_right", "ImposterItems/Resources/Crewmate/MoveRight", 16, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0);
prefab.AddAnimation("run_left", "ImposterItems/Resources/Crewmate/MoveLeft", 16, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0);
prefab.AddAnimation("pet_right", "ImposterItems/Resources/Crewmate/PetRight", 5, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0, assignAnimation: false);
prefab.AddAnimation("pet_left", "ImposterItems/Resources/Crewmate/PetLeft", 5, CompanionBuilder.AnimationType.Move, (DirectionType)2, (FlipType)0, assignAnimation: false);
DirectionalAnimation val2 = new DirectionalAnimation();
val2.AnimNames = new string[2] { "pet_right", "pet_left" };
val2.Flipped = (FlipType[])(object)new FlipType[2];
val2.Type = (DirectionType)2;
val2.Prefix = string.Empty;
DirectionalAnimation animation = val2;
((BraveBehaviour)val).aiAnimator.AssignDirectionalAnimation("pet", animation, CompanionBuilder.AnimationType.Other);
BehaviorSpeculator component = prefab.GetComponent<BehaviorSpeculator>();
List<MovementBehaviorBase> movementBehaviors = component.MovementBehaviors;
CompanionFollowPlayerBehavior val3 = new CompanionFollowPlayerBehavior();
val3.IdleAnimations = new string[1] { "idle" };
val3.DisableInCombat = false;
movementBehaviors.Add((MovementBehaviorBase)(object)val3);
PetOffsetHolder petOffsetHolder = prefab.AddComponent<PetOffsetHolder>();
petOffsetHolder.petOffsetLeft = new Vector2(-0.5f, -0.0625f);
petOffsetHolder.petOffsetRight = new Vector2(0.5f, -0.0625f);
}
}
}
[BepInPlugin("spapi.etg.imposteritems", "Imposter Items", "1.0.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "spapi.etg.imposteritems";
public void Awake()
{
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
public void GMStart(GameManager game)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
new Harmony("spapi.etg.imposteritems").PatchAll();
ItemBuilder.Init();
LilCrewmate.Init();
VotingInterface.Init();
ImpostersKnife.Init();
ImpostersSidearm.Init();
}
}
}