public void TransformToTargetGunSpecial(Gun targetGun)
        {
            int clipShotsRemaining = this.gun.ClipShotsRemaining;

            if (((VFXPool)m_currentlyPlayingChargeVFX_info.GetValue(this.gun)) != null)
            {
                ((VFXPool)m_currentlyPlayingChargeVFX_info.GetValue(this.gun)).DestroyAll();
                m_currentlyPlayingChargeVFX_info.SetValue(this.gun, null);
            }
            ProjectileVolleyData volley = this.gun.Volley;

            this.gun.RawSourceVolley = targetGun.RawSourceVolley;
            this.gun.singleModule    = targetGun.singleModule;
            this.gun.modifiedVolley  = null;
            if (targetGun.sprite)
            {
                this.gun.DefaultSpriteID = targetGun.sprite.spriteId;
                this.gun.GetSprite().SetSprite(targetGun.sprite.Collection, this.gun.DefaultSpriteID);
                if (base.spriteAnimator && targetGun.spriteAnimator)
                {
                    base.spriteAnimator.Library = targetGun.spriteAnimator.Library;
                }
                tk2dSpriteDefinition.AttachPoint[] attachPoints = this.gun.GetSprite().Collection.GetAttachPoints(this.gun.DefaultSpriteID);
                tk2dSpriteDefinition.AttachPoint   attachPoint;
                if (attachPoints != null)
                {
                    attachPoint = Array.Find(attachPoints, (tk2dSpriteDefinition.AttachPoint a) => a.name == "PrimaryHand");
                }
                else
                {
                    attachPoint = null;
                }
                tk2dSpriteDefinition.AttachPoint attachPoint2 = attachPoint;
                if (attachPoint2 != null)
                {
                    m_defaultLocalPosition_info.SetValue(this.gun, -attachPoint2.position);
                }
            }
            if (targetGun.GetBaseMaxAmmo() != this.gun.GetBaseMaxAmmo() && targetGun.GetBaseMaxAmmo() > 0)
            {
                int num = (!this.gun.InfiniteAmmo) ? this.gun.AdjustedMaxAmmo : this.gun.GetBaseMaxAmmo();
                this.gun.SetBaseMaxAmmo(targetGun.GetBaseMaxAmmo());
                if (this.gun.AdjustedMaxAmmo > 0 && num > 0 && this.gun.ammo > 0 && !this.gun.InfiniteAmmo)
                {
                    this.gun.ammo = Mathf.FloorToInt((float)this.gun.ammo / (float)num * (float)this.gun.AdjustedMaxAmmo);
                    this.gun.ammo = Mathf.Min(this.gun.ammo, this.gun.AdjustedMaxAmmo);
                }
                else
                {
                    this.gun.ammo = Mathf.Min(this.gun.ammo, this.gun.GetBaseMaxAmmo());
                }
            }
            this.gun.gunSwitchGroup = targetGun.gunSwitchGroup;
            this.gun.isAudioLoop    = targetGun.isAudioLoop;
            this.gun.gunClass       = targetGun.gunClass;
            if (!string.IsNullOrEmpty(this.gun.gunSwitchGroup))
            {
                AkSoundEngine.SetSwitch("WPN_Guns", this.gun.gunSwitchGroup, base.gameObject);
            }
            this.gun.currentGunDamageTypeModifiers = targetGun.currentGunDamageTypeModifiers;
            this.gun.carryPixelOffset                  = targetGun.carryPixelOffset;
            this.gun.carryPixelUpOffset                = targetGun.carryPixelUpOffset;
            this.gun.carryPixelDownOffset              = targetGun.carryPixelDownOffset;
            this.gun.leftFacingPixelOffset             = targetGun.leftFacingPixelOffset;
            this.gun.UsesPerCharacterCarryPixelOffsets = targetGun.UsesPerCharacterCarryPixelOffsets;
            this.gun.PerCharacterPixelOffsets          = targetGun.PerCharacterPixelOffsets;
            this.gun.gunPosition = targetGun.gunPosition;
            this.gun.forceFlat   = targetGun.forceFlat;
            if (targetGun.GainsRateOfFireAsContinueAttack != this.gun.GainsRateOfFireAsContinueAttack)
            {
                this.gun.GainsRateOfFireAsContinueAttack       = targetGun.GainsRateOfFireAsContinueAttack;
                this.gun.RateOfFireMultiplierAdditionPerSecond = targetGun.RateOfFireMultiplierAdditionPerSecond;
            }
            if (this.gun.barrelOffset && targetGun.barrelOffset)
            {
                this.gun.barrelOffset.localPosition = targetGun.barrelOffset.localPosition;
                m_originalBarrelOffsetPosition_info.SetValue(this.gun, targetGun.barrelOffset.localPosition);
            }
            if (this.gun.muzzleOffset && targetGun.muzzleOffset)
            {
                this.gun.muzzleOffset.localPosition = targetGun.muzzleOffset.localPosition;
                m_originalMuzzleOffsetPosition_info.SetValue(this.gun, targetGun.muzzleOffset.localPosition);
            }
            if (this.gun.chargeOffset && targetGun.chargeOffset)
            {
                this.gun.chargeOffset.localPosition = targetGun.chargeOffset.localPosition;
                m_originalChargeOffsetPosition_info.SetValue(this.gun, targetGun.chargeOffset.localPosition);
            }
            this.gun.reloadTime                    = targetGun.reloadTime;
            this.gun.blankDuringReload             = targetGun.blankDuringReload;
            this.gun.blankReloadRadius             = targetGun.blankReloadRadius;
            this.gun.reflectDuringReload           = targetGun.reflectDuringReload;
            this.gun.blankKnockbackPower           = targetGun.blankKnockbackPower;
            this.gun.blankDamageToEnemies          = targetGun.blankDamageToEnemies;
            this.gun.blankDamageScalingOnEmptyClip = targetGun.blankDamageScalingOnEmptyClip;
            this.gun.doesScreenShake               = targetGun.doesScreenShake;
            this.gun.gunScreenShake                = targetGun.gunScreenShake;
            this.gun.directionlessScreenShake      = targetGun.directionlessScreenShake;
            this.gun.AppliesHoming                 = targetGun.AppliesHoming;
            this.gun.AppliedHomingAngularVelocity  = targetGun.AppliedHomingAngularVelocity;
            this.gun.AppliedHomingDetectRadius     = targetGun.AppliedHomingDetectRadius;
            this.gun.GoopReloadsFree               = targetGun.GoopReloadsFree;
            this.gun.gunHandedness                 = targetGun.gunHandedness;
            m_cachedGunHandedness_info.SetValue(this.gun, null);
            this.gun.shootAnimation = targetGun.shootAnimation;
            this.gun.usesContinuousFireAnimation = targetGun.usesContinuousFireAnimation;
            this.gun.reloadAnimation             = targetGun.reloadAnimation;
            this.gun.emptyReloadAnimation        = targetGun.emptyReloadAnimation;
            this.gun.idleAnimation              = targetGun.idleAnimation;
            this.gun.chargeAnimation            = targetGun.chargeAnimation;
            this.gun.dischargeAnimation         = targetGun.dischargeAnimation;
            this.gun.emptyAnimation             = targetGun.emptyAnimation;
            this.gun.introAnimation             = targetGun.introAnimation;
            this.gun.finalShootAnimation        = targetGun.finalShootAnimation;
            this.gun.enemyPreFireAnimation      = targetGun.enemyPreFireAnimation;
            this.gun.dodgeAnimation             = targetGun.dodgeAnimation;
            this.gun.muzzleFlashEffects         = targetGun.muzzleFlashEffects;
            this.gun.usesContinuousMuzzleFlash  = targetGun.usesContinuousMuzzleFlash;
            this.gun.finalMuzzleFlashEffects    = targetGun.finalMuzzleFlashEffects;
            this.gun.reloadEffects              = targetGun.reloadEffects;
            this.gun.emptyReloadEffects         = targetGun.emptyReloadEffects;
            this.gun.activeReloadSuccessEffects = targetGun.activeReloadSuccessEffects;
            this.gun.activeReloadFailedEffects  = targetGun.activeReloadFailedEffects;
            this.gun.shellCasing                 = targetGun.shellCasing;
            this.gun.shellsToLaunchOnFire        = targetGun.shellsToLaunchOnFire;
            this.gun.shellCasingOnFireFrameDelay = targetGun.shellCasingOnFireFrameDelay;
            this.gun.shellsToLaunchOnReload      = targetGun.shellsToLaunchOnReload;
            this.gun.reloadShellLaunchFrame      = targetGun.reloadShellLaunchFrame;
            this.gun.clipObject                   = targetGun.clipObject;
            this.gun.clipsToLaunchOnReload        = targetGun.clipsToLaunchOnReload;
            this.gun.reloadClipLaunchFrame        = targetGun.reloadClipLaunchFrame;
            this.gun.IsTrickGun                   = targetGun.IsTrickGun;
            this.gun.TrickGunAlternatesHandedness = targetGun.TrickGunAlternatesHandedness;
            this.gun.alternateVolley              = targetGun.alternateVolley;
            this.gun.alternateShootAnimation      = targetGun.alternateShootAnimation;
            this.gun.alternateReloadAnimation     = targetGun.alternateReloadAnimation;
            this.gun.alternateIdleAnimation       = targetGun.alternateIdleAnimation;
            this.gun.alternateSwitchGroup         = targetGun.alternateSwitchGroup;
            this.gun.rampBullets                  = targetGun.rampBullets;
            this.gun.rampStartHeight              = targetGun.rampStartHeight;
            this.gun.rampTime = targetGun.rampTime;
            this.gun.usesDirectionalAnimator       = targetGun.usesDirectionalAnimator;
            this.gun.usesDirectionalIdleAnimations = targetGun.usesDirectionalIdleAnimations;
            Component[] targetGunComponents = targetGun.GetComponents <Component>();
            Component[] thisGunComponents   = this.GetComponents <Component>();
            foreach (Component targetGunComponent in targetGunComponents)
            {
                if (this.gun.GetComponent(targetGunComponent.GetType()) == null)
                {
                    Component comp = this.gun.gameObject.AddComponent(targetGunComponent.GetType());
                    comp.SetFields(targetGunComponent, includeProperties: true, includeFields: true);
                }
            }
            foreach (Component thisGunComponent in thisGunComponents)
            {
                if (thisGunComponent != this && targetGun.GetComponent(thisGunComponent.GetType()) == null)
                {
                    Destroy(thisGunComponent);
                }
            }
            if (base.aiAnimator)
            {
                Destroy(base.aiAnimator);
                base.aiAnimator = null;
            }
            if (targetGun.aiAnimator)
            {
                AIAnimator aianimator = base.gameObject.AddComponent <AIAnimator>();
                AIAnimator aiAnimator = targetGun.aiAnimator;
                aianimator.facingType               = aiAnimator.facingType;
                aianimator.DirectionParent          = aiAnimator.DirectionParent;
                aianimator.faceSouthWhenStopped     = aiAnimator.faceSouthWhenStopped;
                aianimator.faceTargetWhenStopped    = aiAnimator.faceTargetWhenStopped;
                aianimator.directionalType          = aiAnimator.directionalType;
                aianimator.RotationQuantizeTo       = aiAnimator.RotationQuantizeTo;
                aianimator.RotationOffset           = aiAnimator.RotationOffset;
                aianimator.ForceKillVfxOnPreDeath   = aiAnimator.ForceKillVfxOnPreDeath;
                aianimator.SuppressAnimatorFallback = aiAnimator.SuppressAnimatorFallback;
                aianimator.IsBodySprite             = aiAnimator.IsBodySprite;
                aianimator.IdleAnimation            = aiAnimator.IdleAnimation;
                aianimator.MoveAnimation            = aiAnimator.MoveAnimation;
                aianimator.FlightAnimation          = aiAnimator.FlightAnimation;
                aianimator.HitAnimation             = aiAnimator.HitAnimation;
                aianimator.OtherAnimations          = aiAnimator.OtherAnimations;
                aianimator.OtherVFX             = aiAnimator.OtherVFX;
                aianimator.OtherScreenShake     = aiAnimator.OtherScreenShake;
                aianimator.IdleFidgetAnimations = aiAnimator.IdleFidgetAnimations;
                base.aiAnimator = aianimator;
            }
            MultiTemporaryOrbitalSynergyProcessor component  = targetGun.GetComponent <MultiTemporaryOrbitalSynergyProcessor>();
            MultiTemporaryOrbitalSynergyProcessor component2 = base.GetComponent <MultiTemporaryOrbitalSynergyProcessor>();

            if (!component && component2)
            {
                Destroy(component2);
            }
            else if (component && !component2)
            {
                MultiTemporaryOrbitalSynergyProcessor multiTemporaryOrbitalSynergyProcessor = base.gameObject.AddComponent <MultiTemporaryOrbitalSynergyProcessor>();
                multiTemporaryOrbitalSynergyProcessor.RequiredSynergy = component.RequiredSynergy;
                multiTemporaryOrbitalSynergyProcessor.OrbitalPrefab   = component.OrbitalPrefab;
            }
            if (this.gun.RawSourceVolley != null)
            {
                for (int i = 0; i < this.gun.RawSourceVolley.projectiles.Count; i++)
                {
                    this.gun.RawSourceVolley.projectiles[i].ResetRuntimeData();
                }
            }
            else
            {
                this.gun.singleModule.ResetRuntimeData();
            }
            if (volley != null)
            {
                this.gun.RawSourceVolley = DuctTapeItem.TransferDuctTapeModules(volley, this.gun.RawSourceVolley, this.gun);
            }
            if (this.gun.CurrentOwner is PlayerController)
            {
                PlayerController playerController = this.gun.CurrentOwner as PlayerController;
                if (playerController.stats != null)
                {
                    playerController.stats.RecalculateStats(playerController, false, false);
                }
            }
            if (base.gameObject.activeSelf)
            {
                base.StartCoroutine((IEnumerator)HandleFrameDelayedTransformation_info.Invoke(this.gun, new object[0]));
            }
            this.gun.DidTransformGunThisFrame = true;
        }
