public static void OpenDeitySelectMenu(Building_SacrificialAltar altar) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate { MapComponent_SacrificeTracker.Get.lastUsedAltar = altar; altar.tempCurrentSacrificeDeity = null; }, MenuOptionPriority.Medium, null, null, 0f, null)); foreach (CosmicEntity current in MapComponent_CosmicDeities.Get.DeityCache.Keys) { if (current.discovered) { Action action; CosmicEntity localDeity = current; action = delegate { MapComponent_SacrificeTracker.Get.lastUsedAltar = altar; altar.tempCurrentSacrificeDeity = localDeity; altar.tempCurrentSpell = null; }; list.Add(new FloatMenuOption(localDeity.LabelCap, action, MenuOptionPriority.Medium, null, null, 0f, null)); } } Find.WindowStack.Add(new FloatMenu(list)); }
public static void OpenDeitySelectMenu(Building_SacrificialAltar altar) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate { //Map.GetComponent<MapComponent_SacrificeTracker>().lastUsedAltar = altar; altar.tempCurrentWorshipDeity = null; }, MenuOptionPriority.Default, null, null, 0f, null)); foreach (CosmicEntity current in DeityTracker.Get.DeityCache.Keys) { if (!current.discovered) { continue; } Action action; CosmicEntity localDeity = current; action = delegate { //Map.GetComponent<MapComponent_SacrificeTracker>().lastUsedAltar = altar; altar.tempCurrentWorshipDeity = localDeity; //altar.tempCurrentSpell = null; }; Func <Rect, bool> extraPartOnGUI = (Rect rect) => DeityInfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, current); list.Add(new FloatMenuOption(localDeity.LabelCap, action, MenuOptionPriority.Default, null, null, 29f, extraPartOnGUI)); } Find.WindowStack.Add(new FloatMenu(list)); }
// RimWorld.SkillUI private static string GetFavorDescription(CosmicEntity entity) { var stringBuilder = new StringBuilder(); if (entity == null) { stringBuilder.Append("DisabledLower".Translate().CapitalizeFirst()); } else { stringBuilder.AppendLine(string.Concat("Tier".Translate(), " ", entity.PlayerTier, ": ", entity.TierString)); if (Current.ProgramState == ProgramState.Playing) { string text = entity.PlayerTier != CosmicEntity.Tier.Final ? "ProgressToNextLevel".Translate() : "Favor".Translate(); stringBuilder.AppendLine(string.Concat(new object[] { text, ": ", entity.PlayerFavor.ToString("F"), " / ", entity.currentTierMax.ToString("F") })); } } stringBuilder.AppendLine(); stringBuilder.AppendLine(); stringBuilder.Append("FavorDescription".Translate()); return(stringBuilder.ToString()); }
public CosmicEntity GetCache(CosmicEntity deity) { CosmicEntity result; bool flag1 = DeityCache == null; if (flag1) { DeityCache = new Dictionary <CosmicEntity, int>(); } foreach (CosmicEntity current in DeityCache.Keys) { if (current == deity) { result = current; return(result); } } CosmicEntity cosmicEntity = deity; DeityCache.Add(deity, deity.Version); result = deity; return(result); }
public CosmicEntity GetCache(CosmicEntity deity) { CosmicEntity result; var flag1 = DeityCache == null; if (flag1) { DeityCache = new Dictionary <CosmicEntity, int>(); } foreach (var current in DeityCache.Keys) { if (current != deity) { continue; } result = current; return(result); } DeityCache.Add(deity, deity.Version); result = deity; return(result); }
public static void DrawDeity(CosmicEntity entity, Rect rect3, string spellDescription = null, float offset = 0f) { string entityLabel = ""; string entityDescrip = ""; if (entity != null) { entityLabel = entity.LabelCap; entityDescrip = entity.def.description; } Rect secondBox = rect3; secondBox.x += rect3.x + 10f + 30f + offset; secondBox.xMax += 125f; secondBox.height = ITab_AltarSacrificesCardUtility.ButtonSize; Text.Font = GameFont.Medium; Widgets.Label(secondBox, entityLabel); Text.Font = GameFont.Small; Rect secondBoxUnder = secondBox; secondBoxUnder.y += ITab_AltarSacrificesCardUtility.ButtonSize + ITab_AltarSacrificesCardUtility.SpacingOffset; secondBoxUnder.width -= 15f; secondBoxUnder.height = ITab_AltarSacrificesCardUtility.ButtonSize; Widgets.Label(secondBoxUnder, entityDescrip); ITab_AltarCardUtility.DrawTier(entity, new Vector2(secondBoxUnder.x, secondBoxUnder.y + 70f)); Rect secondBoxUnder2 = secondBoxUnder; secondBoxUnder2.y += ITab_AltarSacrificesCardUtility.ButtonSize * 2 + (ITab_AltarSacrificesCardUtility.SpacingOffset * 2); secondBoxUnder2.height = 250f; if (spellDescription != null) { Widgets.Label(secondBoxUnder2, spellDescription); } }
public static bool DeityInfoCardButton(float x, float y, CosmicEntity entity) { bool result; var methodObj = AccessTools.Method( typeof(Widgets), "InfoCardButtonWorker", new Type[] { typeof(float), typeof(float) }); if ((bool)methodObj.Invoke(null, new object[] { x, y })) { Find.WindowStack.Add(new Dialog_CosmicEntityInfoBox(entity)); result = true; } else { result = false; } return(result); }
public Bill_Sacrifice(Pawn newSacrifice, Pawn newExecutioner, CosmicEntity newEntity, IncidentDef newSpell) { sacrifice = newSacrifice; executioner = newExecutioner; entity = newEntity; spell = newSpell; }
private void CheckForUpdates() { //Create a temporary dictionary. //Load all the current deities into it. var tempDic = new Dictionary <CosmicEntity, int>(); foreach (var pair in DeityCache) { tempDic.Add(pair.Key, pair.Value); } //Now, check to see if the saved "version" matches the new "version" we loaded. var entitiesToUpdate = new List <CosmicEntity>(); foreach (var pair in tempDic) { //Version mismatch, let's update! if (pair.Key.Version != pair.Value) { entitiesToUpdate.Add(pair.Key); //Cthulhu.Utility.DebugReport("To be updated +1"); } //Cthulhu.Utility.DebugReport("Cycled"); } foreach (var entity in entitiesToUpdate) { ReloadCosmicEntity(entity); } //Deities are updated, but let's check if there are new deities. foreach (var current in DefDatabase <ThingDef> .AllDefs) { if (current.thingClass != typeof(CosmicEntity)) { continue; } var newDeity = new CosmicEntity(current); if (tempDic.Keys.FirstOrDefault(oldDeity => oldDeity.def.defName == newDeity.def.defName) != null) { continue; } newDeity.discovered = false; GetCache(newDeity); //RevealDeityCheck(); } //Clear that dictionary }
public static bool DeityInfoCardButton(float x, float y, CosmicEntity entity) { bool result; if ((bool)AccessTools.Method(type: typeof(Widgets), name: "InfoCardButtonWorker").Invoke(obj: null, parameters: new object[] { x, y })) { Find.WindowStack.Add(new Dialog_CosmicEntityInfoBox(entity)); result = true; } else { result = false; } return(result); }
// RimWorld.SkillUI// public static void DrawTier(CosmicEntity entity, Vector2 topLeft) { if (entity == null) { return; } _ = entity.PlayerTier.ToString(); string standingLabel = "Standing".Translate() + ":"; var tierLabelWidth = Text.CalcSize(standingLabel).x; var tierCurrentVal = entity.PlayerFavor; var tierCurrentMax = entity.currentTierMax; var tierPrevMax = entity.prevTierMax; var rect = new Rect(topLeft.x, topLeft.y, 150f, 24f); if (Mouse.IsOver(rect)) { GUI.DrawTexture(rect, TexUI.HighlightTex); } GUI.BeginGroup(rect); Text.Anchor = TextAnchor.MiddleLeft; var rect2 = new Rect(0f, 0f, tierLabelWidth + 5f, rect.height); Widgets.Label(rect2, standingLabel); var position = new Rect(rect2.xMax, 0f, 10f, 24f); var rect3 = new Rect(position.xMax, 0f, rect.width - position.xMax, rect.height); Widgets.FillableBar(rect3, (tierCurrentVal - tierPrevMax) / (tierCurrentMax - tierPrevMax), Buttons.TierBarFillTex, null, false); var rect4 = new Rect(position.xMax + 4f, 0f, 999f, rect.height); //rect4.yMin += 10f; rect4.yMax += 18f; var label = entity.TierString; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Widgets.Label(rect4, label); GenUI.ResetLabelAlign(); GUI.color = Color.white; GUI.EndGroup(); TooltipHandler.TipRegion(rect, new TipSignal(GetFavorDescription(entity), entity.def.GetHashCode() * 397945)); }
public void orGenerate() { if (!AreDeitiesSpawned) { foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs) { if (current.thingClass == typeof(CosmicEntity)) { CosmicEntity x = new CosmicEntity(current); //x.Position = new IntVec3(); //x.SpawnSetup(); GetCache(x); } } AreDeitiesSpawned = true; //Cthulhu.Utility.DebugReport("Cosmic Deities Spawned"); } return; }
private void ReloadCosmicEntity(CosmicEntity entity) { var currentFavor = entity.PlayerFavor; var currentDiscovery = entity.discovered; //Remove entity DeityCache.Remove(entity); //New deity var x = new CosmicEntity(entity.def); x.AffectFavor(currentFavor); x.discovered = currentDiscovery; DeityCache.Add(x, x.Version); //Destroy deity entity.Destroy(); //Cthulhu.Utility.DebugReport("Reloaded " + entity.Label); }
public void ReloadCosmicEntity(CosmicEntity entity) { float currentFavor = entity.PlayerFavor; bool currentDiscovery = entity.discovered; //Remove entity DeityCache.Remove(entity); //New deity CosmicEntity x = new CosmicEntity(entity.def); x.AffectFavor(currentFavor); x.discovered = currentDiscovery; DeityCache.Add(x, x.Version); //Destroy deity entity.Destroy(0); //Cthulhu.Utility.DebugReport("Reloaded " + entity.Label); return; }