Ludeon Forums

Ludeon Forums

  • July 02, 2020, 06:07:04 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 6

Author Topic: [A13] Modular Solar Panels (1.11)  (Read 68254 times)

Kirid

  • Colonist
  • ***
  • Posts: 372
  • Resident Polemicist
    • View Profile
[A13] Modular Solar Panels (1.11)
« on: March 11, 2014, 09:29:52 AM »


This adds single solar panels that are placed similar to walls.
Charge, health, and metal cost are close if not equal to the same fraction of a regular solar (1/16).
Colonists can walk on them and build floors underneath.

How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in the game.
Notes:
Thanks to Abrexus for a new texture and code help.
I give my permission to include this in any modpacks. Contact me if you plan to use or alter the code or art. Please give me credit in either case.
Changelog:
Code: [Select]
Released
1.1: Cleaned redundant code
     Panels no longer connect to walls
     Floors can be placed underneath                         
1.2: Updated for Alpha 3
1.3: Dll added - Now change charge depending on light level.
1.4: Updated for Alpha 5
1.5: Updated for Alpha 6
1.6: Updated for Alpha 7
     New texture and charge bar
1.7: Updated for Alpha 8
1.7.1: Changed fillpercent from 1 to 0.025
     Added mod menu picture
     Now requires research
1.8: Updated for Alpha 9
1.9: Updated for Alpha 10
     Changed texture
     Added slight pathing cost
1.9NoBars: Removed charge bar (Optional)
1.10: Updated to Alpha 11
     No change for Alpha 12
1.11: Updated to Alpha 13
1.11.1: Readded Building_Base
     Removed component breakdown


[attachment deleted by admin - too old]
« Last Edit: July 03, 2016, 06:05:50 PM by Kirid »
Logged
You can't rollerskate in a muffalo herd

Agthor

  • Muffalo
  • *
  • Posts: 7
  • Refugee
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #1 on: March 11, 2014, 09:35:12 AM »

Very nice, going to give this a try.
Logged

Kilroy232

  • Colonist
  • ***
  • Posts: 230
  • Process Automation Engineering Student
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #2 on: March 11, 2014, 01:29:11 PM »

Cool concept, and I really like that you put a good amount of thought into the distribution of resources needed and power output. having said that is it possible to make it so that they do not produce power during the night?

Vas

  • Colonist
  • ***
  • Posts: 875
  • Dragon
    • View Profile
    • Feral Dragon
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #3 on: March 11, 2014, 05:39:53 PM »

I like the concept, I haven't tested yet but I do know of one issue this might present, which is having a hard time repairing small solar panels in the center of a group.  EG if you build a 4x4 grid, the 2x2 in the middle, can't be repaired anymore.  You can't reach them.

Also that issue of producing power during the night that someone else just mentioned, though I believe that would be an easy fix, I think.  Not sure.
Logged
Click to see my steam. I'm a lazy modder who takes long breaks and everyone seems to hate.

Darker

  • Colonist
  • ***
  • Posts: 378
  • I'm Jack's twisted mind
    • View Profile
    • Rim world editor
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #4 on: March 11, 2014, 05:50:20 PM »

Why don't you use solar panel class to enforce solar panel behavior? Like this:


   <thingClass>Building_PowerPlantSolar</thingClass>



Edit: actually, that would cause nasty things to render on the screen. Nevemind.
« Last Edit: March 11, 2014, 05:52:05 PM by Darker »
Logged
Please... Throw human readable errors on savefile parsing failure!!!
Rim world editor Editor on GIT

JackQW

  • Drifter
  • **
  • Posts: 53
  • Refugee
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #5 on: March 11, 2014, 06:17:38 PM »

He could write his own C# mod for this...

