Ejemplo n.º 1
0
        static IEnumerable <Gizmo> Postfix(IEnumerable <Gizmo> __result, ThingComp __instance)
        {
            foreach (var g in __result)
            {
                yield return(g);
            }
            if (!(__instance is CompArt compArt))
            {
                yield break;
            }
            if (!(compArt.parent is Building_Art))
            {
                yield break;
            }
            yield return(new Command_Action()
            {
                defaultLabel = "Make Special Sculpture (SLOW)",
                defaultDesc = "Make this Sculpture the first Special Sculpture available.  Reloads everything.\n\nTHIS IS VERY SLOW!\n(Project RimFactory)",
                action = delegate() {
                    // reload graphic assets: (not fast)
                    LoadedModManager.GetMod <ProjectRimFactory.Common.ProjectRimFactory_ModComponent>().Content.ReloadContent();
                    // reload language data: (....slow)
                    LanguageDatabase.Clear();
                    LanguageDatabase.InitAllMetadata(); // have to reload all? :p
                    //LoadedModManager.GetMod<ProjectRimFactory.Common.ProjectRimFactory_ModComponent>().Content.
                    ProjectRimFactory.Common.ProjectRimFactory_ModComponent.availableSpecialSculptures
                        = SpecialSculpture.LoadAvailableSpecialSculptures(LoadedModManager.GetMod <ProjectRimFactory.Common.ProjectRimFactory_ModComponent>().Content
                                                                          );
                    foreach (var s in ProjectRimFactory.Common.ProjectRimFactory_ModComponent.availableSpecialSculptures)
                    {
                        s.Init();
                    }
                    var target = ProjectRimFactory.Common.ProjectRimFactory_ModComponent.availableSpecialSculptures[0];

                    var comp = Current.Game.GetComponent <ProjectRimFactory.PRFGameComponent>();
                    if (comp.specialScupltures != null)
                    {
                        //                    if (comp.specialScupltures == null) comp.specialScupltures = new List<SpecialSculpture>();

                        comp.specialScupltures.RemoveAll(s => s.id == target.id);
                    }
                    comp.TryAddSpecialSculpture(compArt.parent, target);
                    compArt.parent.DirtyMapMesh(compArt.parent.Map); // redraw graphic
                }
            });
        }