/// <summary>
        /// Make a sculpture Special!
        /// Use: Current.Game.GetComponent&lt;PRFGrameComponent&gt;().TryAddSpecialSculpture(...)
        /// </summary>
        /// <returns><c>true</c>, if the sculpture is now Special.</returns>
        /// <param name="item">Art item to make Special.</param>
        /// <param name="specialSculpture">Specific special sculpture; otherwise random</param>
        public bool TryAddSpecialSculpture(Thing item, SpecialSculpture specialSculpture = null)
        {
            if (specialSculpture == null)   // find an acceptable special sculpture
            {
                foreach (var ss in ProjectRimFactory_ModComponent.availableSpecialSculptures
                         .InRandomOrder())
                {
                    if (this.specialScupltures == null)
                    {
                        specialSculpture = ss; break;
                    }
                    var inGameWithSameId = specialScupltures.FirstOrDefault(s => s.id == ss.id);
                    if (inGameWithSameId == null)
                    {
                        specialSculpture = ss;  break;
                    }
                    if (inGameWithSameId.currentInstances == null ||
                        inGameWithSameId.currentInstances.Count(a => a != item)
                        < inGameWithSameId.maxNumberCopies)
                    {
                        specialSculpture = ss;
                        break;
                    }
                    //TODO: Maybe check defs, too, to make sure we aren't replacing
                    //  a grand sculptur with the image for a large one?
                }
                if (specialSculpture == null)
                {
                    return(false);                          // could not find empty sculpture slot
                }
            }
            specialSculpture.MakeItemSpecial(item);
            // bookkeeping:
            if (this.specialScupltures == null)
            {
                specialScupltures = new List <SpecialSculpture>();
            }
            var alreadyRecordedSpecialSculpture = this.specialScupltures
                                                  .FirstOrDefault(s => s.id == specialSculpture.id);

            if (alreadyRecordedSpecialSculpture == null)
            {
                this.specialScupltures.Add(specialSculpture);
                alreadyRecordedSpecialSculpture = specialSculpture;
            } // alreadyRSS has been added to list one way or another now
            if (alreadyRecordedSpecialSculpture.currentInstances == null)
            {
                alreadyRecordedSpecialSculpture.currentInstances = new List <Thing>();
            }
            if (!alreadyRecordedSpecialSculpture.currentInstances.Contains(item))
            {
                alreadyRecordedSpecialSculpture.currentInstances.Add(item);
            }
            // Note: autocompletion was essential for all that.
            return(true);
        }
예제 #2
0
        public PRFGameComponent(Game game)
        {
            SpecialSculpture.PreStartGame();

            //Back Compatibility Setup

            List <BackCompatibilityConverter> data = (List <BackCompatibilityConverter>)SAL3.ReflectionUtility.BackCompatibility_conversionChain.GetValue(null);

            data.Add(new Common.BackCompatibility.PRF_BackCompatibilityConverter());
            SAL3.ReflectionUtility.BackCompatibility_conversionChain.SetValue(null, data);
        }
예제 #3
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
                }
            });
        }
예제 #4
0
 public PRFGameComponent(Game game)
 {
     SpecialSculpture.PreStartGame();
 }