コード例 #1
0
ファイル: LichsGun.cs プロジェクト: SpecialAPI/LichItems
 private void Update()
 {
     if (Dungeon.IsGenerating || Dungeon.ShouldAttemptToLoadFromMidgameSave)
     {
         return;
     }
     if (this.m_gun && this.m_gun.CurrentOwner is PlayerController)
     {
         PlayerController playerController = this.m_gun.CurrentOwner as PlayerController;
         if (!this.m_gun.enabled)
         {
             return;
         }
         if (LichsBookItem.PlayerHasActiveSynergy(playerController, this.SynergyToCheck) && !this.m_transformed)
         {
             this.m_transformed = true;
             this.m_gun.TransformToTargetGun(PickupObjectDatabase.GetById(this.SynergyGunId) as Gun);
             if (this.ShouldResetAmmoAfterTransformation)
             {
                 this.m_gun.ammo = this.ResetAmmoCount;
             }
         }
         else if (!LichsBookItem.PlayerHasActiveSynergy(playerController, this.SynergyToCheck) && this.m_transformed)
         {
             this.m_transformed = false;
             this.m_gun.TransformToTargetGun(PickupObjectDatabase.GetById(this.NonSynergyGunId) as Gun);
             if (this.ShouldResetAmmoAfterTransformation)
             {
                 this.m_gun.ammo = this.ResetAmmoCount;
             }
         }
     }
     else if (this.m_gun && !this.m_gun.CurrentOwner && this.m_transformed)
     {
         this.m_transformed = false;
         this.m_gun.TransformToTargetGun(PickupObjectDatabase.GetById(this.NonSynergyGunId) as Gun);
         if (this.ShouldResetAmmoAfterTransformation)
         {
             this.m_gun.ammo = this.ResetAmmoCount;
         }
     }
     this.ShouldResetAmmoAfterTransformation = false;
 }
コード例 #2
0
        private void CreateCompanion(PlayerController owner)
        {
            if (this.PreventRespawnOnFloorLoad)
            {
                return;
            }
            if (this.BabyGoodMimicOrbitalOverridden)
            {
                GameObject extantCompanion = PlayerOrbitalItem.CreateOrbital(owner, (!this.OverridePlayerOrbitalItem.OrbitalFollowerPrefab) ? this.OverridePlayerOrbitalItem.OrbitalPrefab.gameObject : this.OverridePlayerOrbitalItem.OrbitalFollowerPrefab.gameObject, this.OverridePlayerOrbitalItem.OrbitalFollowerPrefab, null);
                this.SetExtantCompanion(extantCompanion);
                return;
            }
            string guid = this.CompanionGuid;

            this.m_lastActiveSynergyTransformation = -1;
            if (this.UsesAlternatePastPrefab && GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.CHARACTER_PAST)
            {
                guid = this.CompanionPastGuid;
            }
            else
            {
                if (this.UseAdvancedSynergies && this.AdvancedSynergies.Length > 0)
                {
                    for (int i = 0; i < this.AdvancedSynergies.Length; i++)
                    {
                        if ((this.AdvancedSynergies[i].UseStringSynergyDetectionInstead && LichsBookItem.PlayerHasActiveSynergy(this.m_owner, this.AdvancedSynergies[i].RequiredStringSynergy)) || (!this.AdvancedSynergies[i].UseStringSynergyDetectionInstead &&
                                                                                                                                                                                                    owner.HasActiveBonusSynergy(this.AdvancedSynergies[i].RequiredSynergy, false)))
                        {
                            guid = this.AdvancedSynergies[i].SynergyCompanionGuid;
                            this.m_lastActiveSynergyTransformation = i;
                        }
                    }
                }
                else if (this.Synergies.Length > 0)
                {
                    for (int i = 0; i < this.Synergies.Length; i++)
                    {
                        if (owner.HasActiveBonusSynergy(this.Synergies[i].RequiredSynergy, false))
                        {
                            guid = this.Synergies[i].SynergyCompanionGuid;
                            this.m_lastActiveSynergyTransformation = i;
                        }
                    }
                }
            }
            AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(guid);
            Vector3 vector       = owner.transform.position;

            if (GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER)
            {
                vector += new Vector3(1.125f, -0.3125f, 0f);
            }
            GameObject extantCompanion2 = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity);

            this.SetExtantCompanion(extantCompanion2);
            CompanionController orAddComponent = this.ExtantCompanion.GetOrAddComponent <CompanionController>();

            orAddComponent.Initialize(owner);
            if (orAddComponent.specRigidbody)
            {
                PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false);
            }
            if (orAddComponent.companionID == CompanionController.CompanionIdentifier.BABY_GOOD_MIMIC)
            {
                GameStatsManager.Instance.SetFlag(GungeonFlags.ITEMSPECIFIC_GOT_BABY_MIMIC, true);
            }
        }
コード例 #3
0
 protected override void Update()
 {
     base.Update();
     if (!Dungeon.IsGenerating && this.m_owner && this.UseAdvancedSynergies && this.AdvancedSynergies.Length > 0)
     {
         if (!this.UsesAlternatePastPrefab || GameManager.Instance.CurrentLevelOverrideState != GameManager.LevelOverrideState.CHARACTER_PAST)
         {
             bool flag = false;
             for (int i = this.AdvancedSynergies.Length - 1; i >= 0; i--)
             {
                 if ((this.AdvancedSynergies[i].UseStringSynergyDetectionInstead && LichsBookItem.PlayerHasActiveSynergy(this.m_owner, this.AdvancedSynergies[i].RequiredStringSynergy)) || (!this.AdvancedSynergies[i].UseStringSynergyDetectionInstead &&
                                                                                                                                                                                             this.m_owner.HasActiveBonusSynergy(this.AdvancedSynergies[i].RequiredSynergy, false)))
                 {
                     if (this.m_lastActiveSynergyTransformation != i)
                     {
                         this.DestroyCompanion();
                         this.CreateCompanion(this.m_owner);
                     }
                     flag = true;
                     break;
                 }
             }
             if (!flag && this.m_lastActiveSynergyTransformation != -1)
             {
                 this.DestroyCompanion();
                 this.CreateCompanion(this.m_owner);
             }
         }
     }
 }