Example #1
0
 public static bool OnConsoleCommand_spawn_Prefix(NotificationCenter.Notification n)
 {
     if (n != null && n.data != null && n.data.Count > 0)
     {
         string text = (string)n.data[0];
         if (UWE.Utils.TryParseEnum <TechType>(text, out TechType techType) && techType != TechType.None)
         {
             if (CraftData.IsAllowed(techType))
             {
                 foreach (IDecorationItem item in DecorationsMod.DecorationItems)
                 {
                     // If item being spawned is one of our decoration items.
                     if (techType == item.TechType)
                     {
                         // If item being spawned is one of our new flora.
                         if (!string.IsNullOrEmpty(item.ClassID) && CustomFlora.AllPlants.Contains(item.ClassID))
                         {
                             GameObject prefabForTechType = CraftData.GetPrefabForTechType(techType, true);
                             if (prefabForTechType != null)
                             {
                                 int num = 1;
                                 int num2;
                                 if (n.data.Count > 1 && int.TryParse((string)n.data[1], out num2))
                                 {
                                     num = num2;
                                 }
                                 float maxDist = 12f;
                                 if (n.data.Count > 2)
                                 {
                                     maxDist = float.Parse((string)n.data[2]);
                                 }
                                 Debug.LogFormat("Spawning {0} {1}", new object[] { num, techType });
                                 for (int i = 0; i < num; i++)
                                 {
                                     GameObject gameObject = global::Utils.CreatePrefab(prefabForTechType, maxDist, i > 0);
                                     LargeWorldEntity.Register(gameObject);
                                     CrafterLogic.NotifyCraftEnd(gameObject, techType);
                                     gameObject.SendMessage("StartConstruction", SendMessageOptions.DontRequireReceiver);
                                     // Hide plant, show seed and enable pickupable
                                     PrefabsHelper.HidePlantAndShowSeed(gameObject.transform, item.ClassID);
                                 }
                             }
                             else
                             {
                                 ErrorMessage.AddDebug("Could not find prefab for TechType = " + techType);
                             }
                             // Dont call original function if item being spawned is one of our new flora.
                             return(false);
                         }
                         break;
                     }
                 }
             }
         }
     }
     // Give back execution to original function.
     return(true);
 }
Example #2
0
 public static bool OnConsoleCommand_item_Prefix(NotificationCenter.Notification n)
 {
     if (n != null && n.data != null && n.data.Count > 0)
     {
         string text = (string)n.data[0];
         if (UWE.Utils.TryParseEnum <TechType>(text, out TechType techType) && techType != TechType.None)
         {
             if (CraftData.IsAllowed(techType))
             {
                 foreach (IDecorationItem item in DecorationsMod.DecorationItems)
                 {
                     // If item being spawned is one of our decoration items.
                     if (techType == item.TechType)
                     {
                         // If item being spawned is one of our new flora.
                         if (!string.IsNullOrEmpty(item.ClassID) && CustomFlora.AllPlants.Contains(item.ClassID))
                         {
                             int num = 1;
                             if (n.data.Count > 1 && int.TryParse((string)n.data[1], out int num2))
                             {
                                 num = num2;
                             }
                             for (int i = 0; i < num; i++)
                             {
                                 GameObject gameObject = CraftData.InstantiateFromPrefab(techType, false);
                                 if (gameObject != null)
                                 {
                                     gameObject.transform.position = MainCamera.camera.transform.position + MainCamera.camera.transform.forward * 3f;
                                     CrafterLogic.NotifyCraftEnd(gameObject, techType);
                                     Pickupable component = gameObject.GetComponent <Pickupable>();
                                     if (component != null && !Inventory.main.Pickup(component, false))
                                     {
                                         ErrorMessage.AddError(Language.main.Get("InventoryFull"));
                                         // Hide plant, show seed and enable pickupable
                                         PrefabsHelper.HidePlantAndShowSeed(gameObject.transform, item.ClassID);
                                     }
                                 }
                             }
                             // Dont call original function if item being spawned is one of our new flora.
                             return(false);
                         }
                         break;
                     }
                 }
             }
         }
     }
     // Give back execution to original function.
     return(true);
 }
Example #3
0
        private static void InventoryAndWaterParkSetup()
        {
            LanguageHandler.SetTechTypeName(TechType.Rockgrub, "RockGrub");
            LanguageHandler.SetTechTypeTooltip(TechType.Rockgrub, "A small, luminescent scavenger");


            Sprite rockgrub = ImageUtils.LoadSpriteFromFile(Path.Combine(AssetsFolder, "RockGrub.png"));

            if (rockgrub != null)
            {
                SpriteHandler.RegisterSprite(TechType.Rockgrub, rockgrub);
            }
            CraftDataHandler.SetItemSize(TechType.Rockgrub, new Vector2int(1, 1));
            WaterParkCreature.waterParkCreatureParameters[TechType.Rockgrub] = new WaterParkCreatureParameters(0.03f, 0.7f, 1f, 1f, true);
            CraftData.IsAllowed(TechType.Rockgrub);
            BioReactorHandler.SetBioReactorCharge(TechType.Rockgrub, 350f);
        }
