Esempio n. 1
0
    // Token: 0x06000188 RID: 392 RVA: 0x000089C8 File Offset: 0x00006BC8
    public static void ArrayRemoveAtAndResize <T>(ref T[] array, int position, int count = 1)
    {
        int newSize = array.Length;

        HGArrayUtilities.ArrayRemoveAt <T>(ref array, ref newSize, position, count);
        Array.Resize <T>(ref array, newSize);
    }
Esempio n. 2
0
        // Token: 0x06001854 RID: 6228 RVA: 0x00069274 File Offset: 0x00067474
        private static void SetProjectilePrefabs(GameObject[] newProjectilePrefabs)
        {
            ProjectileCatalog.projectilePrefabs = HGArrayUtilities.Clone <GameObject>(newProjectilePrefabs);
            int num = 256;

            if (ProjectileCatalog.projectilePrefabs.Length > num)
            {
                Debug.LogErrorFormat("Cannot have more than {0} projectile prefabs defined, which is over the limit for {1}. Check comments at error source for details.", new object[]
                {
                    num,
                    typeof(byte).Name
                });
                for (int i = num; i < ProjectileCatalog.projectilePrefabs.Length; i++)
                {
                    Debug.LogErrorFormat("Could not register projectile [{0}/{1}]=\"{2}\"", new object[]
                    {
                        i,
                        num - 1,
                        ProjectileCatalog.projectilePrefabs[i].name
                    });
                }
            }
            ProjectileCatalog.projectilePrefabProjectileControllerComponents = new ProjectileController[ProjectileCatalog.projectilePrefabs.Length];
            ProjectileCatalog.projectileNames = new string[ProjectileCatalog.projectilePrefabs.Length];
            for (int j = 0; j < ProjectileCatalog.projectilePrefabs.Length; j++)
            {
                GameObject           gameObject = ProjectileCatalog.projectilePrefabs[j];
                ProjectileController component  = gameObject.GetComponent <ProjectileController>();
                component.catalogIndex = j;
                ProjectileCatalog.projectilePrefabProjectileControllerComponents[j] = component;
                ProjectileCatalog.projectileNames[j] = gameObject.name;
            }
        }
Esempio n. 3
0
        // Token: 0x06001D28 RID: 7464 RVA: 0x0007C9B8 File Offset: 0x0007ABB8
        public override Sprite GetCurrentIcon([NotNull] GenericSkill skillSlot)
        {
            MercDashSkillDef.InstanceData instanceData = (MercDashSkillDef.InstanceData)skillSlot.skillInstanceData;
            int index = (instanceData != null) ? instanceData.currentDashIndex : 0;

            return(HGArrayUtilities.GetSafe <Sprite>(this.icons, index));
        }
 // Token: 0x060004FF RID: 1279 RVA: 0x00014280 File Offset: 0x00012480
 public void AddDisplayRule(ItemDisplayRule itemDisplayRule)
 {
     if (this.rules == null)
     {
         this.rules = Array.Empty <ItemDisplayRule>();
     }
     HGArrayUtilities.ArrayAppend <ItemDisplayRule>(ref this.rules, ref itemDisplayRule);
 }
Esempio n. 5
0
            // Token: 0x06000E62 RID: 3682 RVA: 0x00040064 File Offset: 0x0003E264
            private void RemoveMemberAt(int i)
            {
                MinionOwnership minionOwnership = this.members[i];

                HGArrayUtilities.ArrayRemoveAt <MinionOwnership>(ref this.members, ref this._memberCount, i, 1);
                minionOwnership.HandleOwnerDiscovery(null);
                minionOwnership.HandleGroupDiscovery(null);
            }
 // Token: 0x06000164 RID: 356 RVA: 0x00008798 File Offset: 0x00006998
 public static void ArrayInsert <T>(ref T[] array, ref int arraySize, int position, ref T value)
 {
     arraySize++;
     if (arraySize > array.Length)
     {
         Array.Resize <T>(ref array, arraySize);
     }
     HGArrayUtilities.ArrayInsertNoResize <T>(array, arraySize, position, ref value);
 }
 // Token: 0x06000B82 RID: 2946 RVA: 0x000324B4 File Offset: 0x000306B4
 public void SetSkillOverride(object source, SkillDef skillDef, GenericSkill.SkillOverridePriority priority)
 {
     GenericSkill.SkillOverride skillOverride = new GenericSkill.SkillOverride(source, skillDef, priority);
     if (this.FindSkillOverrideIndex(ref skillOverride) == -1)
     {
         HGArrayUtilities.ArrayAppend <GenericSkill.SkillOverride>(ref this.skillOverrides, ref skillOverride);
         this.PickCurrentOverride();
     }
 }
