Skip to content

Commit

Permalink
Workshop version 0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
micktu committed Aug 10, 2016
1 parent d627373 commit 43b02e0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
4 changes: 1 addition & 3 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<author>Micktu</author>
<url>http://micktu.net</url>
<targetVersion>0.14.1249</targetVersion>
<description>&lt;b&gt;Requires &lt;color=&quot;orange&quot;&gt;Community Core Library&lt;/color&gt;.&lt;/b&gt;

This convenient mod allows you to build by copying buildings you have already have, saving you a trip to the Architect tab. Simply select a building, click a button, and place.
<description>This convenient mod allows you to build by copying buildings you have already have, saving you a trip to the Architect tab. Simply select a building, click a button, and place.

It also copies settings for buildings that have some. Currently it remembers electrical &lt;b&gt;power switches&lt;/b&gt;, heater and cooler &lt;b&gt;target temperature&lt;/b&gt;, turret &lt;b&gt;hold-fire&lt;/b&gt;, and trap &lt;b&gt;auto-rearm&lt;/b&gt;. Ask me for more if you need it!

Expand Down
2 changes: 1 addition & 1 deletion Source/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BuildProductive
[StaticConstructorOnStartup]
class Bootstrapper
{
public static readonly Logger.Level Verbosity = Logger.Level.Debug;
public static readonly Logger.Level Verbosity = Logger.Level.Info;

static Bootstrapper()
{
Expand Down
10 changes: 6 additions & 4 deletions Source/BuildProductive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AsmHelper.cs" />
<Compile Include="BuildingKeeper.cs" />
<Compile Include="Designator_BuildCopy.cs" />
<Compile Include="Bootstrapper.cs" />
<Compile Include="HookInjector.cs" />
<Compile Include="Platform.cs" />
<Compile Include="Globals.cs" />
<Compile Include="InitScript.cs" />
<Compile Include="Injection\AsmHelper.cs" />
<Compile Include="Injection\HookInjector.cs" />
<Compile Include="Injection\Platform.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Privates.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BuildingWatchdog.cs" />
<Compile Include="VerseExtensions.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
37 changes: 23 additions & 14 deletions Source/BuildingKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,36 @@ public void UnregisterFrame(Frame frame)
}
}

public void RegisterBuilding(Frame frame, Building building)
public bool RegisterBuilding(Thing thing, Building building, bool isCopy = false)
{
var id = frame.thingIDNumber;
BuildingInfo bi = new BuildingInfo();
var id = thing.thingIDNumber;
var isFound = false;

BuildingInfo bi;
if (_frames.TryGetValue(id, out bi))
if (thing is Frame && _frames.TryGetValue(id, out bi))
{
UnwrapInfo(building, bi);
_frames.Remove(id);
LogTransfer(frame, building);
isFound = true;
if (!isCopy) _frames.Remove(id);
}
else if (thing is Building && WrapInfo(thing as Building, out bi))
{
isFound = true;
isCopy = true;
}
else if (thing is Blueprint_Build && _blueprints.TryGetValue(id, out bi))
{
isFound = true;
if (!isCopy) _blueprints.Remove(id);
}
}

public void RegisterBuilding(Building source, Building destination)
{
BuildingInfo bi;
if (WrapInfo(source, out bi))
if (isFound)
{
UnwrapInfo(destination, bi);
LogTransfer(source, destination, true);
UnwrapInfo(building, bi);
LogTransfer(thing, building, isCopy);
return true;
}

return false;
}

public bool WrapInfo(Building building, out BuildingInfo bi)
Expand Down
4 changes: 2 additions & 2 deletions Source/Designator_BuildCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public override void DesignateSingleCell(IntVec3 c)

if (DebugSettings.godMode || entDef.GetStatValueAbstract(StatDefOf.WorkToMake, StuffDef) == 0f)
{
var building = Find.ThingGrid.ThingAt(c, LastThing.def) as Building;
Keeper.RegisterBuilding(LastThing as Building, building);
var building = Find.ThingGrid.ThingAt(c, entDef as ThingDef) as Building;
Keeper.RegisterBuilding(LastThing, building, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion deploy.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET dir="c:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\BuildProductive-0.15\"
SET dir="c:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods\BuildProductive-0.30\"

rd /s /q %dir%

Expand Down

0 comments on commit 43b02e0

Please sign in to comment.