A4 and later will include some source files for modder reference.
I thought I might as well release them here early; they might help someone.
http://puu.sh/8tVfJ.zip
Thanks tynan this will prove very helpful when writing dll's in my mod, and I'm sure will be helpful for the other modders too, I have not had a look at it yet as I'm tired and working on some simple things in xml before bed, but I'm sure to dive in when something arises that I want to edit.
What is this? I see comments, proper formatting, no internal variables named 'current'... it... its beautiful.
In all seriousness, this is fantastic. Much easier to read than what we can get through something like ILSpy.
Awesome sauce! Also, nice selection of classes, seems to cover a lot of interesting things :).
mmmm, that new code smell...
Quote from: Architect on May 01, 2014, 05:21:03 PM
mmmm, that new code smell...
I really hope there aren't too many code smells (http://en.wikipedia.org/wiki/Code_smell). :)
I like the comments being put into the code, it's very helpful for people who aren't great programmers haha :) It certainly helps me anyway :)
Where is the image for a standard metal wall located?
Quote from: dadog99 on May 30, 2014, 09:53:58 PM
Where is the image for a standard metal wall located?
it should be there
http://ludeon.com/forums/index.php?topic=2325.0 (http://ludeon.com/forums/index.php?topic=2325.0)
With the new alpha4 it states in the modding file that partial source code is included with the game but it isn't there? ..>
Crap, you're right. The build script must have broken and I didn't notice. Let me fix it.
All right, fixed and hotfixed. If you re-download the game you'll get Alpha4b which is identical in the built version, but includes the source.
Quote from: Tynan on June 02, 2014, 08:36:42 AM
All right, fixed and hotfixed. If you re-download the game you'll get Alpha4b which is identical in the built version, but includes the source.
Lol We all have those moments :p Thank you :)
Hi Tynan,
Could you add GenAI, it seems not do decompile well.
And somhow you changed the way targets are selected between alpha 3 and 4.
Regards,
Mr Nice
Here's how GenAI looks now:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;
using Verse;
using RimWorld;
namespace Verse.AI{
public static class GenAI
{
public static Thing BestShootTarget(IntVec3 root,
Thing searcher,
RegionTraverseParameters traverseParams,
Predicate<Thing> validator,
float maxDistance,
float minDistance,
bool needsLOStoDynamic,
bool needsLOStoStatic,
bool shootBurning = true )
{
Pawn searcherPawn = searcher as Pawn;
//Figure out what enumerable to search through the find the target
//Can include enemy pawns or buildings
IEnumerable<Thing> targetEnum;
SquadBrain searcherKing = null;
if( searcherPawn != null )
searcherKing = searcherPawn.GetSquadBrain();
if( searcherKing != null )
{
//Special target list: Anything on king's hit list
targetEnum = searcherKing.GetAttackTargets();
}
else
{
//Standard target list: All hostile pawns
targetEnum = PawnTargetsFor( searcher.Faction );
}
float minDistanceSquared = minDistance*minDistance;
Predicate<Thing> inValidator = t=>
{
if( validator != null && !validator(t) )
return false;
if( searcherPawn != null && !searcherPawn.CanReach(t, PathMode.Touch) )
return false;
if( (root - t.Position).LengthHorizontalSquared < minDistanceSquared )
return false;
if( needsLOStoDynamic || needsLOStoStatic )
{
if (!searcher.CanSee(t))
{
if (t is Pawn)
{
if (needsLOStoDynamic)
return false;
}
else
{
if (needsLOStoStatic)
return false;
}
}
}
Pawn p = t as Pawn;
if( p != null && p.Incapacitated )
return false;
if( !shootBurning && t.IsBurning() )
return false;
return true;
};
return GenClosest.ClosestThingReachableGlobal( searcher.Position,
targetEnum,
PathMode.Touch,
traverseParams,
maxDistance: maxDistance,
validator: inValidator);
}
public static IEnumerable<Thing> PawnTargetsFor( Faction faction )
{
return from pawn in Find.ListerPawns.PawnsHostileTo(faction)
where !pawn.Incapacitated
select (Thing)pawn;
}
//This method resembles Ability.ShootLineFromTo a little too much. Perhaps they should merge somehow
public static bool CanSee( this Thing seer, Thing target )
{
foreach( IntVec3 sourceCell in ShootLeanUtility.ShootingSourcesFromTo(seer.Position, target.Position) )
{
foreach( IntVec3 destCell in ShootLeanUtility.ShootableSquaresOf( target ) )
{
if( GenSight.LineOfSight( sourceCell, destCell ) )
return true;
}
}
return false;
}
public static bool MachinesLike(Faction machineFaction, Pawn p)
{
if( p.Faction == null )
return false;
if ( p.JailerFaction == machineFaction )
return false;
return !p.Faction.IsHostileToward(machineFaction);
//return p.Faction == machineFaction;
}
public static bool CanUseItem( Pawn p, Thing item )
{
if( item.IsForbidden( p.Faction ) )
return false;
if( !p.CanReserveAndReach( item, ReservationType.Total, PathMode.ClosestTouch ) )
return false;
return true;
}
}}
/* Old ClosestEnemyTarget loop
float MaxDistanceSquared = MaxDistance*MaxDistance;
float ClosestSquaredDist = float.MaxValue;
Pawn ClosestEnemy = null;
foreach( Pawn p in Find.PawnManager.PawnsWithHostilityTo[Searcher.Team] )
{
float SquaredDist = (p.Position - Searcher.Position).LengthHorizontalSquared;
if( SquaredDist < ClosestSquaredDist && SquaredDist <= MaxDistanceSquared )
{
if( NeedsLOS && !Searcher.CanSee(p) )
continue;
ClosestSquaredDist = SquaredDist;
ClosestEnemy = p;
}
}
return ClosestEnemy;
*/
Is this code from an unreleased version?
IntVec3 root,
Thing searcher,
RegionTraverseParameters traverseParams,
Predicate<Thing> validator,
float maxDistance,
float minDistance,
bool needsLOStoDynamic,
bool needsLOStoStatic,
bool shootBurning = true
In Alpha4f BestShootTarget is missing minDistance.
Regards,
Mr Nice
mrnic3 - Yes, I'm sorry, it is. You may want to disregard the code I posted. It is for Alpha5 dev version.
would it be possible to get the drop pod related source files ? I'm trying to make meteors for my mod that drop similar to the droppods and I'm having problems left and right, looking at the existing code would likely help me immensely.
Quote from: Jerethi50 on July 23, 2014, 02:16:14 PM
would it be possible to get the drop pod related source files ? I'm trying to make meteors for my mod that drop similar to the droppods and I'm having problems left and right, looking at the existing code would likely help me immensely.
Sure http://puu.sh/anYyo/58547fbee1.zip
having a problem with a line,
ticksToImpact = Rand.RangeInclusive(MinTicksToImpact,MaxTicksToImpact);
from the droppodincoming file you sent me. says
Error 3 The name 'Rand' does not exist in the current context
The code I sent is for A6, it won't work with A5. Replace the call with with UnityEngine.Random.Range
Is there any way to Draw glowing light alongside the moving mesh in DropPodIncoming ?
Hi Tynan, I was wondering if we could get some of the source code for the workgivers and jobdrivers? I can't make head or tail of how it is done D:
Thanks,
mipen
There is some included in the game.
Yeah, the yield keywords completely throw the decompilers off and make them write some nonsense instead of actual code. I tried to take a look at how the kidnapping job worked and got nothing, and it's quite hard to find out how to do such things purely from looking at the hauling jobs. :)
No, I mean the source code is included. There are some jobdrivers and workgivers, I believe.
Quote from: Tynan on July 31, 2014, 06:06:02 PM
No, I mean the source code is included. There are some jobdrivers and workgivers, I believe.
Oh, I completely missed those! Haha, thanks =]
Hi Tynan, I hate to bother you again, but would it be possible to get the source code for the hopper? Thanks
I don't think it has any source code, it's just a dumb building.
"Work, you dumb building!"
No, Tynan, the politically-correct way to say it is 'code-less'.
it just has the Storage settings code, I was wondering how it worked while trying to figure out a way to make a sort of 'chest', but I've figured it out now. Thanks for your time :]
Would it be possible to get the entire source code of the 'Assembly-CSharp.dll' for the purpose of making a Total Conversion mod?
Quote from: Argain on August 14, 2014, 03:16:17 PM
Would it be possible to get the entire source code of the 'Assembly-CSharp.dll' for the purpose of making a Total Conversion mod?
Not sure what you need all of the source code for, but you can decompile that .dll with http://www.jetbrains.com/decompiler/ - just export it into a .sln file so you can work with it in Visual Studio, otherwise you can use any IDE you want.
Be warned though, there's a
lot of code. Good luck!
be warned, classes are decompiled with errors that must be manually fixed afterward.
in case of entire source, it will be huge deal to force users to download mod running from separate exe, and you will need to provide executable for each platform.
It wouldn't need to be a separate exe, just an alternative Assembly-CSharp.dll.
in this case you will need to force users to replace basefiles of game.
Hi Tynan, not sure if you'll see this post, but would it be possible to get the source code for the pawn class? Particularly I am interested in seeing how the GetCommands() function works, as I would like to do something similar to how the drafted force attack works with colonists. I'm interested in seeing how it takes control of the mouse click and displays the UI on the cursor, and listens for a mouseclick, then sends that info to the pawn to carry out the job. I'm not sure if this is done in the pawn GetCommands(), or elsewhere but any help in finding it would be greatly appreciated! :D Cheers
Use ILSpy to decompile the main DLL located in RimWorldinstallDir/RimWorlAlphaXXX_Data/Managed/Assembly-CSharp.dll
It contains all the source code. :)
Be aware that this is a biiiig piece of code! :o
The part that I'm interested in is hidden by the way compiler, so the whole method appears as a big mess :(