예제 #1
0
    IEnumerator Start()
    {
        RNotification notification = FindObjectOfType <RNotify>().AddNotification(RNotify.NotificationType.spinning, "Loading MoreStorages...");

        var bundleLoadRequest = AssetBundle.LoadFromFileAsync("mods\\ModData\\MoreStorages\\morestorages.assets");

        yield return(bundleLoadRequest);

        assetbundle = bundleLoadRequest.assetBundle;
        if (assetbundle == null)
        {
            RConsole.LogError("Failed to load AssetBundle for MoreStorages!");
            notification.Close();
            yield return(null);
        }

        List <Item_Base> list = Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").GetValue <List <Item_Base> >();

        Item_Base Placeable_MoreStorages_MinecraftChest = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_MinecraftChest");

        Placeable_MoreStorages_MinecraftChest.Initialize(9845, "Placeable_MoreStorages_MinecraftChest", 1);
        list.Add(Placeable_MoreStorages_MinecraftChest);
        RegisterChest(Placeable_MoreStorages_MinecraftChest);

        Item_Base Placeable_MoreStorages_Barrel = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Barrel");

        Placeable_MoreStorages_Barrel.Initialize(9846, "Placeable_MoreStorages_Barrel", 1);
        list.Add(Placeable_MoreStorages_Barrel);
        RegisterChest(Placeable_MoreStorages_Barrel);

        Item_Base Placeable_MoreStorages_Crate = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Crate");

        Placeable_MoreStorages_Crate.Initialize(9847, "Placeable_MoreStorages_Crate", 1);
        list.Add(Placeable_MoreStorages_Crate);
        RegisterChest(Placeable_MoreStorages_Crate);

        Item_Base Placeable_MoreStorages_Luggage = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Luggage");

        Placeable_MoreStorages_Luggage.Initialize(9848, "Placeable_MoreStorages_Luggage", 1);
        list.Add(Placeable_MoreStorages_Luggage);
        RegisterChest(Placeable_MoreStorages_Luggage);

        Item_Base Placeable_MoreStorages_MedievalChest = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_MedievalChest");

        Placeable_MoreStorages_MedievalChest.Initialize(9849, "Placeable_MoreStorages_MedievalChest", 1);
        list.Add(Placeable_MoreStorages_MedievalChest);
        RegisterChest(Placeable_MoreStorages_MedievalChest);

        Item_Base Placeable_MoreStorages_Package = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("Placeable_MoreStorages_Package");

        Placeable_MoreStorages_Package.Initialize(9850, "Placeable_MoreStorages_Package", 1);
        list.Add(Placeable_MoreStorages_Package);
        RegisterChest(Placeable_MoreStorages_Package);


        Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").SetValue(list);

        notification.Close();
        RConsole.Log("MoreStorages has been successfully loaded!");
    }
예제 #2
0
 private static void WriteFile <T>(T serializableObject, string path) where T : class
 {
     try
     {
         var serializer = new XmlSerializer(typeof(T));
         using (var writer = new StreamWriter(path))
         {
             serializer.Serialize(writer, serializableObject);
         }
     }
     catch (Exception ex)
     {
         RConsole.LogError(string.Format("{0}: Could not write file. Exception: {1}.", ModNamePrefix, ex));
     }
 }
예제 #3
0
 private static T ReadFile <T>(string filePath) where T : class
 {
     try
     {
         var serializer = new XmlSerializer(typeof(T));
         using (var reader = new StreamReader(filePath))
         {
             return((T)serializer.Deserialize(reader));
         }
     }
     catch (Exception ex)
     {
         RConsole.LogError(string.Format("{0}: Could not read file. Exception: {1}.", ModNamePrefix, ex));
         return(null);
     }
 }
예제 #4
0
    public void SpawnItem()
    {
        Item_Base currentItem = null;

        string[] lastCommand = RConsole.lastCommands.LastOrDefault <string>().Split(' ');
        if (lastCommand.Length == 1)
        {
            RConsole.Log("Please include an item name after eg \"spawn Paddle\"");
        }
        else
        {
            string itemName = lastCommand[1];
            int    amount   = 1;
            if (lastCommand.Length > 2)
            {
                string itemAmount = lastCommand[2];
                int    result;
                if (int.TryParse(itemAmount, out result))
                {
                    amount = result;
                }
            }

            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].UniqueName == itemName)
                {
                    PlayerInventory pi = ComponentManager <PlayerInventory> .Value;
                    try
                    {
                        pi.AddItem(items[i].UniqueName, amount);
                        RConsole.Log("Have given player " + amount + " " + items[i].UniqueName);
                    }
                    catch (Exception e)
                    {
                        RConsole.LogError(e.ToString());
                    }
                    return;
                }
            }

            RConsole.Log("Couldn't find the item called " + itemName);
        }
    }
예제 #5
0
    private void SaveNetFilterMapping()
    {
        var currentConfigurationFilePath      = GetConfigurationFilePath();
        var currentConfigurationFileDirectory = Path.GetDirectoryName(currentConfigurationFilePath);

        if (currentConfigurationFileDirectory == null)
        {
            RConsole.LogError(string.Format("{0}: Cannot determine save-path.", ModNamePrefix));
            return;
        }

        if (!Directory.Exists(currentConfigurationFileDirectory))
        {
            Directory.CreateDirectory(currentConfigurationFileDirectory);
        }

        var netfilterMapping = GetCurrentFilterMapping();

        WriteFile(netfilterMapping, currentConfigurationFilePath);
    }
예제 #6
0
    IEnumerator Start()
    {
        RNotification notification = FindObjectOfType <RNotify>().AddNotification(RNotify.NotificationType.spinning, "Loading SolarPanelMod...");

        var bundleLoadRequest = AssetBundle.LoadFromFileAsync("mods\\ModData\\SolarPanel\\solarpanel.assets");

        yield return(bundleLoadRequest);

        assetbundle = bundleLoadRequest.assetBundle;
        if (assetbundle == null)
        {
            RConsole.LogError("Failed to load AssetBundle for solarpanel!");
            notification.Close();
            yield return(null);
        }

        List <Item_Base> list = Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").GetValue <List <Item_Base> >();

        Item_Base placeable_solarpanel = (Item_Base)assetbundle.LoadAsset <ScriptableObject>("placeable_solarpanel");

        placeable_solarpanel.settings_buildable.GetBlockPrefab(0).gameObject.AddComponent <SolarPanelObject>();
        SolarPanelObject obj = placeable_solarpanel.settings_buildable.GetBlockPrefab(0).gameObject.AddComponent <SolarPanelObject>();

        Traverse.Create(placeable_solarpanel.settings_buildable.GetBlockPrefab(0).GetComponentInChildren <Battery>()).Field("networkBehaviourID").SetValue(obj);
        placeable_solarpanel.Initialize(999, "placeable_solarpanel", 1);

        list.Add(placeable_solarpanel);

        Traverse.Create(typeof(ItemManager)).Field("allAvailableItems").SetValue(list);

        RAPI.AddItemToBlockQuadType(placeable_solarpanel, RBlockQuadType.quad_floor);
        RAPI.AddItemToBlockQuadType(placeable_solarpanel, RBlockQuadType.quad_foundation);
        RAPI.AddItemToBlockQuadType(placeable_solarpanel, RBlockQuadType.quad_table);

        notification.Close();
    }
예제 #7
0
 private void Error(string message)
 {
     RConsole.LogError("<color=#e74c3c>[error]</color>\t<b>traxam's WaterWheels:</b> " + message);
 }