Ludeon Forums

Ludeon Forums

  • February 02, 2023, 09:07:30 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Poll

What is your interest level in this?

None
Minor - But probably wouldn't use
Minor - May use if enough other people did
Somewhat - Would use if done properly
Interested - Would like to use and possibly contribute to

Author Topic: [Poll - Proposed] Community Core Library  (Read 2962 times)

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
[Poll - Proposed] Community Core Library
« on: April 23, 2015, 10:00:17 AM »

So, I've noticed quite the level of redundancy in the mods which are being produced.  Not so much in content of the mods but of the underlying code which drives them.  I propose that house some of those redundancies into a single core library and thereby have a "standard" of how to do common things as well as have a simple common requirement.  This will help for people on lower-end machines who may not have either the RAM or CPU to waste on code redundancies.  Further, it can also serve as an example of sorts for future modders who, quite frankly, don't have many good official sources to work off of and have to rely on examining the work of the existing mods on the forum and/or reverse-engineering the game (which has to be done to a certain extent anyway).

Where to get:  https://github.com/ForsakenShell/CommunityCoreLibrary

Please remember that this currently a WIP and not everything is 100%.  I am currently and actively working on the food system to allow new nutrient paste dispensers.

For those who voted on the poll and are interested in helping in any capacity (ideas, code, fixes, beer) - feel free to PM me and send the beer to...



Quote from: Original post for posterity
To that end, I present v0.1 of the "Community Core Library" for review by modders and feedback.  This is 100% open for discussion and debate as to how to approach a given problem.  I am providing everything thus far for peer review and hope to get a decent discussion going.

What it currently offers (everything is in the namespace CommunityCoreLibrary):

Alert_NeedMealSourceComplete : Alert_NeedMealSource
The new alert looks for any building with the CompFoodSource ThingComp instead of using hard-coded references.

Building_LightFixture : Building
Reduces the number of base light buildings.  You only need one def and it can support multiple colours after the appropriate research is complete.

Building_SunLampUV : Building
It's a sunlamp!  It's a temperature controller!

CompFoodSource : ThingComp
Flags a building as a food source.

CompPowerLowIdleDraw : ThingComp
Allows a building to use less power when idle.  No one leaves the stove on all night!
Currently operates in one of two modes, "InUse" (production tables) and "WhenNear" (doors, NPD).  Plan to add "GroupUse" for things like the television once I work out the detection code.

CompProperties_LowIdleDraw : CompProperties
Contains the values to influence how CompPowerLowIdleDraw works.
idlePowerFactor - Range 1.0 >= x >= 0.0 - Multiplier on basePowerConsumption for when the building is not in use.  Default 0.0
operationalMode - "InUse" or "WhenNear", determines when the building should come back to full-power.  Default "InUse"

PlaceWorker_OnlyOnItemSurface : PlaceWorker
Allows you to force placement on an existing building with an item surface.  Make sure the thing you're placing isn't an edifice.

PlaceWorker_OnlyUnderRoof : PlaceWorker
Allows you to restrict the placement of a new building to be under a roof.

PlaceWorker_WallAttachment : PlaceWorker
Force placement of the new building so it's "head" is against a proper support structure.  No floating wall lights!


Toils:  These are housed in the static class Toils_Common.

Toil SpawnThingOfCountAt( ThingDef of, int count, IntVec3 at )
Spawns count thingDefs of at location.

Toil ReplaceThingWithThingOfCount( Thing oldThing, ThingDef of, int count )
Removes oldThing and spawns count thingDefs of at the oldThings position.

Toil RemoveDesignationOfAt( DesignationDef of, IntVec3 at )
Removes designation of at location.

Toil RemoveDesignationOfOn( DesignationDef of, Thing on )
Removes designation of on thing.


Common functions:  Located in static class Common.

void ChangeThingDefDesignationCategoryDefOfTo( ThingDef t, string d )
Updates the thingdef to now use the new designation category.  Used internally by AdvancedResearch.

void ClearBuildingRecipeCache( ThingDef building )
Clears the buildings recipe cache.  Used internally by AdvancedResearch.

void ResolveDesignationCategoryDefs()
Rebuilds the designation categories after changing buildings designation category.  Used internally by AdvancedResearch.

bool ThingHasCategory( Thing t, ThingCategoryDef c )
Does this thing have a given thing category?


static class LightColour:  Contains the list of colours for lights (and anything else that wants colours in this fashion).


static class Icons:  Various icon refs used for the core library.


Advanced Research:  AdvancedResearchDef

This defines how multiple research projects interact as far as what recipes and buildings become available.  One AdvancedResearchDef can use multiple research projects to unlock multiple buildings OR multiple recipes on multiple buildings.  It is differentiated by an AdvancedResearchDef either containing recipeDefs or not.  If it does not contain any recipeDefs, then it will unlock tables.  If it has it, it will unlock recipes on tables.


The "mod" is mostly examples of how to do things, not a mod in-and-of-itself.  I'm also using some "borrowed" graphics to illustrate some aspects of the mod.
« Last Edit: April 30, 2015, 06:16:32 AM by 1000101 »
Logged
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

soltysek

  • Drifter
  • **
  • Posts: 81
  • TLM - Insane
    • View Profile
Re: [Proposed] Community Core Library
« Reply #1 on: April 23, 2015, 01:09:40 PM »