Esempio n. 8
0
 // Token: 0x060003EF RID: 1007 RVA: 0x0000F7B4 File Offset: 0x0000D9B4
 private static void SetBodyPrefabs([NotNull] GameObject[] newBodyPrefabs)
 {
     BodyCatalog.bodyPrefabs = HGArrayUtilities.Clone <GameObject>(newBodyPrefabs);
     BodyCatalog.bodyPrefabBodyComponents = new CharacterBody[BodyCatalog.bodyPrefabs.Length];
     BodyCatalog.bodyNames      = new string[BodyCatalog.bodyPrefabs.Length];
     BodyCatalog.bodyComponents = new Component[BodyCatalog.bodyPrefabs.Length][];
     BodyCatalog.skillSlots     = new GenericSkill[BodyCatalog.bodyPrefabs.Length][];
     BodyCatalog.skins          = new SkinDef[BodyCatalog.bodyPrefabs.Length][];
     BodyCatalog.nameToIndexMap.Clear();
     for (int i = 0; i < BodyCatalog.bodyPrefabs.Length; i++)
     {
         GameObject gameObject = BodyCatalog.bodyPrefabs[i];
         string     name       = gameObject.name;
         BodyCatalog.bodyNames[i]      = name;
         BodyCatalog.bodyComponents[i] = gameObject.GetComponents <Component>();
         BodyCatalog.skillSlots[i]     = gameObject.GetComponents <GenericSkill>();
         BodyCatalog.nameToIndexMap.Add(name, i);
         BodyCatalog.nameToIndexMap.Add(name + "(Clone)", i);
         (BodyCatalog.bodyPrefabBodyComponents[i] = gameObject.GetComponent <CharacterBody>()).bodyIndex = i;
         Texture2D    texture2D = Resources.Load <Texture2D>("Textures/BodyIcons/" + name);
         SkinDef[][]  array     = BodyCatalog.skins;
         int          num       = i;
         ModelLocator component = gameObject.GetComponent <ModelLocator>();
         SkinDef[]    array2;
         if (component == null)
         {
             array2 = null;
         }
         else
         {
             Transform modelTransform = component.modelTransform;
             if (modelTransform == null)
             {
                 array2 = null;
             }
             else
             {
                 ModelSkinController component2 = modelTransform.GetComponent <ModelSkinController>();
                 array2 = ((component2 != null) ? component2.skins : null);
             }
         }
         array[num] = (array2 ?? Array.Empty <SkinDef>());
         if (texture2D)
         {
             BodyCatalog.bodyPrefabBodyComponents[i].portraitIcon = texture2D;
         }
         else if (BodyCatalog.bodyPrefabBodyComponents[i].portraitIcon == null)
         {
             BodyCatalog.bodyPrefabBodyComponents[i].portraitIcon = Resources.Load <Texture2D>("Textures/MiscIcons/texMysteryIcon");
         }
         if (Language.IsTokenInvalid(BodyCatalog.bodyPrefabBodyComponents[i].baseNameToken))
         {
             BodyCatalog.bodyPrefabBodyComponents[i].baseNameToken = "UNIDENTIFIED";
         }
     }
     BodyCatalog.bodyCount = BodyCatalog.bodyPrefabs.Length;
 }
        // Token: 0x06001FB9 RID: 8121 RVA: 0x00089C24 File Offset: 0x00087E24
        private static void OnConnectionLost(NetworkConnection connection)
        {
            int position;

            if (RttManager.FindConnectionIndex(connection, out position))
            {
                HGArrayUtilities.ArrayRemoveAtAndResize <RttManager.ConnectionRttInfo>(ref RttManager.entries, position, 1);
            }
        }
        // Token: 0x0600271A RID: 10010 RVA: 0x000AA00E File Offset: 0x000A820E
        public static string GetEventNameFromNetworkIndex(NetworkSoundEventIndex networkSoundEventIndex)
        {
            NetworkSoundEventDef safe = HGArrayUtilities.GetSafe <NetworkSoundEventDef>(NetworkSoundEventCatalog.entries, (int)networkSoundEventIndex);

            if (safe == null)
            {
                return(null);
            }
            return(safe.eventName);
        }
