RimWorld

RimWorld

676 ratings
PowerSwitch
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6
File Size
Posted
Updated
1.194 MB
4 Jul, 2016 @ 2:57pm
11 Jul @ 2:11pm
36 Change Notes ( view )

Subscribe to download
PowerSwitch

Description
This mod adds additional functions to the vanilla power switch.

Here you have various research topics available, which will improve the functionality of the switch.
You can research the upgrade for a motion detector, an enemy detector and for a timer.


Note: Mod settings are available.


Description:

- Pawn Detection in Room: Available after research with the normal switch.
Detects if a Pawn (human, animal) is in the room

- Pawn Detection within 7 squares: Available after research.
Normal pawn detection mode for wall switches.
Normal switches can be switched between this mode and the pawn in room mode by repeatedly pressing the selection button.

- Enemy detection (within 1/2 of the map): Available after research.
Available modes: Switch on when detected and switch off when detected.

- Timer: Switches on and off at specified times.
Time is initially set to 6h->On and 20h->Off. This can be changed by pressing the buttons repeatedly



NOTE:
This mod can savely be added to a running savegame, but to use the functionality you have to destroy and rebuild (by debug mode or the normal way) the switches you already have, as the old ones don't have the needed references.


(Version: 1.6.0)
Language: English, German, Russian, Chinese, Spanish

Thanks to duduluu and Biscuit for the Chinese translation
Thanks to 53N4 for the Spanish translation
Thanks to Well for the Russian translation
262 Comments
Haplo_X1  [author] 11 Jul @ 2:11pm 
Done
The Byzarkandian 11 Jul @ 11:44am 
1.6?
Haplo_X1  [author] 8 May @ 11:53am 
You can do a pull request if you like, then I can merge it
Scentese 6 May @ 7:40am 
Haplo_X1, should I make a push/fork/anything? All the code changes are just one block and one line. And thank you for the great mod!
Scentese 6 May @ 7:36am 
also add this in your class scope (outside of the method) if anyone is using the fix

private int lastCheckedHour = -1;
Scentese 6 May @ 7:33am 
I was using this mod along with Logic Switch. I am not sure if it resulted in any conflict, but this fix seems to have made the timer of this mod work for me, by flicking the switch only once per hour. The timer may not start to work immediately, but should do after an hour of in game time.
Scentese 6 May @ 7:33am 
with

[code]
// Improved Timer switching
if (autoSwitchTimerActive)
{
int currentHour = GenLocalDate.HourInteger(Map);

if (currentHour != lastCheckedHour)
{
lastCheckedHour = currentHour;

if (currentHour == autoSwitchTimerOnTime && !flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = true; // No designator usage!
SetWantSwitchOn(true);
}

if (currentHour == autoSwitchTimerOffTime && flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = false; // No designator usage!
SetWantSwitchOn(false);
}
}
}
[/code]
Scentese 6 May @ 7:32am 
ok I might have made a fix:

replace
[code]
// Timer switching
if (autoSwitchTimerActive)
{
// Time = Off-Time => Switch OFF
if (GenLocalDate.HourInteger(Map) == autoSwitchTimerOffTime && flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = false; // No designator usage!
SetWantSwitchOn(false);
}

// Time = On-Time => Switch ON
if (GenLocalDate.HourInteger(Map) == autoSwitchTimerOnTime && !flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = true; // No designator usage!
SetWantSwitchOn(true);
}
}
[/code]
Scentese 25 Apr @ 9:30pm 
I too feel the timer function is buggy. Could you please link the repo of 1.5 for me to take a look at?