Code: (C#) [Select]
using System;
using System.Reflection;
using UnityEngine;

public static class Reflect<T> { // basic reflection helper
const BindingFlags staticField =
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Static |
BindingFlags.GetField |
BindingFlags.GetProperty;
public static TResult GetStatic<TResult>(string name) {
return (TResult)typeof(T).InvokeMember(name, staticField, null, null, null);
}
}


public class Building_PowerPlantSimpleSolar : Building_PowerPlant {
    readonly float FullSunPower = Reflect<Building_PowerPlantSolar>.GetStatic<float>("FullSunPower");
    readonly float NightPower = Reflect<Building_PowerPlantSolar>.GetStatic<float>("NightPower");
   
    public override void Tick() {
        base.Tick();

        powerComp.powerOutput =
Find.RoofGrid.Roofed(Position)
? NightPower
: Mathf.Lerp(NightPower, FullSunPower, SkyManager.curSkyGlowPercent);
    }
}

Then it'd be...

<thingClass>Building_PowerPlantSimpleSolar</thingClass>
« Last Edit: March 11, 2014, 06:20:47 PM by JackQW »
Logged

Darker

  • Colonist
  • ***
  • Posts: 378
  • I'm Jack's twisted mind
    • View Profile
    • Rim world editor
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #6 on: March 11, 2014, 06:20:44 PM »

Wow, you're good with C#.
Logged
Please... Throw human readable errors on savefile parsing failure!!!
Rim world editor Editor on GIT

Kirid

  • Colonist
  • ***
  • Posts: 372
  • Resident Polemicist
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #7 on: March 11, 2014, 08:25:36 PM »

I like the concept, I haven't tested yet but I do know of one issue this might present, which is having a hard time repairing small solar panels in the center of a group.  EG if you build a 4x4 grid, the 2x2 in the middle, can't be repaired anymore.  You can't reach them.

I had this problem while I was testing them, they are currently set to standable, so no problem.

As for making them work at night As said,<thingClass>Building_PowerPlantSolar</thingClass> makes nasty power bars to appear, and I would fix it if it wasn't a class file.

He could write his own C# mod for this...

Then it'd be...

<thingClass>Building_PowerPlantSimpleSolar</thingClass>

Have you tested that and does it work?

On the other hand, I'd like to fix it connecting to walls, I thought maybe changing the Altas art for the wall to something more like a sandbagwall might fix it?
Logged
You can't rollerskate in a muffalo herd

JackQW

  • Drifter
  • **
  • Posts: 53
  • Refugee
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #8 on: March 11, 2014, 08:29:03 PM »

Nah I didn't want to go through all the project setup stuff to make a seperate one, I was investigating with other bits of craziness...


It might work though. Do you know how to create your own project, and throw that in? I'd be happy to help. :)

If you really want me to, I can make the project and add it to your mod, then send it to you... but then you'd have nothing much to do on your own. :P
Logged

Kirid

  • Colonist
  • ***
  • Posts: 372
  • Resident Polemicist
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #9 on: March 11, 2014, 08:38:13 PM »

Heh, I dont know how to write or inject a file like that. I might work on somethng else and let this mod rest until alpha 3, not much more I can do to it without alot of effort.
Logged
You can't rollerskate in a muffalo herd

JackQW

  • Drifter
  • **
  • Posts: 53
  • Refugee
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #10 on: March 11, 2014, 09:03:58 PM »

Code: (build.cmd) [Select]
set _64=
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set _64=64
set tools=%WinDir%\Microsoft.NET\Framework%_64%\v2.0.50727\
for /f "usebackq delims=." %%n in (`dir /a /b "..\..\..\*.exe"`) do set refs=..\..\..\%%~n_Data\Managed
%tools%csc.exe /nologo /noconfig /target:library /out:..\Assemblies\Mod.dll Mod.cs /nostdlib /lib:%refs% /r:"mscorlib.dll" /r:"System.dll" /r:"System.Core.dll" /r:"System.Security.dll" /r:"System.Configuration.dll" /r:"System.Xml.dll" /r:"System.Xml.Linq.dll" /r:"UnityEngine.dll" /r:"UnityScript.Lang.dll" /r:"Mono.Posix.dll" /r:"Mono.Security.dll" /r:"Boo.Lang.dll" /r:"Assembly-UnityScript-firstpass.dll" /r:"Assembly-CSharp-firstpass.dll" /r:"Assembly-CSharp.dll"
Code: (Mod.cs) [Select]
using System;
using System.Reflection;
using UnityEngine;

public static class Reflect<T> { // basic reflection helper
const BindingFlags staticField =
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Static |
BindingFlags.GetField |
BindingFlags.GetProperty;
public static TResult GetStatic<TResult>(string name) {
return (TResult)typeof(T).InvokeMember(name, staticField, null, null, null);
}
}


public class Building_PowerPlantSimpleSolar : Building_PowerPlant {
    readonly float FullSunPower = Reflect<Building_PowerPlantSolar>.GetStatic<float>("FullSunPower");
    readonly float NightPower = Reflect<Building_PowerPlantSolar>.GetStatic<float>("NightPower");
   
    public override void Tick() {
        base.Tick();

        powerComp.powerOutput =
Find.RoofGrid.Roofed(Position)
? NightPower
: Mathf.Lerp(NightPower, FullSunPower, SkyManager.curSkyGlowPercent);
    }
}

Attached above as a zip file.

Extract to <RimWorldGameDir>\Mods\ModSolar\Source (create the Source folder).
Create a folder <RimWorldGameDir>\Mods\ModSolar\Assemblies


This is a single-file style somewhat auto-config mod for you...
You still have to change the Xml, and you can play with the C# Mod.cs file...

[attachment deleted by admin: too old]
Logged

Kirid

  • Colonist
  • ***
  • Posts: 372
  • Resident Polemicist
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #11 on: March 11, 2014, 10:13:59 PM »

If I define <thingClass>Building_PowerPlantSimpleSolar</thingClass> I get an error.
<thingClass>Building_PowerPlant</thingClass> seems to work without error.
But they still have <eType>Wall</eType>, which is BuildingComplex on a regular solar.

In short.. they still dont react to day/night.

with a regular panel
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>-1</basePowerConsumption>
and mine need
<basePowerConsumption>-106</basePowerConsumption>
in order to match the power created, which leaves me to believe that the charge of the regular solar is from the class file, which I dont know how to find.
Mod solars are modeled like geyser generators, a set constant output. Its may be too wonkey of a building to easily edit.
Its still defined as a wall for the most part, except that it creates power, and we're trying to make it function like a regular solar. Its a bit of a mashup building

also Mods\ModSolar\Assemblies stays empty?

Thank you JackQW! You can help me as long as you are willing and able, this is a pretty awesome learning experience for me.
Logged
You can't rollerskate in a muffalo herd

JackQW

  • Drifter
  • **
  • Posts: 53
  • Refugee
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #12 on: March 11, 2014, 10:16:59 PM »

You have to run build.cmd
It'll run the .NET v2 (v3.5) framework compiler on Mod.cs, referencing the managed (Mono) libraries in the game directory, and build Mod.dll in the Assemblies folder.

If you run it by double clicking, it'll all happen very fast... add "pause" on a new line to the end to make it stay open.
If it still closes too fast, you have to open a command prompt, and enter "cd /d C:\PathToModFolderHere\", then "build", and paste the output in a reply.
« Last Edit: March 11, 2014, 10:20:28 PM by JackQW »
Logged

Kirid

  • Colonist
  • ***
  • Posts: 372
  • Resident Polemicist
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #13 on: March 11, 2014, 10:20:20 PM »

Okay, I had already done that
Logged
You can't rollerskate in a muffalo herd

JackQW

  • Drifter
  • **
  • Posts: 53
  • Refugee
    • View Profile
Re: [MOD] (Alpha 2) Modular Solar Panels
« Reply #14 on: March 11, 2014, 10:20:39 PM »

^ Edited post, sorry.

You should see output like this;
Code: [Select]
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>set
 _64=
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>if
"AMD64" == "AMD64" set _64=64
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>set
 tools=C:\Windows\Microsoft.NET\Framework64\v2.0.50727\
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>for
 /F "usebackq delims=." %n in (`dir /a /b "..\..\..\*.exe"`) do set refs=..\..\.
.\%~n_Data\Managed
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>set
 refs=..\..\..\RimWorld376WinDev_Data\Managed
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>C:\
Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe /nologo /noconfig /target:l
ibrary /out:..\Assemblies\Mod.dll Mod.cs /nostdlib /lib:..\..\..\RimWorld376WinD
ev_Data\Managed /r:"mscorlib.dll" /r:"System.dll" /r:"System.Core.dll" /r:"Syste
m.Security.dll" /r:"System.Configuration.dll" /r:"System.Xml.dll" /r:"System.Xml
.Linq.dll" /r:"UnityEngine.dll" /r:"UnityScript.Lang.dll" /r:"Mono.Posix.dll" /r
:"Mono.Security.dll" /r:"Boo.Lang.dll" /r:"Assembly-UnityScript-firstpass.dll" /
r:"Assembly-CSharp-firstpass.dll" /r:"Assembly-CSharp.dll"
X:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\RimWorld376WinDev\Mods\ModSolars\Source>pau
se
Press any key to continue . . .
« Last Edit: March 11, 2014, 10:47:28 PM by JackQW »
Logged
Pages: [1] 2 3 ... 6