Esempio n. 11
0
 // Token: 0x06000E60 RID: 3680 RVA: 0x0003FFF4 File Offset: 0x0003E1F4
 public void AddMember(MinionOwnership minion)
 {
     HGArrayUtilities.ArrayAppend <MinionOwnership>(ref this.members, ref this._memberCount, ref minion);
     this.refCount++;
     minion.HandleGroupDiscovery(this);
     if (this.resolvedOwnerMaster)
     {
         minion.HandleOwnerDiscovery(this.resolvedOwnerMaster);
     }
 }
        // Token: 0x06000B83 RID: 2947 RVA: 0x000324EC File Offset: 0x000306EC
        public void UnsetSkillOverride(object source, SkillDef skillDef, GenericSkill.SkillOverridePriority priority)
        {
            GenericSkill.SkillOverride skillOverride = new GenericSkill.SkillOverride(source, skillDef, priority);
            int num = this.FindSkillOverrideIndex(ref skillOverride);

            if (num != -1)
            {
                HGArrayUtilities.ArrayRemoveAtAndResize <GenericSkill.SkillOverride>(ref this.skillOverrides, num, 1);
                this.PickCurrentOverride();
            }
        }
Esempio n. 13
0
 // Token: 0x060020B0 RID: 8368 RVA: 0x0008D700 File Offset: 0x0008B900
 private static void OnConnectionLost(NetworkConnection conn)
 {
     for (int i = 0; i < ServerAuthManager.instanceCount; i++)
     {
         if (ServerAuthManager.instances[i].conn == conn)
         {
             HGArrayUtilities.ArrayRemoveAt <ServerAuthManager.KeyValue>(ref ServerAuthManager.instances, ref ServerAuthManager.instanceCount, i, 1);
             return;
         }
     }
 }
            // Token: 0x06001727 RID: 5927 RVA: 0x00064D00 File Offset: 0x00062F00
            private Loadout.BodyLoadoutManager.BodyLoadout GetOrCreateModifiedBodyLoadout(int bodyIndex)
            {
                int num = this.FindModifiedBodyLoadoutIndexByBodyIndex(bodyIndex);

                if (num != -1)
                {
                    return(this.modifiedBodyLoadouts[num]);
                }
                Loadout.BodyLoadoutManager.BodyLoadout result = Loadout.BodyLoadoutManager.GetDefaultLoadoutForBody(bodyIndex).Clone();
                HGArrayUtilities.ArrayAppend <Loadout.BodyLoadoutManager.BodyLoadout>(ref this.modifiedBodyLoadouts, ref result);
                return(result);
            }
Esempio n. 15
0
            public override void Update()
            {
                base.Update();
                if (age >= shatterTime && !shatterFlag)
                {
                    shatterFlag = true;
                    if (pickupDisplay && pickupDisplay.modelObject)
                    {
                        var childLocator = pickupDisplay.modelObject.GetComponent <ChildLocator>();
                        if (!childLocator)
                        {
                            childLocator = pickupDisplay.modelObject.AddComponent <ChildLocator>();
                        }
                        if (childLocator.transformPairs == null)
                        {
                            childLocator.transformPairs = new ChildLocator.NameTransformPair[] { }
                        }
                        ;
                        var transformPair = new ChildLocator.NameTransformPair
                        {
                            name      = "ShatterOrigin",
                            transform = pickupDisplay.modelObject.transform
                        };
                        HGArrayUtilities.ArrayAppend(ref childLocator.transformPairs, ref transformPair);

                        TemporaryOverlay temporaryOverlay = pickupDisplay.modelObject.AddComponent <TemporaryOverlay>();
                        temporaryOverlay.duration                 = 0.5f;
                        temporaryOverlay.destroyObjectOnEnd       = true;
                        temporaryOverlay.originalMaterial         = LegacyResourcesAPI.Load <Material>("Materials/matShatteredGlass");
                        temporaryOverlay.destroyEffectPrefab      = (GameObject)LegacyResourcesAPI.Load <GameObject>("Prefabs/Effects/BrittleDeath");
                        temporaryOverlay.destroyEffectChildString = "ShatterOrigin";
                        temporaryOverlay.alphaCurve               = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                        temporaryOverlay.animateShaderAlpha       = true;
                        temporaryOverlay.SetupMaterial();

                        var renderer = pickupDisplay.modelRenderer;
                        if (renderer)
                        {
                            var materials = renderer.materials;
                            HGArrayUtilities.ArrayAppend(ref materials, ref temporaryOverlay.materialInstance);
                            renderer.materials = materials;
                        }
                    }
                }
                if (age >= duration)
                {
                    Object.Destroy(gameObject);
                }
            }
        }
