internal static LandPlot.Id Get_Plot_ID_From_Upgrades_UI_Class(object sender)
        {
            LandPlot.Id kind = LandPlot.Id.NONE;
            Type        type = sender.GetType();

            if (type == typeof(GardenUI))
            {
                kind = LandPlot.Id.GARDEN;
            }
            else if (type == typeof(CoopUI))
            {
                kind = LandPlot.Id.COOP;
            }
            else if (type == typeof(CorralUI))
            {
                kind = LandPlot.Id.CORRAL;
            }
            else if (type == typeof(PondUI))
            {
                kind = LandPlot.Id.POND;
            }
            else if (type == typeof(SiloUI))
            {
                kind = LandPlot.Id.SILO;
            }
            else if (type == typeof(IncineratorUI))
            {
                kind = LandPlot.Id.INCINERATOR;
            }

            return(kind);
        }
예제 #2
0
        private static Sisco_Return onSpawn_PlotUpgrades_Kiosk(ref object sender, ref object[] args, ref object return_value)
        {
            LandPlot.Id kind = (LandPlot.Id)args[0];
#if !SR_VANILLA
            LandPlotUI         kiosk   = sender as LandPlotUI;
            LandPlot           plot    = kiosk.Get_LandPlot();
            PlotUpgradeTracker tracker = plot.GetComponent <PlotUpgradeTracker>();
            if (tracker == null)
            {
                tracker = plot.gameObject.AddComponent <PlotUpgradeTracker>();
            }


            GameObject panel = return_value as GameObject;
            var        ui    = panel.GetComponent <PurchaseUI>();

            foreach (PlotUpgrade up in ALL[Upgrade_Type.PLOT_UPGRADE].Values)
            {
                if (up.Kind != kind)
                {
                    continue;
                }
                bool can_buy = up.CanBuy(tracker);
                ui.AddButton(new PurchaseUI.Purchasable(up.Name, up.Sprite, up.PreviewSprite, up.Description, up.Cost, new PediaDirector.Id?(), new UnityAction(() => { up.Purchase(kiosk.gameObject); }), can_buy));
            }
#endif
            return(null);
        }
예제 #3
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 });
        }
        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
        }
예제 #5
0
        /// <summary>
        /// Adds a component to any land plot (or the ones in the white list)
        /// </summary>
        /// <typeparam name="T">Type of component to add</typeparam>
        /// <param name="whiteList">White list to add component to (null will add to all)</param>
        public static void AddComponentToLand <T>(ICollection <LandPlot.Id> whiteList = null) where T : Component
        {
            foreach (string name in System.Enum.GetValues(typeof(LandPlot.Id)))
            {
                LandPlot.Id ID = EnumUtils.Parse <LandPlot.Id>(name);
                if (whiteList != null && !whiteList.Contains(ID))
                {
                    continue;
                }

                GameContext.Instance.LookupDirector.GetPlotPrefab(ID).AddComponent <T>();
            }
        }
예제 #6
0
        private static Sisco_Return onPlot_Demolished(ref object sender, ref object[] args, ref object return_value)
        {
            LandPlot.Id ID   = (LandPlot.Id)args[0];
            LandPlot    plot = sender as LandPlot;
            PlotID      id   = new PlotID(plot);
            //SLog.Debug("Plot({0}){1} Demolished", ID, id);

            var track = plot.gameObject.GetComponent <PlotUpgradeTracker>();

            track.Remove_All();

            return(null);
        }
예제 #7
0
        public static void RegisterPlotUpgrader <T>(LandPlot.Id plot) where T : PlotUpgrader
        {
            switch (SRModLoader.CurrentLoadingStep)
            {
            case SRModLoader.LoadingStep.PRELOAD:
                SRCallbacks.OnGameContextReady += () =>
                {
                    GameContext.Instance.LookupDirector.GetPlotPrefab(plot).AddComponent <T>();
                };
                break;

            default:
                GameContext.Instance.LookupDirector.GetPlotPrefab(plot).AddComponent <T>();
                break;
            }
        }
예제 #8
0
 /// <summary>
 /// Gets a land plot item
 /// </summary>
 /// <typeparam name="T">Type of item</typeparam>
 /// <param name="ID">ID of the item</param>
 /// <returns>Item found or null if nothing is found</returns>
 public static T Get <T>(LandPlot.Id ID) where T : PlotItem
 {
     return(!Items.ContainsKey(ID) || !(Items[ID] is T) ? null : Items[ID] as T);
 }
 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 })));
 }
예제 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="parent">A reference to your plugin, also used to uniquely identify the upgrade in save files</param>
 /// <param name="kind">What kind of plot item this upgrade is for; Coop, Silo, Corral, Pond, Garden, etc.</param>
 /// <param name="id">A string that will be used to uniquely identify this upgrade in save files</param>
 /// <param name="cost">How many credits the upgrade costs</param>
 /// <param name="name">The title text for the upgrade when shown in the kiosk</param>
 /// <param name="desc">The description text for the upgrade when shown in the kiosk</param>
 /// <param name="function">Function that applies the upgrade's effects.</param>
 /// <param name="remove_func">Function to remove the upgrade's effects.</param>
 /// <param name="icon">An icon used to represent the upgrade when shown in the kiosk</param>
 /// <param name="preview">The preview image to show in the upgrade kiosk</param>
 public PlotUpgrade(Plugin parent, LandPlot.Id kind, string id, int cost, string name, string desc, Action <GameObject> function, Action <LandPlot> remove_func, Texture2D icon, Texture2D preview) : base(parent, id, cost, name, desc, function, icon, preview)
 {
     Kind             = kind;
     removal_function = remove_func;
     Upgrades.Register(this);
 }
예제 #11
0
 public static bool IsModdedLandPlot(LandPlot.Id id)
 {
     return(landplots.ContainsKey(id));
 }
예제 #12
0
 /// <summary>
 /// Checks if there is a prefab for the given land plot ID
 /// </summary>
 /// <param name="dir">The lookup director</param>
 /// <param name="id">The ID to check</param>
 public static bool HasPlotPrefab(this LookupDirector dir, LandPlot.Id id)
 {
     return(dir.GetPrivateField <Dictionary <LandPlot.Id, GameObject> >("plotPrefabDict").ContainsKey(id));
 }
 /// <summary>
 /// Template to create new plots
 /// </summary>
 /// <param name="name">The name of the object (prefixes are recommended, but not needed)</param>
 /// <param name="ID">The Plot ID for this plot</param>
 public CustomPlotTemplate(string name, LandPlot.Id ID) : base(name)
 {
     this.ID = ID;
 }