コード例 #1
0
        internal static void Setup()
        {
            if (setup)
            {
                return;
            }
            setup = true;

            PlayerUpgrades          = new List <IUpgrade>();
            Player_Upgrades_Missing = new List <string>();

            Plot_Upgrades_Cache = new List <Plot_Upgrades>();
            Plot_Upgrade_Data   = new Dictionary <PlotID, Dictionary <string, Dictionary <string, byte[]> > >();

            foreach (HookUID hk in hooks)
            {
                SiscosHooks.unregister(hk);
            }

            hooks.Add(SiscosHooks.register(HOOK_ID.Game_Saved, onGameSaved));
            hooks.Add(SiscosHooks.register(HOOK_ID.Pre_Game_Loaded, onPreGameLoaded));
            hooks.Add(SiscosHooks.register(HOOK_ID.Post_Game_Loaded, onPostGameLoaded));
            hooks.Add(SiscosHooks.register(HOOK_ID.Spawn_Player_Upgrades_UI, onSpawn_PlayerUpgrades_Kiosk));
            hooks.Add(SiscosHooks.register(HOOK_ID.Spawn_Plot_Upgrades_UI, onSpawn_PlotUpgrades_Kiosk));
            hooks.Add(SiscosHooks.register(HOOK_ID.Plot_Load_Upgrades, onPlot_Loaded_Upgrades));
            hooks.Add(SiscosHooks.register(HOOK_ID.Level_Loaded, onLevelLoaded));
            hooks.Add(SiscosHooks.register(HOOK_ID.Demolished_Land_Plot, onPlot_Demolished));
        }
コード例 #2
0
        private void Handle_Entity_Destroyed()
        {
            Identifiable ident = base.gameObject.GetComponent <Identifiable>();

            Identifiable.Id ID = ident ? ident.id : Identifiable.Id.NONE;

            object return_value = new object();

            SiscosHooks.call(HOOK_ID.Destroyed_Entity, base.gameObject, ref return_value, new object[] { ID });

            if (Identifiable.IsSlime(ID) || Identifiable.IsLargo(ID) || Identifiable.IsGordo(ID))
            {
                SiscosHooks.call(HOOK_ID.Destroyed_Slime, base.gameObject, ref return_value, new object[] { ID });
            }

            if (Identifiable.IsAnimal(ID))
            {
                SiscosHooks.call(HOOK_ID.Destroyed_Animal, base.gameObject, ref return_value, new object[] { ID });
            }

            if (Identifiable.IsFood(ID))
            {
                SiscosHooks.call(HOOK_ID.Destroyed_Food, base.gameObject, ref return_value, new object[] { ID });
            }
        }
コード例 #3
0
        private void Handle_Garden_Patch_Destroyed()
        {
            SpawnResource plot = base.gameObject.GetComponent <SpawnResource>();

            SpawnResource.Id ID = plot ? plot.id : SpawnResource.Id.NONE;

            object return_value = new object();

            SiscosHooks.call(HOOK_ID.Destroyed_Garden_Patch, base.gameObject, ref return_value, new object[] { ID });
        }
コード例 #4
0
        private void Handle_Land_Plot_Destroyed()
        {
            LandPlot plot = base.gameObject.GetComponent <LandPlot>();

            LandPlot.Id ID = plot ? plot.id : LandPlot.Id.NONE;

            object return_value = new object();

            SiscosHooks.call(HOOK_ID.Destroyed_Land_Plot, plot, ref return_value, new object[] { ID });
        }
コード例 #5
0
        internal static Sisco_Return Ext_Identifiable_Spawn(ref object sender, ref object[] args, ref object return_value)
        {
            Identifiable ident = sender as Identifiable;

            if (ident.id == Identifiable.Id.PLAYER)
            {
                SiscosHooks.call(HOOK_ID.Player_Spawn, ident.gameObject, ref return_value, args);
            }
            return(null);
        }