Esempio n. 16
0
        // Token: 0x060003D0 RID: 976 RVA: 0x0000EB60 File Offset: 0x0000CD60
        private BlastAttack.HitPoint[] CollectHits()
        {
            Vector3 vector = this.position;

            Collider[] array = Physics.OverlapSphere(vector, this.radius, LayerIndex.entityPrecise.mask);
            int        num   = array.Length;
            int        num2  = 0;

            BlastAttack.< > c__DisplayClass27_0 CS$ < > 8__locals1;
            CS$ < > 8__locals1.encounteredHealthComponentsLength = 0;
            CS$ < > 8__locals1.hitOrderBufferLength = 0;
            HGArrayUtilities.EnsureCapacity <BlastAttack.HitPoint>(ref BlastAttack.hitPointsBuffer, num);
            HGArrayUtilities.EnsureCapacity <int>(ref BlastAttack.hitOrderBuffer, num);
            HGArrayUtilities.EnsureCapacity <HealthComponent>(ref BlastAttack.encounteredHealthComponentsBuffer, num);
            for (int i = 0; i < num; i++)
            {
                Collider collider  = array[i];
                HurtBox  component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent && ((this.canHurtAttacker && healthComponent.gameObject == this.attacker) || healthComponent.GetComponent <TeamComponent>().teamIndex != this.teamIndex))
                    {
                        Vector3 vector2      = collider.transform.position;
                        Vector3 hitNormal    = vector2 - vector;
                        float   sqrMagnitude = hitNormal.sqrMagnitude;
                        BlastAttack.hitPointsBuffer[num2++] = new BlastAttack.HitPoint
                        {
                            hurtBox     = component,
                            hitPosition = vector2,
                            hitNormal   = hitNormal,
                            distanceSqr = sqrMagnitude
                        };
                    }
                }
            }
            if (true)
            {
                for (int j = 0; j < num2; j++)
                {
                    ref BlastAttack.HitPoint ptr = ref BlastAttack.hitPointsBuffer[j];
                    RaycastHit raycastHit;
                    if (ptr.hurtBox != null && ptr.distanceSqr > 0f && ptr.hurtBox.collider.Raycast(new Ray(vector, -ptr.hitNormal), out raycastHit, this.radius))
                    {
                        ptr.hitPosition = raycastHit.point;
                        ptr.hitNormal   = raycastHit.normal;
                    }
                }
            }
 // Token: 0x060017AF RID: 6063 RVA: 0x00066E18 File Offset: 0x00065018
 private static void SetEntries(GameObject[] newEntries)
 {
     MasterCatalog.masterPrefabs = HGArrayUtilities.Clone <GameObject>(newEntries);
     MasterCatalog.masterPrefabMasterComponents = new CharacterMaster[MasterCatalog.masterPrefabs.Length];
     for (int i = 0; i < MasterCatalog.masterPrefabs.Length; i++)
     {
         MasterCatalog.MasterIndex value = new MasterCatalog.MasterIndex(i);
         MasterCatalog.nameToIndexMap.Add(MasterCatalog.masterPrefabs[i].name, value);
         MasterCatalog.nameToIndexMap.Add(MasterCatalog.masterPrefabs[i].name + "(Clone)", value);
         MasterCatalog.masterPrefabMasterComponents[i] = MasterCatalog.masterPrefabs[i].GetComponent <CharacterMaster>();
     }
     MasterCatalog.aiMasterPrefabs = (from master in MasterCatalog.masterPrefabMasterComponents
                                      where master.GetComponent <BaseAI>()
                                      select master).ToArray <CharacterMaster>();
 }