Example #4
0
        public static void randomBlueprintUnlock()
        {
            System.Random random = new System.Random();

            TechType[] blueprintTech = { TechType.BaseBioReactor, TechType.RocketBase, TechType.Constructor, TechType.Exosuit, TechType.BaseMoonpool, TechType.BaseNuclearReactor, TechType.PropulsionCannon, TechType.Seamoth, TechType.StasisRifle, TechType.ThermalPlant, TechType.Transfuser, TechType.Workbench, TechType.Techlight, TechType.LEDLight, TechType.CyclopsHullBlueprint, TechType.CyclopsBridgeBlueprint, TechType.CyclopsEngineBlueprint, TechType.CyclopsDockingBayBlueprint, TechType.Seaglide, TechType.Beacon, TechType.BatteryCharger, TechType.BaseObservatory, TechType.FiltrationMachine, TechType.CoffeeVendingMachine, TechType.BaseMapRoom, TechType.BaseLadder };
            int        randomNum     = random.Next(blueprintTech.Length);

            int counter = 0;

            while (CrafterLogic.IsCraftRecipeUnlocked(blueprintTech[randomNum]) && counter < 50)
            {
                randomNum = random.Next(blueprintTech.Length);
                counter++;
            }

            if (CraftData.IsAllowed(blueprintTech[randomNum]) && KnownTech.Add(blueprintTech[randomNum], true))
            {
                ErrorMessage.AddDebug("Unlocked " + Language.main.Get(blueprintTech[randomNum].AsString(false)));
            }
        }
 private static void OnConsoleCommand_lock(NotificationCenter.Notification n)
 {
     if (n != null && n.data != null)
     {
         string text = (string)n.data[0];
         if (text == "all")
         {
             List <TechType> list = new List <TechType>(KnownTech.GetTech());
             for (int i = 0; i < list.Count; i++)
             {
                 KnownTech.Remove(list[i]);
             }
             return;
         }
         TechType techType;
         if (UWE.Utils.TryParseEnum <TechType>(text, out techType) && CraftData.IsAllowed(techType))
         {
             bool flag = false | KnownTech.Remove(techType);
             PDAScanner.RemoveAllEntriesWhichUnlocks(techType);
             ErrorMessage.AddDebug("Locked " + Language.main.Get(techType.AsString(false)));
         }
     }
 }
        // Token: 0x06000009 RID: 9 RVA: 0x00002534 File Offset: 0x00000734
        public void OnConsoleCommand_spse(NotificationCenter.Notification n)
        {
            bool flag = n != null && n.data != null && n.data.Count > 0;

            if (flag)
            {
                string   text = (string)n.data[0];
                TechType techType;
                bool     flag2 = UWE.Utils.TryParseEnum <TechType>(text, out techType);
                if (flag2)
                {
                    bool flag3 = CraftData.IsAllowed(techType);
                    if (flag3)
                    {
                        CoroutineHost.StartCoroutine(SpawnTechType(n, techType));
                    }
                }
                else
                {
                    ErrorMessage.AddDebug("Unable to read " + text + " as TechType");
                }
            }
        }
    // Token: 0x06000016 RID: 22 RVA: 0x00003018 File Offset: 0x00001218
    public void OnConsoleCommand_waterparkspawn(NotificationCenter.Notification n)
    {
        bool flag = !Player.main.currentWaterPark;

        if (flag)
        {
            ErrorMessage.AddDebug("Not currently inside a waterpark!");
        }
        else
        {
            bool flag2 = n != null && n.data != null && n.data.Count > 0;
            if (flag2)
            {
                string   text = (string)n.data[0];
                TechType techType;
                bool     flag3 = UWE.Utils.TryParseEnum <TechType>(text, out techType);
                if (flag3)
                {
                    bool flag4 = CraftData.IsAllowed(techType);
                    if (flag4)
                    {
                        GameObject prefabForTechType = CraftData.GetPrefabForTechType(techType, true);
                        bool       flag5             = prefabForTechType != null;
                        if (flag5)
                        {
                            bool flag6 = prefabForTechType.GetComponent <Creature>();
                            if (flag6)
                            {
                                int  num = 1;
                                int  num2;
                                bool flag7 = n.data.Count > 1 && int.TryParse((string)n.data[1], out num2);
                                if (flag7)
                                {
                                    num = num2;
                                }
                                bool flag8 = n.data.Count > 2;
                                if (flag8)
                                {
                                    float num3 = float.Parse((string)n.data[2]);
                                }
                                Debug.Log(string.Format("Spawning {0} {1}", num, techType));
                                for (int i = 0; i < num; i++)
                                {
                                    WaterParkCreature.Born(techType, Player.main.currentWaterPark, Player.main.transform.position);
                                }
                            }
                            else
                            {
                                ErrorMessage.AddDebug("Not valid creature!");
                            }
                        }
                        else
                        {
                            ErrorMessage.AddDebug("Could not find prefab for TechType = " + techType);
                        }
                    }
                }
                else
                {
                    ErrorMessage.AddDebug("Could not parse " + text + " as TechType");
                }
            }
        }
    }