示例#1
0
        public static void AllItemsAre()
        {
            if (itemPool.Count == 0)
            {
                return;
            }

            foreach (PickupObject pickupObject in UnityEngine.Object.FindObjectsOfType <PickupObject>())
            {
                //ETGModConsole.Log("ID: " + pickupObject.PickupObjectId + " | InstanceID: " + pickupObject.GetInstanceID() + " | Name: " + pickupObject.name);

                bool continueThen = false;
                foreach (PickupObject item in itemPool)
                {
                    if (item.PickupObjectId == pickupObject.PickupObjectId)
                    {
                        continueThen = true;
                        break;
                    }
                }

                if (continueThen)
                {
                    continue;
                }

                if (pickupObject.GetComponentInParent <AIActor>() != null)
                {
                    if (pickupObject.GetComponentInParent <AIActor>().IsMimicEnemy)
                    {
                        continue;
                    }
                }

                if (pickupObject.GetComponentInParent <BeholsterTentacleController>() != null)
                {
                    continue;
                }

                if (GameManager.Instance.PrimaryPlayer != null)
                {
                    if (GameManager.Instance.PrimaryPlayer.characterIdentity == PlayableCharacters.Pilot)
                    {
                        if (pickupObject.PickupObjectId == Game.Items.Get("trusty_lockpicks").PickupObjectId)
                        {
                            continue;
                        }
                    }
                    else if (GameManager.Instance.PrimaryPlayer.characterIdentity == PlayableCharacters.Convict)
                    {
                        if (pickupObject.PickupObjectId == Game.Items.Get("molotov").PickupObjectId)
                        {
                            continue;
                        }
                    }
                    else if (GameManager.Instance.PrimaryPlayer.characterIdentity == PlayableCharacters.Soldier)
                    {
                        if (pickupObject.PickupObjectId == Game.Items.Get("supply_drop").PickupObjectId)
                        {
                            continue;
                        }
                    }
                    else if (GameManager.Instance.PrimaryPlayer.characterIdentity == PlayableCharacters.Robot)
                    {
                        if (pickupObject.PickupObjectId == Game.Items.Get("coolant_leak").PickupObjectId)
                        {
                            continue;
                        }
                    }
                }

                if (!settingBools[2] && pickupObject.PickupObjectId == glassGuonID)
                {
                    continue;
                }
                else if (!settingBools[12] && pickupObject.PickupObjectId == mapItemID)
                {
                    continue;
                }
                else if (!settingBools[1] && pickupObject.PickupObjectId == junkID)
                {
                    continue;
                }
                else if (pickupObject.PickupObjectId == keyID)
                {
                    continue;
                }
                else if (pickupObject.PickupObjectId == heartID)
                {
                    continue;
                }
                else if (pickupObject.PickupObjectId == GlobalItemIds.Blank)
                {
                    continue;
                }
                else if (pickupObject.PickupObjectId == halfHeartID)
                {
                    continue;
                }



                if (pickupObject as Gun != null && settingBools[3])
                {
                    Gun gun = pickupObject.GetComponent <Gun>();
                    if (gun.HasBeenPickedUp)
                    {
                        safeItems.Add(gun.GetInstanceID());
                        continue;
                    }
                    else
                    {
                        if (!safeItems.Contains(gun.GetInstanceID()))
                        {
                            LootEngine.SpawnItem(itemPool.ElementAt(UnityEngine.Random.Range(0, itemPool.Count)).gameObject, pickupObject.transform.position, Vector2.up, 1.0f);
                            UnityEngine.Object.Destroy(gun.gameObject);
                        }
                    }
                }
                else if (pickupObject as PassiveItem != null && settingBools[4])
                {
                    PassiveItem passiveItem = pickupObject.GetComponent <PassiveItem>();
                    if (passiveItem.PickedUp)
                    {
                        safeItems.Add(passiveItem.GetInstanceID());
                        continue;
                    }
                    else
                    {
                        if (!safeItems.Contains(passiveItem.GetInstanceID()))
                        {
                            {
                                LootEngine.SpawnItem(itemPool.ElementAt(UnityEngine.Random.Range(0, itemPool.Count)).gameObject, pickupObject.transform.position, Vector2.up, 1.0f);
                                UnityEngine.Object.Destroy(passiveItem.gameObject);
                            }
                        }
                    }
                }
                else if (pickupObject as PlayerItem != null && settingBools[5])
                {
                    PlayerItem playerItem = pickupObject.GetComponent <PlayerItem>();
                    if (playerItem.LastOwner != null)
                    {
                        safeItems.Add(playerItem.GetInstanceID());
                        continue;
                    }
                    else
                    {
                        if (!safeItems.Contains(playerItem.GetInstanceID()))
                        {
                            LootEngine.SpawnItem(itemPool.ElementAt(UnityEngine.Random.Range(0, itemPool.Count)).gameObject, pickupObject.transform.position, Vector2.up, 1.0f);
                            UnityEngine.Object.Destroy(playerItem.gameObject);
                        }
                    }
                }
                else
                {
                    continue;
                }
            }

            foreach (ShopItemController shopItem in UnityEngine.Object.FindObjectsOfType <ShopItemController>())
            {
                bool continueSoon = false;
                foreach (PickupObject itemToTest in itemPool)
                {
                    if (itemToTest.PickupObjectId == shopItem.item.PickupObjectId)
                    {
                        continueSoon = true;
                    }
                }

                if (!settingBools[3] && shopItem.item is Gun)
                {
                    continue;
                }
                else if (!settingBools[4] && shopItem.item is PassiveItem)
                {
                    continue;
                }
                else if (!settingBools[5] && shopItem.item is PlayerItem)
                {
                    continue;
                }

                if (continueSoon)
                {
                    continue;
                }
                else
                {
                    if (StaticReferenceManager.AllShops.Count > 0)
                    {
                        if (!settingBools[6] && (shopItem.item.PickupObjectId == halfHeartID || shopItem.item.PickupObjectId == heartID))
                        {
                            continue;
                        }
                        else if (!settingBools[7] && shopItem.item.PickupObjectId == shieldID)
                        {
                            continue;
                        }
                        else if (!settingBools[8] && shopItem.item.PickupObjectId == blankID)
                        {
                            continue;
                        }
                        else if (!settingBools[9] && (shopItem.item.PickupObjectId == ammoID || shopItem.item.PickupObjectId == spreadAmmoID))
                        {
                            continue;
                        }
                        else if (!settingBools[10] && shopItem.item.PickupObjectId == keyID)
                        {
                            continue;
                        }
                        else if (!settingBools[2] && shopItem.item.PickupObjectId == glassGuonID)
                        {
                            continue;
                        }
                        else if (!settingBools[12] && shopItem.item.PickupObjectId == mapItemID)
                        {
                            continue;
                        }
                        else if (!settingBools[1] && shopItem.item.PickupObjectId == junkID)
                        {
                            continue;
                        }
                        else if (shopItem.IsResourcefulRatKey)
                        {
                            continue;
                        }
                        else
                        {
                            float distanceToClosest      = 555555f;
                            BaseShopController shopToUse = StaticReferenceManager.AllShops.First();
                            foreach (BaseShopController shop in StaticReferenceManager.AllShops)
                            {
                                foreach (Transform tran in shop.spawnPositions)
                                {
                                    if (shopItem.GetDistanceToPoint(tran.position) < distanceToClosest)
                                    {
                                        distanceToClosest = shopItem.GetDistanceToPoint(tran.position);
                                        shopToUse         = shop;
                                    }
                                }
                                foreach (Transform tran in shop.spawnPositionsGroup2)
                                {
                                    if (shopItem.GetDistanceToPoint(tran.position) < distanceToClosest)
                                    {
                                        distanceToClosest = shopItem.GetDistanceToPoint(tran.position);
                                        shopToUse         = shop;
                                    }
                                }
                            }
                            int priceBefore = shopItem.CurrentPrice;
                            shopItem.Initialize(itemPool.ElementAt(UnityEngine.Random.Range(0, itemPool.Count)), shopToUse);
                            if (!settingBools[11])
                            {
                                shopItem.OverridePrice = priceBefore;
                            }
                            else if (shopItem.OverridePrice == 9999)
                            {
                                ETGModConsole.Log("New Payday item in shop... adjusting price to avoid 9999 cost item");
                                shopItem.OverridePrice = 69;                                 //heheheheheheh
                            }
                        }
                    }
                }
            }

            foreach (RewardPedestal pedestal in UnityEngine.Object.FindObjectsOfType <RewardPedestal>())
            {
                if (pedestal.pickedUp || pedestal.contents == null)
                {
                    continue;
                }

                bool conAfter = false;
                foreach (PickupObject idem in itemPool)
                {
                    if (pedestal.contents.PickupObjectId == idem.PickupObjectId)
                    {
                        conAfter = true;
                    }
                }

                if (conAfter)
                {
                    continue;
                }

                if (!settingBools[3] && pedestal.contents is Gun)
                {
                    continue;
                }
                else if (!settingBools[4] && pedestal.contents is PassiveItem)
                {
                    continue;
                }
                else if (!settingBools[5] && pedestal.contents is PlayerItem)
                {
                    continue;
                }
                else if (!settingBools[2] && pedestal.contents.PickupObjectId == glassGuonID)
                {
                    continue;
                }
                else if (!settingBools[12] && pedestal.contents.PickupObjectId == mapItemID)
                {
                    continue;
                }
                else if (!settingBools[1] && pedestal.contents.PickupObjectId == junkID)
                {
                    continue;
                }
                else if (!settingBools[13] && pedestal.contents.PickupObjectId == crestID)
                {
                    continue;
                }
                else if (!settingBools[0] && masterRoundIDs.Contains(pedestal.contents.PickupObjectId))
                {
                    continue;
                }

                PickupObject idemInstead = itemPool[UnityEngine.Random.Range(0, itemPool.Count)];

                pedestal.contents             = null;
                pedestal.IsBossRewardPedestal = false;
                pedestal.UsesSpecificItem     = true;
                pedestal.SpecificItemId       = idemInstead.PickupObjectId;
                pedestal.ForceConfiguration();

                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().sprite.Collection = idemInstead.sprite.Collection;
                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().sprite.spriteId   = idemInstead.sprite.spriteId;
                SpriteOutlineManager.AddOutlineToSprite(pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>(), Color.black, 0.1f, 0.05f, SpriteOutlineManager.OutlineType.NORMAL);
                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().HeightOffGround        = 0.25f;
                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().depthUsesTrimmedBounds = true;
                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().PlaceAtPositionByAnchor(pedestal.spawnTransform.position, tk2dSprite.Anchor.LowerCenter);
                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().transform.position = pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().transform.position.Quantize(1f / 16f);
                pedestal.spawnTransform.GetComponentInChildren <tk2dSprite>().UpdateZDepth();
            }
        }