Esempio n. 18
0
        // Token: 0x06001B6A RID: 7018 RVA: 0x00080264 File Offset: 0x0007E464
        public void Update(float deltaTime)
        {
            this.internalTime += deltaTime;
            int num = 0;

            while (num < this.count && this.timers[num].time <= this.internalTime)
            {
                HGArrayUtilities.ArrayInsert <Action>(ref this.actionsToCall, ref this.actionsToCallCount, this.actionsToCallCount, ref this.timers[num].action);
                num++;
            }
            for (int i = this.actionsToCallCount - 1; i >= 0; i--)
            {
                this.RemoveTimerAt(i);
            }
            for (int j = 0; j < this.actionsToCallCount; j++)
            {
                this.actionsToCall[j]();
                this.actionsToCall[j] = null;
            }
            this.actionsToCallCount = 0;
        }
        // Token: 0x06002198 RID: 8600 RVA: 0x000914A8 File Offset: 0x0008F6A8
        private void BuildFromCharacterData(AllyCardManager.CharacterDataSet characterDataSet)
        {
            if (characterDataSet.count < this.displayElementCount)
            {
                Array.Clear(this.displayElements, characterDataSet.count, this.displayElementCount - characterDataSet.count);
            }
            this.displayElementCount = characterDataSet.count;
            HGArrayUtilities.EnsureCapacity <AllyCardManager.DisplayElement>(ref this.displayElements, this.displayElementCount);
            int i     = 0;
            int count = characterDataSet.count;

            while (i < count)
            {
                ref AllyCardManager.CharacterData ptr = ref characterDataSet[i];
                this.displayElements[i] = new AllyCardManager.DisplayElement
                {
                    master   = ptr.master,
                    priority = -1
                };
                i++;
            }
Esempio n. 20
0
        // Token: 0x06001B67 RID: 7015 RVA: 0x00080158 File Offset: 0x0007E358
        public TimerQueue.TimerHandle CreateTimer(float time, Action action)
        {
            time += this.internalTime;
            int position = this.count;

            for (int i = 0; i < this.count; i++)
            {
                if (time < this.timers[i].time)
                {
                    position = i;
                    break;
                }
            }
            TimerQueue.TimerHandle timerHandle = new TimerQueue.TimerHandle(this.indexAllocator.RequestIndex());
            TimerQueue.Timer       timer       = new TimerQueue.Timer
            {
                time   = time,
                action = action,
                handle = timerHandle
            };
            HGArrayUtilities.ArrayInsert <TimerQueue.Timer>(ref this.timers, ref this.count, position, ref timer);
            return(timerHandle);
        }
Esempio n. 21
0
 // Token: 0x06001910 RID: 6416 RVA: 0x0006C164 File Offset: 0x0006A364
 private static void SetSceneDefs(SceneDef[] newSceneDefs)
 {
     SceneCatalog.indexToSceneDef = HGArrayUtilities.Clone <SceneDef>(newSceneDefs);
     for (int i = 0; i < SceneCatalog.indexToSceneDef.Length; i++)
     {
         SceneCatalog.indexToSceneDef[i].sceneDefIndex = i;
     }
     SceneManager.activeSceneChanged += delegate(Scene oldScene, Scene newScene)
     {
         SceneCatalog.currentSceneDef = SceneCatalog.GetSceneDefFromSceneName(newScene.name);
         if (SceneCatalog.currentSceneDef != null)
         {
             SceneCatalog.mostRecentSceneDef = SceneCatalog.currentSceneDef;
             Action <SceneDef> action = SceneCatalog.onMostRecentSceneDefChanged;
             if (action == null)
             {
                 return;
             }
             action(SceneCatalog.mostRecentSceneDef);
         }
     };
     SceneCatalog.currentSceneDef    = SceneCatalog.GetSceneDefFromSceneName(SceneManager.GetActiveScene().name);
     SceneCatalog.mostRecentSceneDef = SceneCatalog.currentSceneDef;
 }
Esempio n. 22
0
    // Token: 0x0600009C RID: 156 RVA: 0x000050D4 File Offset: 0x000032D4
    public bool Push(float t)
    {
        float num = t - this.window;

        if (t < this.newestTime)
        {
            this.lastValidCount = this.timestamps.Length;
        }
        int num2 = this.lastValidCount - 1;

        while (num2 >= 0 && num > this.timestamps[num2])
        {
            this.lastValidCount--;
            num2--;
        }
        int num3 = this.FindInsertionPosition(t);

        if (num3 < this.timestamps.Length)
        {
            this.lastValidCount++;
            HGArrayUtilities.ArrayInsertNoResize <float>(this.timestamps, this.lastValidCount, num3, ref t);
        }
        return(this.lastValidCount == this.requirement);
    }
Esempio n. 23
0
 // Token: 0x060003EB RID: 1003 RVA: 0x0000F6C3 File Offset: 0x0000D8C3
 public static SkinDef[] GetBodySkins(int bodyIndex)
 {
     return(HGArrayUtilities.GetSafe <SkinDef[]>(BodyCatalog.skins, bodyIndex, Array.Empty <SkinDef>()));
 }
Esempio n. 24
0
 // Token: 0x06001B69 RID: 7017 RVA: 0x0008022B File Offset: 0x0007E42B
 private void RemoveTimerAt(int i)
 {
     this.indexAllocator.FreeIndex(this.timers[i].handle.uid);
     HGArrayUtilities.ArrayRemoveAt <TimerQueue.Timer>(ref this.timers, ref this.count, i, 1);
 }
 // Token: 0x06001FB8 RID: 8120 RVA: 0x00089C00 File Offset: 0x00087E00
 private static void OnConnectionDiscovered(NetworkConnection connection)
 {
     RttManager.ConnectionRttInfo connectionRttInfo = new RttManager.ConnectionRttInfo(connection);
     HGArrayUtilities.ArrayAppend <RttManager.ConnectionRttInfo>(ref RttManager.entries, ref connectionRttInfo);
 }
Esempio n. 26
0
 // Token: 0x06001858 RID: 6232 RVA: 0x000693A4 File Offset: 0x000675A4
 public static ProjectileController GetProjectilePrefabProjectileControllerComponent(int projectileIndex)
 {
     return(HGArrayUtilities.GetSafe <ProjectileController>(ProjectileCatalog.projectilePrefabProjectileControllerComponents, projectileIndex));
 }
Esempio n. 27
0
 // Token: 0x06001857 RID: 6231 RVA: 0x00069397 File Offset: 0x00067597
 public static GameObject GetProjectilePrefab(int projectileIndex)
 {
     return(HGArrayUtilities.GetSafe <GameObject>(ProjectileCatalog.projectilePrefabs, projectileIndex));
 }
Esempio n. 28
0
 // Token: 0x060003E2 RID: 994 RVA: 0x0000F5F2 File Offset: 0x0000D7F2
 public static string GetBodyName(int bodyIndex)
 {
     return(HGArrayUtilities.GetSafe <string>(BodyCatalog.bodyNames, bodyIndex));
 }
Esempio n. 29
0
        public override void OnLoad()
        {
            equipmentDef.name = "MysticsItems_MechanicalArm";
            ConfigManager.Balance.CreateEquipmentCooldownOption(equipmentDef, "Equipment: Mechanical Arm", 20f);
            equipmentDef.canDrop = true;
            ConfigManager.Balance.CreateEquipmentEnigmaCompatibleOption(equipmentDef, "Equipment: Mechanical Arm", true);
            ConfigManager.Balance.CreateEquipmentCanBeRandomlyTriggeredOption(equipmentDef, "Equipment: Mechanical Arm", false);
            equipmentDef.pickupModelPrefab = PrepareModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Equipment/Mechanical Arm/Model.prefab"));
            equipmentDef.pickupIconSprite  = Main.AssetBundle.LoadAsset <Sprite>("Assets/Equipment/Mechanical Arm/Icon.png");

            void ApplyToModels(GameObject model)
            {
                var mat = model.GetComponentInChildren <SkinnedMeshRenderer>().sharedMaterial;

                HopooShaderToMaterial.Standard.Apply(mat);
                HopooShaderToMaterial.Standard.Gloss(mat);
                HopooShaderToMaterial.Standard.Emission(mat, 1.5f, new Color32(191, 15, 3, 255));
            }

            ApplyToModels(equipmentDef.pickupModelPrefab);

            ModelPanelParameters modelPanelParameters = equipmentDef.pickupModelPrefab.GetComponent <ModelPanelParameters>();

            modelPanelParameters.minDistance = 6f;
            modelPanelParameters.maxDistance = 12f;

            itemDisplayPrefab = PrepareItemDisplayModel(Main.AssetBundle.LoadAsset <GameObject>("Assets/Equipment/Mechanical Arm/MovingModel.prefab"));
            onSetupIDRS      += () =>
            {
                AddDisplayRule("CommandoBody", "Chest", new Vector3(0.07816F, 0.25502F, -0.15061F), new Vector3(0F, 180F, 0F), new Vector3(0.07862F, 0.07862F, 0.07862F));
                AddDisplayRule("HuntressBody", "Chest", new Vector3(0.10676F, 0.14576F, -0.04849F), new Vector3(0F, 180F, 0F), new Vector3(0.03776F, 0.03776F, 0.03776F));
                AddDisplayRule("Bandit2Body", "Chest", new Vector3(0.00326F, 0.18527F, -0.12067F), new Vector3(0F, 185.5073F, 0F), new Vector3(0.05941F, 0.05941F, 0.05941F));
                AddDisplayRule("ToolbotBody", "Chest", new Vector3(2.63852F, 1.90061F, 0.02656F), new Vector3(0F, 180F, 0F), new Vector3(0.56946F, 0.56946F, 0.56946F));
                AddDisplayRule("EngiBody", "Chest", new Vector3(0.01994F, 0.13958F, -0.23417F), new Vector3(0F, 180F, 0F), new Vector3(0.06142F, 0.06142F, 0.06142F));
                AddDisplayRule("MageBody", "Chest", new Vector3(0.09002F, 0.03363F, -0.2332F), new Vector3(0F, 175.5407F, 0F), new Vector3(0.05358F, 0.05358F, 0.05358F));
                AddDisplayRule("MercBody", "Chest", new Vector3(0.00246F, 0.14756F, -0.16344F), new Vector3(0F, 202.2791F, 0F), new Vector3(0.08846F, 0.08846F, 0.08846F));
                AddDisplayRule("TreebotBody", "PlatformBase", new Vector3(0.53248F, 0.66126F, 0F), new Vector3(0F, 180F, 0F), new Vector3(0.19873F, 0.19873F, 0.19873F));
                AddDisplayRule("LoaderBody", "MechBase", new Vector3(-0.03249F, 0.00003F, -0.06065F), new Vector3(0F, 206.8929F, 0F), new Vector3(0.09891F, 0.09891F, 0.09796F));
                AddDisplayRule("CrocoBody", "SpineChest2", new Vector3(0F, -0.86934F, 0.00013F), new Vector3(0F, 0F, 0F), new Vector3(0.83816F, 0.83816F, 0.83816F));
                AddDisplayRule("CaptainBody", "Chest", new Vector3(-0.00812F, 0.17595F, -0.14316F), new Vector3(0F, 218.1953F, 0F), new Vector3(0.09604F, 0.09604F, 0.09604F));
                AddDisplayRule("ScavBody", "Backpack", new Vector3(6.49963F, 6.38849F, 0.00031F), new Vector3(0F, 180F, 0F), new Vector3(2.02387F, 2.02387F, 2.02387F));
                AddDisplayRule("EquipmentDroneBody", "HeadCenter", new Vector3(0.4758F, 0F, -0.48188F), new Vector3(270F, 180F, 0F), new Vector3(0.42601F, 0.42601F, 0.42601F));
                if (SoftDependencies.SoftDependenciesCore.itemDisplaysSniper)
                {
                    AddDisplayRule("SniperClassicBody", "Chest", new Vector3(0.1706F, 0.13246F, -0.20744F), new Vector3(0F, 180F, 0F), new Vector3(0.053F, 0.053F, 0.053F));
                }
                AddDisplayRule("RailgunnerBody", "Backpack", new Vector3(0.08517F, 0.21948F, 0.00002F), new Vector3(0F, 180F, 0F), new Vector3(0.09344F, 0.09344F, 0.09344F));
                AddDisplayRule("VoidSurvivorBody", "Center", new Vector3(-0.0074F, 0.3145F, -0.08637F), new Vector3(359.7796F, 219.7314F, 0.26983F), new Vector3(0.07043F, 0.07043F, 0.07043F));
            };

            ChildLocator childLocator = itemDisplayPrefab.AddComponent <ChildLocator>();

            NetworkedBodyAttachment networkedBodyAttachment = mechanicalArmControllerPrefab.AddComponent <NetworkedBodyAttachment>();

            networkedBodyAttachment.shouldParentToAttachedBody = true;
            networkedBodyAttachment.forceHostAuthority         = true;

            EntityStateMachine entityStateMachine = mechanicalArmControllerPrefab.AddComponent <EntityStateMachine>();

            entityStateMachine.initialStateType = entityStateMachine.mainStateType = new EntityStates.SerializableEntityStateType(typeof(MysticsItemsMechanicalArmState.Idle));

            NetworkStateMachine networkStateMachine = mechanicalArmControllerPrefab.AddComponent <NetworkStateMachine>();

            networkStateMachine.SetFieldValue("stateMachines", new EntityStateMachine[] {
                entityStateMachine
            });

            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(MysticsItemsMechanicalArmState));
            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(MysticsItemsMechanicalArmState.Idle));
            MysticsItemsContent.Resources.entityStateTypes.Add(typeof(MysticsItemsMechanicalArmState.Swing));

            ModelLocator modelLocator = mechanicalArmControllerPrefab.AddComponent <ModelLocator>();

            modelLocator.dontReleaseModelOnDeath  = false;
            modelLocator.autoUpdateModelTransform = false;
            modelLocator.dontDetatchFromParent    = true;
            modelLocator.preserveModel            = true;

            PrefabAPI.InstantiateClone(
                Main.AssetBundle.LoadAsset <GameObject>("Assets/Equipment/Mechanical Arm/MovingModel.prefab")
                .transform.Find("HitboxGroup").gameObject,
                "HitboxGroup",
                false
                ).transform.SetParent(mechanicalArmControllerPrefab.transform);
            Object.Destroy(itemDisplayPrefab.transform.Find("HitboxGroup").gameObject);
            HitBoxGroup hitBoxGroup = mechanicalArmControllerPrefab.transform.Find("HitboxGroup").gameObject.AddComponent <HitBoxGroup>();

            hitBoxGroup.groupName = "MysticsItems_MechanicalArmSwing";
            hitBoxGroup.hitBoxes  = new HitBox[]
            {
                mechanicalArmControllerPrefab.transform.Find("HitboxGroup/Hitbox").gameObject.AddComponent <HitBox>()
            };
            hitBoxGroup.gameObject.SetActive(true);

            AnimationCurve MakeGenericCurve()
            {
                return(new AnimationCurve {
                    keys = new Keyframe[] { new Keyframe(0, 1), new Keyframe(1, 1) }
                });
            }

            Transform armRoot = null;

            foreach (var child in itemDisplayPrefab.GetComponentsInChildren <Transform>())
            {
                var childName = child.name;
                if (childName == "arm.1")
                {
                    armRoot = child;
                    var ntp = new ChildLocator.NameTransformPair
                    {
                        name      = "Arm1",
                        transform = child
                    };
                    HGArrayUtilities.ArrayAppend(ref childLocator.transformPairs, ref ntp);
                }
                else
                {
                    if (childName.StartsWith("arm.", false, System.Globalization.CultureInfo.InvariantCulture))
                    {
                        var ntp = new ChildLocator.NameTransformPair
                        {
                            name      = "Arm" + childName.Remove(0, "arm.".Length),
                            transform = child
                        };
                        HGArrayUtilities.ArrayAppend(ref childLocator.transformPairs, ref ntp);

                        DynamicBone dynamicBone = child.gameObject.AddComponent <DynamicBone>();
                        dynamicBone.m_Root              = child;
                        dynamicBone.m_UpdateRate        = 60;
                        dynamicBone.m_UpdateMode        = DynamicBone.UpdateMode.Normal;
                        dynamicBone.m_Damping           = 0.8f;
                        dynamicBone.m_DampingDistrib    = MakeGenericCurve();
                        dynamicBone.m_Elasticity        = 0.1f;
                        dynamicBone.m_ElasticityDistrib = MakeGenericCurve();
                        dynamicBone.m_Stiffness         = 0.9f;
                        dynamicBone.m_StiffnessDistrib  = MakeGenericCurve();
                        dynamicBone.m_Inert             = 0f;
                        dynamicBone.m_InertDistrib      = MakeGenericCurve();
                        dynamicBone.m_Radius            = 0f;
                        dynamicBone.m_RadiusDistrib     = MakeGenericCurve();
                    }
                }
            }

            On.RoR2.EquipmentSlot.FixedUpdate += (orig, self) =>
            {
                orig(self);
                if (NetworkServer.active)
                {
                    MysticsItemsMechanicalArmState armController = MysticsItemsMechanicalArmState.FindMechanicalArmController(self.gameObject);

                    bool carryingThisEquipment = self.equipmentIndex == equipmentDef.equipmentIndex;
                    if (carryingThisEquipment != (armController != null))
                    {
                        if (carryingThisEquipment)
                        {
                            var armControllerInstance = Object.Instantiate <GameObject>(mechanicalArmControllerPrefab);
                            armControllerInstance.GetComponent <NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(self.gameObject);
                            return;
                        }
                        Object.Destroy(armController.gameObject);
                    }
                }
            };

            var swingEffectPrefab = MysticsItemsMechanicalArmState.Swing.swingEffectPrefab = Main.AssetBundle.LoadAsset <GameObject>("Assets/Equipment/Mechanical Arm/SwingEffect.prefab");
            ScaleParticleSystemDuration scaleParticleSystemDuration = swingEffectPrefab.AddComponent <ScaleParticleSystemDuration>();

            scaleParticleSystemDuration.particleSystems = swingEffectPrefab.GetComponentsInChildren <ParticleSystem>();
            scaleParticleSystemDuration.initialDuration = 1f;
            ShakeEmitter shakeEmitter = swingEffectPrefab.AddComponent <ShakeEmitter>();

            shakeEmitter.duration = 0.2f;
            shakeEmitter.radius   = 20f;
            shakeEmitter.wave     = new Wave
            {
                amplitude = 4f,
                frequency = 4f
            };
            shakeEmitter.amplitudeTimeDecay = true;
            shakeEmitter.shakeOnStart       = true;
            shakeEmitter.shakeOnEnable      = false;

            MysticsItemsMechanicalArmState.Swing.hitEffectPrefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/Effects/ImpactEffects/SawmerangImpact");
            var snd = ScriptableObject.CreateInstance <NetworkSoundEventDef>();

            snd.eventName = "MysticsItems_Play_mechanicalArm_impact";
            MysticsItemsContent.Resources.networkSoundEventDefs.Add(snd);
            MysticsItemsMechanicalArmState.Swing.impactSound = snd;

            GenericGameEvents.OnHitEnemy += GenericGameEvents_OnHitEnemy;

            RecalculateStatsAPI.GetStatCoefficients += RecalculateStatsAPI_GetStatCoefficients;
        }
Esempio n. 30
0
 // Token: 0x0600139F RID: 5023 RVA: 0x00053CC4 File Offset: 0x00051EC4
 public GenericSkill GetSkillAtIndex(int index)
 {
     return(HGArrayUtilities.GetSafe <GenericSkill>(this.allSkills, index));
 }