コード例 #6
0
        internal static Sisco_Return Ext_Demolish_Plot_Upgrade(ref object sender, ref object[] args, ref object return_value)
        {
#if !SR_VANILLA
            LandPlot.Id kind = Get_Plot_ID_From_Upgrades_UI_Class(sender);
            LandPlotUI  ui   = sender as LandPlotUI;
            LandPlot    plot = ui.Get_LandPlot();
            return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Demolished_Land_Plot, plot, ref return_value, new object[] { kind })));
#else
            return(null);
#endif
        }
コード例 #7
0
 internal static Sisco_Return Ext_LockOnDeath_End(ref object sender, ref object[] args, ref object return_value)
 {
     if (is_player_dead)
     {
         is_player_dead = false;
         return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Player_Spawn, sender, ref return_value, new object[] {})));
     }
     else
     {
         return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Player_Sleep_End, sender, ref return_value, args)));
     }
 }
コード例 #8
0
        internal static void Setup()// This is the initial setup function, it should only be called a single time, and only by the loader itself.
        {
            if (_setup)
            {
                throw new NotSupportedException("Blocked attempt to call MainMenu.Setup() a second time.");
            }
            _setup = true;//now we have run setup!

            SiscosHooks.register(HOOK_ID.Level_Loaded, MainMenu.onLevelLoaded);

            State = new Active_State_Tracker("MAIN_MENU");
            // Create our handler game object
            root = new GameObject("PluginLoader_MainMenu_Handler");
            GameObject.DontDestroyOnLoad(root);
            var Handler = root.AddComponent <LevelLoaded_Handler_Script>();
        }
コード例 #9
0
        public static void Setup()
        {
            SiscosHooks.register(HOOK_ID.Level_Loaded, onLevelLoaded);
            Init();

            Root      = uiControl.Create <uiPanel>();
            Root.Name = "DebugUI";
            Root.Set_Padding(5);
            Root.FloodXY();
            Root.local_style.normal.background = null;
            Root.isVisible = false;                         //Because our State var is inactive by default

            var list = uiControl.Create <uiListView>(Root); // Using a uiListView to contain all of our debug var displays makes them all auto layout, which is nice

            list.alignLeftSide();
            list.alignTop(200);

            lbl_player_pos      = uiControl.Create <uiVarText>(list);
            lbl_player_pos.Text = "Player Pos:";
            lbl_player_pos.Set_Margin(0);
            lbl_player_pos.Set_Padding(0);

            lbl_cam_pos      = uiControl.Create <uiVarText>(list);
            lbl_cam_pos.Text = "Cam Pos:";
            lbl_cam_pos.Set_Margin(0);
            lbl_cam_pos.Set_Padding(0);

            lbl_cam_rot      = uiControl.Create <uiVarText>(list);
            lbl_cam_rot.Text = "Cam Rot:";
            lbl_cam_rot.Set_Margin(0);
            lbl_cam_rot.Set_Padding(0);


            lbl_debug_mode = uiControl.Create <uiText>(list);
            //lbl_debug_mode.isVisible = false;//only shows when the debug drawing mode isnt NONE

            uiControl.dbg_mouse_tooltip_style = new GUIStyle();
            uiControl.dbg_mouse_tooltip_style.normal.textColor = Color.white;
            Util.Set_BG_Color(uiControl.dbg_mouse_tooltip_style.normal, new Color(0f, 0f, 0f, 0.5f));
        }