Nice idea :) if i can put my 3 cents ... i know that every one have it own idea about resources but as it was sad before by someone will be good to make something like Minecraft Forge Ore dictionary but to achive this as for now to avoid alot of hard code will be good to have open discuss about and create community base mod a base for every other mod that take care of base resources mayby other thing .
To avoid 2-3 same resource that cant be used crosed .
Logged

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
Re: [Proposed] Community Core Library
« Reply #2 on: April 23, 2015, 03:50:02 PM »

Well, I hate hard coding values *shakes fist at Tynan*, the food alert is one thing that bothered me and I fixed my own copy of A9 because I made a small mod to cook from campfires and the message annoyed me.

Don't think what I have done in any way reflects what this could end up as, this is just an initial proposal to the community.  I know I don't have all the answers or even the best answer to any given question.  This is just what I have come up for a skeleton which (hopefully) other modders will get behind.  (Haplo?  mrofa?  skullywag? ... ... :) )

The idea is that since most of the big mods have redundant code, is it not better to make something more central which *any* mod can use, leaving specialized code in the realm of individual mods.  But, since there are 10+ mods adding unlockable research, I figured this is a prime candidate.  Perhaps my method could be improved on, this is where I invite all to attend and offer input/improvements/code/beer.
Logged
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

soltysek

  • Drifter
  • **
  • Posts: 81
  • TLM - Insane
    • View Profile
Re: [Poll - Proposed] Community Core Library
« Reply #3 on: April 24, 2015, 04:20:33 AM »

 8) for me beer pls  8)
Logged

mrofa

  • Planetologist
  • ****
  • Posts: 1668
  • Squirrel Hunter
    • View Profile
Re: [Poll - Proposed] Community Core Library
« Reply #4 on: April 24, 2015, 04:32:57 AM »

Well i think its a greate idea and im 100% for it, especialy since i did discover what common library is 2 weeks ago ^^
And im trying it to implement in clutter. Can even contribiute few small things thrugh they would need to be optimize by some programmer :P
Logged
All i do is clutter all around.

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
Re: [Poll - Proposed] Community Core Library
« Reply #5 on: April 24, 2015, 01:52:07 PM »

Welp, I am a programmer, just not 100% familiar with RimWorlds inner workings although right now I'm plowing through designators, jobdrivers, toils and workgivers to recreating certain in-game functionality as an exercise.  I noticed that the "simplest" method is also the least satisfying and the core game does small things beyond move, wait, complete.  They play sounds, they have effects, etc.
Logged
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

UMK

  • Colonist
  • ***
  • Posts: 114
  • Refugee
    • View Profile
Re: [Poll - Proposed] Community Core Library
« Reply #6 on: April 24, 2015, 02:52:27 PM »

Maybe add a sort of facade for pawn? Lurking in health/mood/stance trackers is rare fun.
Logged

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
Re: [Poll - Proposed] Community Core Library
« Reply #7 on: April 24, 2015, 09:53:47 PM »

Can you provide an example of what you mean?  I really don't understand.

The idea with this is that it would be a generic set of library functions to reduce mod conflicts and redundancy.  To that end functions should be specific enough to be useful but not so specific as to be mod specific.  Eventually it should be on github or something for proper oss development.
Logged
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

RemingtonRyder

  • Mad Tester
  • Super Tester
  • Planetologist
  • ***
  • Posts: 2169
    • View Profile
    • My RimWorld Mods
Re: [Poll - Proposed] Community Core Library
« Reply #8 on: April 29, 2015, 08:54:57 PM »

Seems like a good idea. It gives modders access to a library to do common tasks that need doing. Saves re-inventing the wheel too. :)

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
Re: [Poll - Proposed] Community Core Library
« Reply #9 on: April 29, 2015, 11:21:08 PM »

I've got it up on github now and I am actively working on this code base and trying to work the basics out for maximum compatibility.

Now I am working on the FoodUtility (re-implementing it) to handle the new nutrient paste dispenser building class.  Which also entails re-implementing certain workgivers and jobs.  The final result is that it will support more than one definition of a nutrient paste dispenser.  I just wish that so many things weren't hard-coded so I don't have to copy-pasta-update so many classes to make it work.

Until I get "all the basics" done and stable, this will be a WIP modders resource and everyone is free to use any of the code segments for their own nefarious purposes.  I've licensed this project on github using The Unlicense.

https://github.com/ForsakenShell/CommunityCoreLibrary

Disclaimer:
THIS WORK IS NOT FINISHED AND IS SUBJECT TO RADICAL CHANGE UNTIL ALL CORE LIBRARY CODE IS COMPLETE.  IT IS COMPLETE WHEN IT IS COMPLETE.

Hopefully I don't have to do a lot of refactoring but until I get everything working "as it should," changes are bound to happen.  Once it is released, additions will follow the format of the rest of the library.  Until the basics are done, the format of the library can not be declared as things may need to change to work.  For example, I had to change how the hopper flag was implemented (from a thing comp to a comp property) adding a comp property to the thing comp because you can't (or I missed something) access the comps until a thingdef has been instantiated (thingdef->thing) but comp properties can be.

People are welcome to check it out as-is and offer suggestions, code, fixes, etc.
« Last Edit: April 30, 2015, 05:31:04 AM by 1000101 »
Logged
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By