示例#2
0
        public void InitializePlayerData(PlayerController p1, MidGamePlayerData playerData, bool isPlayerOne)
        {
            IsInitializingPlayerData = true;

            p1.MasteryTokensCollectedThisRun = playerData.MasteryTokensCollected;
            p1.CharacterUsesRandomGuns       = playerData.CharacterUsesRandomGuns;
            p1.HasTakenDamageThisRun         = playerData.HasTakenDamageThisRun;
            p1.HasFiredNonStartingGun        = playerData.HasFiredNonStartingGun;

            ChallengeManager.ChallengeModeType = playerData.ChallengeMode;

            if (levelSaved == GlobalDungeonData.ValidTilesets.FINALGEON)
            {
                p1.CharacterUsesRandomGuns = false;
            }
            if (levelSaved != GlobalDungeonData.ValidTilesets.FINALGEON || !(p1 is PlayerSpaceshipController))
            {
                p1.inventory.DestroyAllGuns();
                p1.RemoveAllPassiveItems();
                p1.RemoveAllActiveItems();

                if (playerData.passiveItems != null)
                {
                    for (int i = 0; i < playerData.passiveItems.Count; i++)
                    {
                        var item = (MidGamePassiveItemData)(object)playerData.passiveItems[i];

                        EncounterTrackable.SuppressNextNotification = true;
                        LootEngine.GivePrefabToPlayer(Registry.Items[item.ItemID].gameObject, p1);
                    }
                }
                if (playerData.activeItems != null)
                {
                    for (int j = 0; j < playerData.activeItems.Count; j++)
                    {
                        var item = (MidGameActiveItemData)(object)playerData.activeItems[j];

                        EncounterTrackable.SuppressNextNotification = true;
                        LootEngine.GivePrefabToPlayer(Registry.Items[item.ItemID].gameObject, p1);
                    }
                }
                if (playerData.guns != null)
                {
                    for (int k = 0; k < playerData.guns.Count; k++)
                    {
                        var gun = (MidGameGunData)(object)playerData.guns[k];

                        EncounterTrackable.SuppressNextNotification = true;
                        LootEngine.GivePrefabToPlayer(Registry.Items[gun.ItemID].gameObject, p1);
                    }
                    for (int l = 0; l < playerData.guns.Count; l++)
                    {
                        var savegun = (MidGameGunData)(object)playerData.guns[l];

                        for (int m = 0; m < p1.inventory.AllGuns.Count; m++)
                        {
                            var invgun = (PickupObject)(global::PickupObject)p1.inventory.AllGuns[m];
                            if (invgun.UniqueItemID == savegun.ItemID)
                            {
                                p1.inventory.AllGuns[m].MidGameDeserialize(playerData.guns[l].SerializedData);
                                for (int n = 0; n < playerData.guns[l].DuctTapedGunIDs.Count; n++)
                                {
                                    Gun gun = PickupObjectDatabase.GetById(playerData.guns[l].DuctTapedGunIDs[n]) as Gun;
                                    // TODO @save here's the call site for the duct tape id thing, fix to use a string list eventually
                                    if (gun)
                                    {
                                        DuctTapeItem.DuctTapeGuns(gun, p1.inventory.AllGuns[m]);
                                    }
                                }
                                p1.inventory.AllGuns[m].ammo = playerData.guns[l].CurrentAmmo;
                            }
                        }
                    }
                }
                if (playerData.CurrentHealth <= 0f && playerData.CurrentArmor <= 0f)
                {
                    p1.healthHaver.Armor = 0f;
                    p1.DieOnMidgameLoad();
                }
                else
                {
                    p1.healthHaver.ForceSetCurrentHealth(playerData.CurrentHealth);
                    p1.healthHaver.Armor = playerData.CurrentArmor;
                }
                if (isPlayerOne)
                {
                    p1.carriedConsumables.KeyBullets = playerData.CurrentKeys;
                    p1.carriedConsumables.Currency   = playerData.CurrentCurrency;
                }
                p1.Blanks = Mathf.Max(p1.Blanks, playerData.CurrentBlanks);
                if (playerData.activeItems != null)
                {
                    for (int num = 0; num < playerData.activeItems.Count; num++)
                    {
                        for (int num2 = 0; num2 < p1.activeItems.Count; num2++)
                        {
                            if (playerData.activeItems[num].PickupID == p1.activeItems[num2].PickupObjectId)
                            {
                                p1.activeItems[num2].MidGameDeserialize(playerData.activeItems[num].SerializedData);
                                p1.activeItems[num2].CurrentDamageCooldown = playerData.activeItems[num].DamageCooldown;
                                p1.activeItems[num2].CurrentRoomCooldown   = playerData.activeItems[num].RoomCooldown;
                                p1.activeItems[num2].CurrentTimeCooldown   = playerData.activeItems[num].TimeCooldown;
                                if (p1.activeItems[num2].consumable && playerData.activeItems[num].NumberOfUses > 0)
                                {
                                    p1.activeItems[num2].numberOfUses = playerData.activeItems[num].NumberOfUses;
                                }
                            }
                        }
                    }
                }
                if (playerData.passiveItems != null)
                {
                    for (int num3 = 0; num3 < playerData.passiveItems.Count; num3++)
                    {
                        for (int num4 = 0; num4 < p1.passiveItems.Count; num4++)
                        {
                            if (playerData.passiveItems[num3].PickupID == p1.passiveItems[num4].PickupObjectId)
                            {
                                p1.passiveItems[num4].MidGameDeserialize(playerData.passiveItems[num3].SerializedData);
                            }
                        }
                    }
                }
                if (playerData.ownerlessStatModifiers != null)
                {
                    if (p1.ownerlessStatModifiers == null)
                    {
                        p1.ownerlessStatModifiers = new List <StatModifier>();
                    }
                    for (int num5 = 0; num5 < playerData.ownerlessStatModifiers.Count; num5++)
                    {
                        p1.ownerlessStatModifiers.Add(playerData.ownerlessStatModifiers[num5]);
                    }
                }
                if (levelSaved == GlobalDungeonData.ValidTilesets.FINALGEON)
                {
                    p1.ResetToFactorySettings(true, true, false);
                }
                if (p1 && p1.stats != null)
                {
                    p1.stats.RecalculateStats(p1, false, false);
                }
                if (playerData.HasBloodthirst)
                {
                    p1.gameObject.GetOrAddComponent <Bloodthirst>();
                }
            }
            IsInitializingPlayerData = false;
            EncounterTrackable.SuppressNextNotification = false;
        }