コード例 #10
0
        private static void Hook_MainMenu()
        {
            if (Instance != null)
            {
                return;                  // If the instance isn't null then we will have already added all of our buttons and stuff
            }
            Instance = UnityEngine.Object.FindObjectOfType <MainMenuUI>();
            if (Instance == null)
            {
                throw new Exception("Cannot find MainMenuUI!");
            }
            if (Instance.gameObject == null)
            {
                throw new Exception("MainMenuUI component has no GameObject!");
            }

            //Output_Hierarchy();

            var tracker = Instance.gameObject.AddComponent <MainMenuUI_Tracking_Script>();// Attach our tracking script to it.

            if (tracker == null)
            {
                throw new Exception("Cannot attach MainMenu tracking script!");
            }
            // Reset the MainMenu visibility state because we JUST found it so theres no way we have it hidden yet.
            State.Reset();

            //Add_Button("Manage Plugins", "PluginsMenu", new UnityAction(Show_PluginManager));
            //Add_Button("Manage Plugins", "PluginsMenu", new UnityAction(Show_PluginManager));
            //Add_Button("Manage Plugins", "PluginsMenu", new UnityAction(Show_PluginManager));
            //Add_Button("Manage Plugins", "PluginsMenu", new UnityAction(Show_PluginManager));
            Add_Button("Plugins", "Plugins", new UnityAction(Show_PluginManager), clr_gold_light, clr_gold, clr_brown);

            object retVal = new object();

            SiscosHooks.call(HOOK_ID.MainMenu_Loaded, null, ref retVal, new object[] {});
        }
コード例 #11
0
        private IEnumerator Check_For_Updates()
        {
            SLog.Info("[AutoUpdater] Checking for updates...");
            List <UpdateFile> updates = new List <UpdateFile>();

            // We should automatically keep ALL files within the repositorys "installer" directory insync!
            var iter = Git_Updater.Get_Repo_Folder_Files_Async("https://raw.github.com/dsisco11/SR_Plugin_Loader/master/", "/Installer/");

            if (iter == null)
            {
                yield break;
            }
            while (iter.MoveNext())
            {
                yield return(null);
            }

            if (iter.Current != null)
            {
                List <UpdateFile> list  = (List <UpdateFile>)iter.Current;
                string            exDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

                foreach (UpdateFile file in list)
                {
                    string FN  = Path.GetFileName(file.FILE);
                    string dir = exDir;
                    if (String.Compare("SR_PluginLoader_Uninstaller.exe", FN) == 0)
                    {
                        dir = Path.GetFullPath(String.Concat(dir, "/../../"));
                    }

                    string local_path = Path.Combine(dir, FN);
                    file.LOCAL_PATH = local_path;

                    var it = Git_Updater.instance.Get_Update_Status_Async(file.FULLNAME, local_path);
                    if (it == null)
                    {
                        continue;
                    }
                    while (it.MoveNext())
                    {
                        yield return(null);
                    }

                    FILE_UPDATE_STATUS status = (FILE_UPDATE_STATUS)it.Current;
                    //status = FILE_UPDATE_STATUS.OUT_OF_DATE;// DEBUG

                    //PLog.Info("{0}  |  LOCAL_PATH: {1}  |  REMOTE_PATH: {2}", file.FULLNAME, local_path, file.URL);
                    if (status == FILE_UPDATE_STATUS.OUT_OF_DATE)
                    {
                        updates.Add(file);
                    }
                }
            }

            // If we have updates prompt the user to accept them.
            if (updates.Count > 0)
            {
                SLog.Info("[AutoUpdater] {0} Updates Available.", updates.Count);
                var updatesView = uiControl.Create <uiUpdatesAvailable>();
                updatesView.onResult += (DialogResult res) => {
                    if (res == DialogResult.OK)
                    {
                        // The user said OK so let's start downloading
                        var updater = (new GameObject().AddComponent <PluginLoader_AutoUpdater>());
                        updater.Files       = updatesView.Files;
                        updater.updatesView = updatesView;
                        return(true);
                    }
                    return(false);
                };
                foreach (var f in updates)
                {
                    updatesView.Add_File(f);
                }

                if (MainMenu.isReady)
                {
                    updatesView.Show();
                }
                else
                {
                    SiscosHooks.Once(HOOK_ID.MainMenu_Loaded, () => { updatesView.Show(); });
                }
            }
            else
            {
                SLog.Info("[AutoUpdater] No updates.");
            }

            yield return(null);

            yield break;
        }
