public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); this.compPowerTrader = base.GetComp <CompPowerTrader>(); this.compPowerTrader.PowerOutput = -LOW_POWER_COST; this.CurrentMap = map; foreach (Building_Dresser d in BuildingUtil.FindThingsOfTypeNextTo <Building_Dresser>(base.Map, base.Position, Settings.RepairAttachmentDistance)) { this.AddDresser(d); } #if DEBUG_REPAIR Log.Warning(this.Label + " adding attached dressers:"); foreach (Building_Dresser d in this.AttachedDressers) { Log.Warning(" " + d.Label); } #endif this.compPowerTrader.powerStartedAction = new Action(delegate() { this.compPowerTrader.PowerOutput = LOW_POWER_COST; }); this.compPowerTrader.powerStoppedAction = new Action(delegate() { this.StopRepairing(); this.compPowerTrader.PowerOutput = 0; }); }
internal void ReclaimApparel(bool force = false) { if (base.Map == null) { return; } #if DEBUG List <Apparel> ll = new List <Apparel>(BuildingUtil.FindThingsOfTypeNextTo <Apparel>(base.Map, base.Position, 1)); Log.Warning("Apparel found: " + ll.Count); #endif try { List <Thing> l = BuildingUtil.FindThingsNextTo(base.Map, base.Position, 1); if (l.Count > 0) { foreach (Thing t in l) { try { if (t is Apparel) { if (!WorldComp.AddApparel((Apparel)t) && force && t.Spawned) { t.DeSpawn(); if (this.forceAddedApparel == null) { this.forceAddedApparel = new List <Thing>(); } this.forceAddedApparel.Add(t); } } } catch { // Ignore } } l.Clear(); l = null; } } catch { // Ignore } }
internal void ReclaimApparel() { #if DEBUG List <Apparel> ll = new List <Apparel>(BuildingUtil.FindThingsOfTypeNextTo <Apparel>(base.Map, base.Position, 1)); Log.Warning("Apparel found: " + ll.Count); #endif List <Thing> l = BuildingUtil.FindThingsNextTo(base.Map, base.Position, 1); if (l.Count > 0) { foreach (Thing t in l) { if (t is Apparel) { WorldComp.AddApparel((Apparel)t); } } l.Clear(); } }
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 void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); this.CurrentMap = map; WorldComp.AddDresser(this); if (settings == null) { base.settings = new StorageSettings(this); base.settings.CopyFrom(this.def.building.defaultStorageSettings); base.settings.filter.SetDisallowAll(); } foreach (Building_RepairChangeDresser r in BuildingUtil.FindThingsOfTypeNextTo <Building_RepairChangeDresser>(base.Map, base.Position, Settings.RepairAttachmentDistance)) { #if DEBUG_REPAIR Log.Warning("Adding Dresser " + this.Label + " to " + r.Label); #endif r.AddDresser(this); } this.UpdatePreviousStorageFilter(); }