private void Dispose() { try { this.Empty <Apparel>(); } catch (Exception e) { Log.Error( "ChangeDresser:Building_Dresser.Dispose\n" + e.GetType().Name + " " + e.Message + "\n" + e.StackTrace); } WorldComp.RemoveDesser(this); foreach (Building_RepairChangeDresser r in BuildingUtil.FindThingsOfTypeNextTo <Building_RepairChangeDresser>(this.CurrentMap, base.Position, Settings.RepairAttachmentDistance)) { #if DEBUG_REPAIR Log.Warning("Removing Dresser " + this.Label + " to " + r.Label); #endif r.RemoveDresser(this); } }
public override IEnumerable <Gizmo> GetGizmos() { IEnumerable <Gizmo> enumerables = base.GetGizmos(); List <Gizmo> l; if (enumerables != null) { l = new List <Gizmo>(enumerables); } else { l = new List <Gizmo>(1); } int groupKey = this.GetType().Name.GetHashCode(); Command_Action a = new Command_Action(); a.icon = WidgetUtil.manageapparelTexture; a.defaultDesc = "ChangeDresser.ManageApparelDesc".Translate(); a.defaultLabel = "ChangeDresser.ManageApparel".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { Find.WindowStack.Add(new UI.StorageUI(this, null)); }; a.groupKey = groupKey; ++groupKey; l.Add(a); a = new Command_Action(); a.icon = WidgetUtil.assignweaponsTexture; a.defaultDesc = "ChangeDresser.AssignOutfitsDesc".Translate(); a.defaultLabel = "ChangeDresser.AssignOutfits".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { Find.WindowStack.Add(new UI.AssignOutfitUI(this)); }; a.groupKey = groupKey; ++groupKey; l.Add(a); a = new Command_Action(); a.icon = WidgetUtil.customapparelTexture; a.defaultDesc = "ChangeDresser.CustomOutfitsDesc".Translate(); a.defaultLabel = "ChangeDresser.CustomOutfits".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { Find.WindowStack.Add(new UI.CustomOutfitUI(this)); }; a.groupKey = groupKey; ++groupKey; l.Add(a); a = new Command_Action(); a.icon = WidgetUtil.emptyTexture; a.defaultDesc = "ChangeDresser.EmptyDesc".Translate(); a.defaultLabel = "ChangeDresser.Empty".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { this.Empty <Apparel>(); }; a.groupKey = groupKey; ++groupKey; l.Add(a); a = new Command_Action(); a.icon = WidgetUtil.collectTexture; a.defaultDesc = "ChangeDresser.CollectDesc".Translate(); a.defaultLabel = "ChangeDresser.Collect".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { this.ReclaimApparel(); }; a.groupKey = groupKey; ++groupKey; l.Add(a); a = new Command_Action(); if (this.includeInTradeDeals) { a.icon = WidgetUtil.yesSellTexture; } else { a.icon = WidgetUtil.noSellTexture; } a.defaultDesc = "ChangeDresser.IncludeInTradeDealsDesc".Translate(); a.defaultLabel = "ChangeDresser.IncludeInTradeDeals".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { this.includeInTradeDeals = !this.includeInTradeDeals; }; a.groupKey = groupKey; ++groupKey; l.Add(a); a = new Command_Action(); if (this.UseDresserToDressFrom) { a.icon = WidgetUtil.yesDressFromTexture; } else { a.icon = WidgetUtil.noDressFromTexture; } a.defaultDesc = "ChangeDresser.UseDresserToDressFromDesc".Translate(); a.defaultLabel = "ChangeDresser.UseDresserToDressFrom".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { this.UseDresserToDressFrom = !this.UseDresserToDressFrom; if (this.UseDresserToDressFrom) { WorldComp.AddDresser(this); } else { WorldComp.RemoveDesser(this); } }; a.groupKey = groupKey; ++groupKey; l.Add(a); return(SaveStorageSettingsGizmoUtil.AddSaveLoadGizmos(l, SaveTypeEnum.Apparel_Management, this.settings.filter)); }
public override void ExposeData() { #if DEBUG Log.Warning(Environment.NewLine + "Start Building_Dresser.ExposeData mode: " + Scribe.mode); #endif base.ExposeData(); //bool useInLookup = this.UseInApparelLookup; //Scribe_Values.Look(ref useInLookup, "useInApparelLookup", false, false); //this.UseInApparelLookup = useInLookup; if (Scribe.mode == LoadSaveMode.Saving) { this.tempApparelList = new List <Apparel>(this.StoredApparel.Apparel); if (this.forceAddedApparel == null) { this.forceAddedApparel = new List <Thing>(); } } #if DEBUG Log.Warning(" Scribe_Collections.Look tempApparelList"); #endif Scribe_Collections.Look(ref this.tempApparelList, false, "apparel", LookMode.Deep, new object[0]); Scribe_Values.Look(ref this.includeInTradeDeals, "includeInTradeDeals", true); Scribe_Collections.Look(ref this.forceAddedApparel, false, "forceAddedApparel", LookMode.Deep, new object[0]); Scribe_Values.Look(ref this.UseDresserToDressFrom, "useDresserToDressFrom", true, false); #if DEBUG if (this.tempApparelList != null) { Log.Warning(" tempApparelList Count: " + this.tempApparelList.Count); } else { Log.Warning(" StempApparelList is null"); } #endif if (this.tempApparelList != null && Scribe.mode == LoadSaveMode.PostLoadInit) { #if DEBUG Log.Warning(" tempApparelList != null && PostLoadInit"); #endif foreach (Apparel apparel in this.tempApparelList) { if (apparel != null && !apparel.Destroyed && apparel.HitPoints > 0.01) { this.StoredApparel.AddApparel(apparel); } } } if (this.tempApparelList != null && (Scribe.mode == LoadSaveMode.Saving || Scribe.mode == LoadSaveMode.PostLoadInit)) { #if DEBUG StringBuilder sb = new StringBuilder(" Saving or PostLoadInit - Count: " + this.StoredApparel.Count); foreach (Apparel a in this.StoredApparel.Apparel) { sb.Append(", "); sb.Append(a.LabelShort); } Log.Warning(sb.ToString()); #endif this.tempApparelList.Clear(); this.tempApparelList = null; if (this.forceAddedApparel != null && this.forceAddedApparel.Count == 0) { this.forceAddedApparel = null; } } if (Scribe.mode == LoadSaveMode.PostLoadInit) { if (!this.UseDresserToDressFrom) { WorldComp.RemoveDesser(this); } } #if DEBUG Log.Message("End Building_Dresser.ExposeData" + Environment.NewLine); #endif }