コード例 #12
0
        internal void Level_Loaded(int level_idx = 0)
        {
            object retVal = new object();

            SiscosHooks.call(HOOK_ID.Level_Loaded, null, ref retVal, new object[] { level_idx });
        }
コード例 #13
0
        public static void init(string hash)
        {
            lock (locker)
            {
                if (Loader.Config != null)
                {
                    return;
                }
                //Application.stackTraceLogType = StackTraceLogType.Full;
                Logging.Logger.Begin(Path.Combine(Application.dataPath, "plugins.log"));

                Stopwatch timer = new Stopwatch();
                timer.Start();

                if (!Loader.Load_Config_Stream())
                {
                    return;
                }

                try
                {
                    DebugHud.Init();
                    TextureHelper.Setup();
                    MaterialHelper.Setup();
                    SiscosHooks.Setup();
                    PluginLoader_Watermark.Setup();
                    MainMenu.Setup();
                    DebugUI.Setup();

                    Setup_Update_Helper();
                    bool ok = Verify_PluginLoader_Hash(hash);
                    if (!ok)
                    {
                        return;
                    }

                    IN_LOADING_PHASE = true;
                    Setup_Plugin_Dir();

                    Check_For_Updates();

                    Setup_Assembly_Resolver();
                    Upgrades.Setup();
                    Assemble_Plugin_List();
                    Load_Config();
                    IN_LOADING_PHASE = false;
                    ResourceExt.map_SR_Icons();

                    plugin_updater = uiControl.Create <Plugin_Update_Viewer>();// This control manages itself and is only able to become visible under certain conditions which it will control. Therefore it needs no var to track it.
                    plugin_updater.Show();

                    dev_tools = uiControl.Create <DevMenu>();
                    //dev_tools.Show();
                    //dev_tools.onShown += (uiWindow w) => { GameTime.Pause(); };
                    //dev_tools.onHidden += (uiWindow w) => { GameTime.Unpause(); };

                    //Misc_Experiments.Find_Common_Classes_For_Idents(new HashSet<Identifiable.Id> { Identifiable.Id.PINK_RAD_LARGO });
                }
                catch (Exception ex)
                {
                    SLog.Error("Exception during PluginLoader initialization!");
                    SLog.Error(ex);
                }
                finally
                {
                    timer.Stop();
                    SLog.Debug("Plugin Loader initialized! Took: {0}ms", timer.ElapsedMilliseconds);
                }
            }
        }
コード例 #14
0
 internal static Sisco_Return Ext_Spawn_Plot_Upgrades_UI(ref object sender, ref object[] args, ref object return_value)
 {
     LandPlot.Id kind = Get_Plot_ID_From_Upgrades_UI_Class(sender);
     return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Spawn_Plot_Upgrades_UI, sender, ref return_value, new object[] { kind })));
 }
コード例 #15
0
 // The LockOnDeath class is used to lock player input for the game
 // This means that it is used both when the player "goes to sleep" and when they die
 // So we can use it to differentiate between the two
 internal static Sisco_Return Ext_LockOnDeath_Start(ref object sender, ref object[] args, ref object return_value)
 {
     return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Player_Sleep_Begin, sender, ref return_value, args)));
 }
コード例 #16
0
 internal static Sisco_Return Ext_Player_Death(ref object sender, ref object[] args, ref object return_value)
 {
     is_player_dead = true;
     return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Player_Death, sender, ref return_value, args)));
 }
コード例 #17
0
        internal static Sisco_Return Ext_Post_Game_Loaded(ref object sender, ref object[] args, ref object return_value)
        {
            string saveFile = GameData.ToPath(args[0] as string);

            return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Post_Game_Loaded, sender, ref return_value, new object[] { saveFile })));
        }
コード例 #18
0
        internal static Sisco_Return Ext_Game_Saved(ref object sender, ref object[] args, ref object return_value)
        {
            string saveFile = GameData.ToPath((sender as GameData).gameName);

            return(new Sisco_Return(SiscosHooks.call(HOOK_ID.Game_Saved, sender, ref return_value, new object[] { saveFile })));
        }