Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Kilroy232

#1
Help / Creating a Semicircle Explosion
March 12, 2019, 03:27:19 PM
I have been looking at the C# code for the CompExplosion and wondering if it is possible for me to create a 'directed' explosion? I have experience in C# but most of what I do is procedural programming so I am not great at Class based programming.

I understand how the Radius for an explosion is calculated based on the number of combustible items in a stack if that is applicable but not where the "shape" of the explosion is derived from and is it possible for me to create new shapes.

I have provided the contents of the CompExplosive file for reference.


public class CompExplosive : ThingComp
{
public bool wickStarted;

protected int wickTicksLeft;

private Thing instigator;

public bool destroyedThroughDetonation;

protected Sustainer wickSoundSustainer;

public CompProperties_Explosive Props => (CompProperties_Explosive)props;

protected int StartWickThreshold => Mathf.RoundToInt(Props.startWickHitPointsPercent * (float)parent.MaxHitPoints);

private bool CanEverExplodeFromDamage
{
get
{
if (Props.chanceNeverExplodeFromDamage < 1E-05f)
{
return true;
}
Rand.PushState();
Rand.Seed = parent.thingIDNumber.GetHashCode();
bool result = Rand.Value < Props.chanceNeverExplodeFromDamage;
Rand.PopState();
return result;
}
}

public override void PostExposeData()
{
base.PostExposeData();
Scribe_References.Look(ref instigator, "instigator");
Scribe_Values.Look(ref wickStarted, "wickStarted", defaultValue: false);
Scribe_Values.Look(ref wickTicksLeft, "wickTicksLeft", 0);
Scribe_Values.Look(ref destroyedThroughDetonation, "destroyedThroughDetonation", defaultValue: false);
}

public override void CompTick()
{
if (wickStarted)
{
if (wickSoundSustainer == null)
{
StartWickSustainer();
}
else
{
wickSoundSustainer.Maintain();
}
wickTicksLeft--;
if (wickTicksLeft <= 0)
{
Detonate(parent.MapHeld);
}
}
}

private void StartWickSustainer()
{
SoundDefOf.MetalHitImportant.PlayOneShot(new TargetInfo(parent.Position, parent.Map));
SoundInfo info = SoundInfo.InMap(parent, MaintenanceType.PerTick);
wickSoundSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(info);
}

private void EndWickSustainer()
{
if (wickSoundSustainer != null)
{
wickSoundSustainer.End();
wickSoundSustainer = null;
}
}

public override void PostDraw()
{
if (wickStarted)
{
parent.Map.overlayDrawer.DrawOverlay(parent, OverlayTypes.BurningWick);
}
}

public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
{
absorbed = false;
if (!CanEverExplodeFromDamage)
{
return;
}
if (dinfo.Def.ExternalViolenceFor(parent) && dinfo.Amount >= (float)parent.HitPoints && CanExplodeFromDamageType(dinfo.Def))
{
if (parent.MapHeld != null)
{
Detonate(parent.MapHeld);
if (parent.Destroyed)
{
absorbed = true;
}
}
}
else if (!wickStarted && Props.startWickOnDamageTaken != null && dinfo.Def == Props.startWickOnDamageTaken)
{
StartWick(dinfo.Instigator);
}
}

public override void PostPostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
{
if (CanEverExplodeFromDamage && CanExplodeFromDamageType(dinfo.Def) && !parent.Destroyed)
{
if (wickStarted && dinfo.Def == DamageDefOf.Stun)
{
StopWick();
}
else if (!wickStarted && parent.HitPoints <= StartWickThreshold && dinfo.Def.ExternalViolenceFor(parent))
{
StartWick(dinfo.Instigator);
}
}
}

public void StartWick(Thing instigator = null)
{
if (!wickStarted && !(ExplosiveRadius() <= 0f))
{
this.instigator = instigator;
wickStarted = true;
wickTicksLeft = Props.wickTicks.RandomInRange;
StartWickSustainer();
GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(parent, Props.explosiveDamageType);
}
}

public void StopWick()
{
wickStarted = false;
instigator = null;
}

public float ExplosiveRadius()
{
CompProperties_Explosive props = Props;
float num = props.explosiveRadius;
if (parent.stackCount > 1 && props.explosiveExpandPerStackcount > 0f)
{
num += Mathf.Sqrt((float)(parent.stackCount - 1) * props.explosiveExpandPerStackcount);
}
if (props.explosiveExpandPerFuel > 0f && parent.GetComp<CompRefuelable>() != null)
{
num += Mathf.Sqrt(parent.GetComp<CompRefuelable>().Fuel * props.explosiveExpandPerFuel);
}
return num;
}

protected void Detonate(Map map)
{
if (!parent.SpawnedOrAnyParentSpawned)
{
return;
}
CompProperties_Explosive props = Props;
float num = ExplosiveRadius();
if (props.explosiveExpandPerFuel > 0f && parent.GetComp<CompRefuelable>() != null)
{
parent.GetComp<CompRefuelable>().ConsumeFuel(parent.GetComp<CompRefuelable>().Fuel);
}
if (props.destroyThingOnExplosionSize <= num && !parent.Destroyed)
{
destroyedThroughDetonation = true;
parent.Kill();
}
EndWickSustainer();
wickStarted = false;
if (map == null)
{
Log.Warning("Tried to detonate CompExplosive in a null map.");
return;
}
if (props.explosionEffect != null)
{
Effecter effecter = props.explosionEffect.Spawn();
effecter.Trigger(new TargetInfo(parent.PositionHeld, map), new TargetInfo(parent.PositionHeld, map));
effecter.Cleanup();
}
IntVec3 positionHeld = parent.PositionHeld;
float radius = num;
DamageDef explosiveDamageType = props.explosiveDamageType;
Thing thing = instigator ?? parent;
int damageAmountBase = props.damageAmountBase;
float armorPenetrationBase = props.armorPenetrationBase;
SoundDef explosionSound = props.explosionSound;
ThingDef postExplosionSpawnThingDef = props.postExplosionSpawnThingDef;
float postExplosionSpawnChance = props.postExplosionSpawnChance;
int postExplosionSpawnThingCount = props.postExplosionSpawnThingCount;
GenExplosion.DoExplosion(positionHeld, map, radius, explosiveDamageType, thing, damageAmountBase, armorPenetrationBase, explosionSound, null, null, null, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, props.applyDamageToExplosionCellsNeighbors, props.preExplosionSpawnThingDef, props.preExplosionSpawnChance, props.preExplosionSpawnThingCount, props.chanceToStartFire, props.damageFalloff);
}

private bool CanExplodeFromDamageType(DamageDef damage)
{
return Props.requiredDamageTypeToExplode == null || Props.requiredDamageTypeToExplode == damage;
}
}



#2
Outdated / [B18] Extended Surgery Mod
February 25, 2018, 12:42:11 PM
Extended Surgery Mod



Description
This mod adds new basic surgeries intended for mid to late game play that will help keep colonists happier and also stay as close to the vanilla game as possible.

With the ability to add replace whole limbs with bionics I think it is only reasonable that a player can expect to have the ability to preform less complex but still important surgeries. This is the premise for this mod.

The mod includes prosthetics for missing ears, eyes and noses to prevent colonists from picking on disfigured people. The ability to replace any shattered bone and to heal scratches to help reduce the amount of pain a colonist is in and to improve their productivity.

The mod doesn't require any research but you need to have a colonist with a high enough level of caring for all of the surgeries as well as artistics for the prostetics.

Notes
- You DO NOT need to start a new game for this mod
- Note that bones are replaced with Plasteel so you must have some to preform the operation

Changes For Version 1.1.0:
- I have added the ability to harvest and replace natural eyes

Download





Install
- Subscribe to the mod from the steam workshop page provided above or download from NexusMods.
- Activate the mod in the mod menu in the game.

License
Download and share this mod as you want but don't change it or sell it without my consent
#3
I am thinking of making a mod that would create a new gear item for pawns to wear. It would be a belt with a knife on it and it would allow pawns that are using a ranged weapon to have this knife to use if they are engaged in melee combat instead of just punching. It would give a bit of an edge to pawns if they are attacked by wild animals or enemy pawns.

I need some feedback on the idea though as I have lots of thoughts but I would like to know if others have similar thoughts.

1. Should pawns need to meet a minimum melee combat level before they are allowed to use this knife belt? Should there be any other restrictions?
2. What would you like to see the gear look like? (I would love a few test images if any graphic designers wanna draw up examples, I am not an impressive artist)
3. Would you use this mod if it worked as suggested?
#4
I am working on some code and I have attempted a few different methods of detecting if there are enemies withing a 3.1f radius including mimicking part of the turret code but I cannot successfully get the building to check if there are enemies around.

Does anyone happen to have a method to do this? If you would you mind pointing me in the right direction or sharing a snippet of code?
#5
Help / Adding a prerequisite to a XML patch
June 18, 2017, 12:55:56 PM
Is it possible to have a patch that has a prerequisite that you have to research before the patch is applied?
#6
Help / Modified Version of DeepDrill advice?
September 20, 2016, 03:28:34 PM
So having had a good look the DeepDrill building doesn't have a thingClass tag in the XML code, it has <compClass>CompDeepDrill</compClass> and I am not quite sure how that difference effects the building.

I am looking to make a building similar to the DeepDrill where this new drill would not look for resources below the surface at all but instead would just constantly produce a new resource I am working on, oil. The new Drill would still track progress and spit out s produce after so much progress but instead of then looking for a new Resource Lump in would just skip that step and start on more of the infinite oil supply.

This leads to my question, should I just create a building that has a thing class that does what I want or should I continue using the compClass and modify that?
#7
Mods / 'ship cracker' C# possibility?
September 11, 2016, 09:19:33 PM
despite my knowledge in C# I know how to program human machine interfaces not games.

Right now I am just looking to ask how hard it would be to write code to make it so that structure can only be built on top of another structure. I want to make a 'ship cracker', an IED that would destroy a fallen ship piece in one quick blow so that the mechs would be free to ambush at base.

The other way that I could implement this idea if the first is too hard is to make the 'ship cracker' a function that would be available when you selected the ship piece (after the necessary research) just like deconstruction and an explosive would be constructed and detonated.
#8
This is the error message I am getting, if anyone understands this I would love a little help on this one. Thank you!




UPDATE - trying to load a game anyway results in these errors.
There is something in my mod (the current version available for download if you feel like looking through it) that is making it so all items have the same value as wood... literally making every item in the game wood.

If I deconstruct metal, stone or anything I get wood.

#9
Help / Problems decompiling code
April 28, 2016, 10:48:06 PM
When decompiling C# code for the sunlamp I am getting sections that don't make any sense or simply do not work when I put them back into visual studios.

I understand that the software I use to view and decompile it doesn't read the Assembly-CSharp.ddl perfectly and that it is up to me to interpolate some of it but what can you do if you can't make sense of it?

I don't know that I can or should post the C# file that I retrieved from the Assembly-CSharp.ddl so I will start with this and see where people might suggest going
#10
Outdated / [A13] Power Efficient Lights v1.0
April 25, 2016, 03:01:01 PM
Power Efficient Lights

Description:
A simple mod that adds power efficient lights to the game. Includes a new research project and textures for the game for the power efficient standing lamp, as well as red, green and blue standing lamps. All power efficient lights run at 75w as apposed to the original 150w


Sub Topic
If people enjoy this little addition to the RimWorld game I would be interested in making more of the machines in the game power efficient or able to produce more power respectively.

Author/Mod Team
Kilroy232

Download



How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in the game.

License:
Download and share this mod as you want but don't change it or sell it without my consent
#11
Has anyone happen to run into this problem? I have been trying for a while now to fix the problem but I am not sure what the problem is (there could possibly be something new I missed).

Originally it was saying my Research.xml was causing the error so I removed it to test but
it just picks another .xml from my mod to throw the exception with (there could possible be something wrong with my file structure). Also I looked through the Biomes_Arid.xml and the World_oneshots_turrets.xml (A SoundDefs file also throwing the error) but I couldn't find any conflicts.

I won't post the Biomes_arid.xml code because if you own the game you have it, but here is the code for an xml that it claims is causing an error.

Code For the World_oneshots_turrets.xml

<?xml version="1.0" encoding="utf-8"?>
<DefPackage-SoundDef>

<SoundDef>
    <defName>StandardRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>StandardTurret/9mm_Single</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>SniperRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>SniperTurret/50Cal</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>IncediaryRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>IncendiaryTurret/Bren_LMG</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>HeavyRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>HeavyTurret/Heavy(M4A1)</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>MissileLaunch</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>TOWLauncher/missile</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>StunRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>StunTurret/Discharge</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

</DefPackage-SoundDef>


Lastly I cannot read all of the debugging code but I didn't see anything too useful in it, no specified lines of code or anything
#12
Mods / Rocket Artillery
February 22, 2016, 12:27:15 AM
So sitting at home brain storming some new weapons for RimWorld because that is kind of what I know.

What do you guys think about a Rocket Artillery security building? You would have to construct a group of 6 "dumb" missiles at a time at the same work bench that you would construct mortar shells. The artillery building itself would be similar to the vanilla artillery building but will require a small amount of power for the rocket pod to be able to rotate and the rocket artillery will have longer load times (I may even be able to make it so that load time depends on shooting skill).
Once loaded and manned the artillery will locate a target and fire all six rockets in a single volley. The accuracy of the area of effect will be higher than the vanilla artillery but each individual rockets accuracy is low meaning that each rocket will land in a different location in the area of effect.
It should be noted as well that each rockets blast radius will be smaller than the artillery shell.


#13
Help / Exception Parsing DLL Modding Error
March 13, 2015, 02:27:11 AM
So this is my first really crack at using C# to mod the game. I the tutorial posted as best I could and the C++ that I learned in university.

I thought I had everything right but I am getting an error I am not familiar with... I can post source code if necessary.
Image of the error message is bellow

Edit: Sorry I keep posting after work and I am really tired so I am not thinking this through 100%

XML Files: https://www.dropbox.com/s/7153cudo5397vs6/Turrets%20Pack.zip?dl=0
I am trying to mimic the action preformed when you research gun turret cooling but with turrets that have been added via mod.

[attachment deleted due to age]
#14
Help / Extending Stun Effect
March 11, 2015, 10:09:19 PM
I would simply like to know if it is possible to make the stun effect found in the game last longer
#15
 Extended Turrets Mod



Description:
An update for interested users, I have uploaded the mod to steam's workshop under the name "Extended Turrets Mod" for easier access and use for everyone on steam. As well as that I have updated the Nexus Mods page for the users who do not have or use steam. I hope that everyone continues to enjoy this mod and that your colonies stay safe and secure!
Extended Turrets Mod on Steam

This mod adds five new auto-turrets to game making it easier to defend your colony. There are also new research projects for the turrets along with custom sounds and textures.
This mod is meant for use in the later stages of the game and so to accommodate this each turret requires a hefty amount of research, resources and build time.

Notes:
Some features that can be expected in the future are some more research projects that will provide minor tweaks and improvements to the existing turrets.
I will continue to provide minor fixes and work on larger features for the mod.
!! I have not made any changes recently, just updated this page. You can expect updates soon and I am always happy to receive suggestions or told told about problems people are having.

Changes For Version 1.8.0:
-Updated for the Alpha 18 version of Rimworld

Turrets:
1. Standard Turret
This turret is as the name suggests, an improved version if the improvised turret. The turret fires in bursts of four with reduced cooldown time and increased health.

2. Long Range Turret
This turret is an improvised turret that has been fitted with an M-24 sniper rifle. A single high powered round is fired before cooldown, but the range and accuracy of the turret make up for the slow rate of fire, sometimes less is more.

3. Laser Turret
A complex assembly of lenses and electronics, this turret focuses a beam of high energy light at the enemy to deal damage with perfect accuracy but with pauses between charges.

5. Energy Turret
This is the tip top of the charts. This turret has it all, high rate of fire, high damage and high max health. Instead of using conventional projectiles this turret is able to convert electricity into an almost pure form of energy.

Download:




Install:
To install this mod you simply but the directory folder (the folder containing the About, Def, Texture... etc. folders) into your mods folder. In game select the mods menu and select the Turret Pack mod.
This mod does not require a new colony, you can start using it at any point and any update unless specified will not require a new colony.

Credit:
All of the new textures and the C# code for the 'lazer' turret are the work of mrofa. He has contributed lots of his time helping me put some more detail into this mod, he deserves a lot if credit for his skill I cannot thank him enough.

License:
Download and share this mod as you want but don't change it or sell it without my consent
#16
Help / Atlas textures formatting?
April 21, 2014, 06:58:24 PM
Modified the Mineral_Atlas texture so that the spots in the rock are blue (for crystal, I am just trying some different stuff) but in game the rock with crystal in it does not connect to each other properly.

Wondering if it is a formatting issue and hope someone can tell me what the proper format for the .png file is or if I need to be using a different file format altogether

[attachment deleted by admin: too old]
#17
Help / Plant.cs modding errors
April 17, 2014, 03:12:13 PM
This is directed to Tynan but I will happily take input from anyone.

I am working on making crystal stalagmite grow in the ground similar to plants but I want to create a new thingclass for them called 'Resource_Grow'. I have implemented a few changes but mostly I just want to get a functional build.

My code is as follows:

// Type: Plant
// Assembly: Assembly-CSharp, Version=0.3.5215.40225, Culture=neutral, PublicKeyToken=null
// MVID: 8B64AFE0-C40C-4282-B7C2-8F91E3F891DC
// Assembly location: C:\Users\Nile\Desktop\RimWorldAlpha3eWin\RimWorld410Win\RimWorld410Win_Data\Managed\Assembly-CSharp.dll

using Sound;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class Resource_Grow : Thing
{
    private static readonly Material MatSowing = MaterialPool.MatFrom("Things/Plant/Plant_Sowing");
    protected static readonly SoundDef SoundHarvestReady = SoundDef.Named("HarvestReady");
    public float growthPercent = 0.05f;
    private List<int> posIndexList = new List<int>();
    private Color32[] workingColors = new Color32[4];
    public const float BaseGrowthPercent = 0.05f;
    private const float RotDamagePerTick = 0.005f;
    private const int MinFoodFromFoodYieldingPlants = 2;
    private const float MaxAirPressureForDOT = 0.6f;
    private const float SuffocationMaxDOTPerTick = 0.01f;
    private const float GridPosRandomnessFactor = 0.3f;
    private const float MinGrowthToEat = 0.8f;
    private const int TicksWithoutLightBeforeRot = 50000;
    private PlantReproducer reproducer;
    private int age;
    private int ticksSinceLit;

    public bool HarvestableNow
    {
        get
        {
            if (this.def.plant.Harvestable)
                return (double)this.growthPercent > 0.800000011920929;
            else
                return false;
        }
    }

    public bool EdibleNow
    {
        get
        {
            return (double)this.growthPercent > 0.800000011920929;
        }
    }

    public bool Rotting
    {
        get
        {
            if (this.ticksSinceLit > 50000)
                return true;
            if (this.def.plant.LimitedLifespan)
                return this.age > this.def.plant.lifeSpan;
            else
                return false;
        }
    }

    private string GrowthPercentString
    {
        get
        {
            float num = this.growthPercent * 100f;
            if ((double)num > 100.0)
                num = 100.1f;
            return num.ToString("##0");
        }
    }

    public override string LabelMouseover
    {
        get
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append(this.def.label);
            stringBuilder.Append(" (" + this.GrowthPercentString + "% growth");
            if (this.Rotting)
                stringBuilder.Append(", dying");
            stringBuilder.Append(")");
            return stringBuilder.ToString();
        }
    }

    private bool HasEnoughLightToGrow
    {
        get
        {
            return Find.GlowGrid.PsychGlowAt(base.Position) <= this.def.plant.minGlowToGrow;
        }
    }

    public override Material DrawMat
    {
        get
        {
            if (this.LifeStage == PlantLifeStage.Sowing)
                return Resource_Grow.MatSowing;
            else
                return base.DrawMat;
        }
    }

    private float LocalFertility
    {
        get
        {
            return Find.FertilityGrid.FertilityAt(this.Position);
        }
    }

    public PlantLifeStage LifeStage
    {
        get
        {
            if ((double)this.growthPercent < 1.0 / 1000.0)
                return PlantLifeStage.Sowing;
            return (double)this.growthPercent > 0.999000012874603 ? PlantLifeStage.Mature : PlantLifeStage.Growing;
        }
    }

    static Resource_Grow()
    {
    }

    public override void SpawnSetup()
    {
        base.SpawnSetup();
        if (this.reproducer == null && (double)this.def.plant.seedEmitAveragePer20kTicks > 0.0)
            this.reproducer = new PlantReproducer(this);
        if (Find.Map.generating && this.def.plant.LimitedLifespan)
            this.age = Random.Range(0, this.def.plant.lifeSpan + 3000);
        for (int index = 0; index < this.def.plant.maxMeshCount; ++index)
            this.posIndexList.Add(index);
        GenList.Shuffle<int>((IList<int>)this.posIndexList);
    }

    public override void ExposeData()
    {
        base.ExposeData();
        Scribe_Values.LookValue<float>(ref this.growthPercent, "growthPercent", 0.0f, false);
        Scribe_Values.LookValue<int>(ref this.age, "age", 0, false);
        Scribe_Values.LookValue<int>(ref this.ticksSinceLit, "ticksSinceLit", 0, false);
    }

    public float Eaten(float nutritionWanted, Pawn eater)
    {
        this.PlantCollected();
        return this.def.food.nutrition;
    }

    public void PlantCollected()
    {
        if (this.def.plant.destroyOnHarvest)
        {
            this.Destroy();
        }
        else
        {
            this.growthPercent = 0.08f;
            Find.MapDrawer.MapChanged(this.Position, MapChangeType.Things);
        }
    }

    public override void TickRare()
    {
        bool enoughLightToGrow = this.HasEnoughLightToGrow;
        if (!enoughLightToGrow)
            this.ticksSinceLit += 250;
        else
            this.ticksSinceLit = 0;
        if (this.LifeStage == PlantLifeStage.Growing && enoughLightToGrow)
        {
            float num1 = (float)((double)this.LocalFertility * (double)this.def.plant.fertilityFactorGrowthRate + (1.0 - (double)this.def.plant.fertilityFactorGrowthRate));
            float num2 = 1f;
            if ((double)DateHandler.CurDayPercent < 0.200000002980232 || (double)DateHandler.CurDayPercent > 0.800000011920929)
                num2 *= 0.5f;
            this.growthPercent += (float)((double)num1 * (double)num2 * 250.0 * ((double)this.def.plant.growthPer20kTicks / 20000.0));
        }
        this.age += 250;
        if (this.Rotting && this.def.plant.LimitedLifespan)
        {
            int amount = Mathf.CeilToInt(1.25f);
            this.TakeDamage(new DamageInfo(DamageTypeDefOf.Rotting, amount, (Thing)null));
        }
        if (this.destroyed || this.reproducer == null)
            return;
        this.reproducer.PlantReproducerTickRare();
    }

    public int FoodYieldNow()
    {
        if (!this.HarvestableNow)
            return 0;
        if ((double)this.def.plant.maxFoodYield <= 1.0)
            return Mathf.RoundToInt(this.def.plant.maxFoodYield);
        int num = Gen.RandomRoundToInt(this.def.plant.maxFoodYield * ((float)this.health / (float)this.def.maxHealth) * this.growthPercent);
        if (num < 2)
            num = Mathf.Min(2, Gen.RandomRoundToInt(this.def.plant.maxFoodYield));
        return num;
    }

    public override void PrintOnto(SectionLayer layer)
    {
        Vector3 vector3 = Gen.TrueCenter((Thing)this);
        Random.seed = this.Position.GetHashCode();
        float max1 = this.def.plant.maxMeshCount != 1 ? 0.5f : 0.05f;
        int num1 = Mathf.CeilToInt(this.growthPercent * (float)this.def.plant.maxMeshCount);
        if (num1 < 1)
            num1 = 1;
        int num2 = 1;
        int num3 = this.def.plant.maxMeshCount;
        switch (num3)
        {
            case 1:
                num2 = 1;
                break;
            case 4:
                num2 = 2;
                break;
            default:
                if (num3 != 9)
                {
                    if (num3 != 16)
                    {
                        if (num3 == 32)
                        {
                            num2 = 5;
                            break;
                        }
                        else
                        {
                            Log.Error((string)(object)this.def + (object)" must have plant.MaxMeshCount that is a perfect square.");
                            break;
                        }
                    }
                    else
                    {
                        num2 = 4;
                        break;
                    }
                }
                else
                {
                    num2 = 3;
                    break;
                }
        }
        float num4 = 1f / (float)num2;
        Vector3 center1 = Vector3.zero;
        Vector2 size = Vector2.zero;
        int num5 = 0;
        int count = this.posIndexList.Count;
        for (int index = 0; index < count; ++index)
        {
            int num6 = this.posIndexList[index];
            float num7 = this.def.plant.visualSizeRange.LerpThroughRange(this.growthPercent);
            if (this.def.plant.maxMeshCount == 1)
            {
                center1 = vector3 + new Vector3(Random.Range(-max1, max1), 0.0f, Random.Range(-max1, max1));
                float num8 = Mathf.Floor(vector3.z);
                if ((double)center1.z - (double)num7 / 2.0 < (double)num8)
                    center1.z = num8 + num7 / 2f;
            }
            else
            {
                center1 = this.Position.ToVector3();
                center1.y = this.def.altitude;
                center1.x += 0.5f * num4;
                center1.z += 0.5f * num4;
                int num8 = num6 / num2;
                int num9 = num6 % num2;
                center1.x += (float)num8 * num4;
                center1.z += (float)num9 * num4;
                float max2 = num4 * 0.3f;
                center1 += new Vector3(Random.Range(-max2, max2), 0.0f, Random.Range(-max2, max2));
            }
            bool flag = (double)Random.value < 0.5;
            Material mat = GenList.RandomListElement<Material>(this.def.folderDrawMats);
            this.workingColors[1].a = this.workingColors[2].a = (byte)((double)byte.MaxValue * (double)this.def.plant.topWindExposure);
            this.workingColors[0].a = this.workingColors[3].a = (byte)0;
            if (this.def.overdraw)
                num7 += 2f;
            size = new Vector2(num7, num7);
            bool flipUv = flag;
            Printer_Plane.PrintPlane(layer, center1, size, mat, 0.0f, flipUv, (Vector2[])null, this.workingColors);
            ++num5;
            if (num5 >= num1)
                break;
        }
        if (this.def.sunShadowInfo == null)
            return;
        float num10 = (double)size.y >= 1.0 ? 0.81f : 0.6f;
        Vector3 center2 = center1;
        center2.z -= size.y / 2f * num10;
        center2.y -= 0.04f;
        Printer_Shadow.PrintShadow(layer, center2, this.def.sunShadowInfo);
    }

    public override string GetInspectString()
    {
        StringBuilder stringBuilder1 = new StringBuilder();
        stringBuilder1.Append(base.GetInspectString());
        stringBuilder1.AppendLine();
        StringBuilder stringBuilder2 = stringBuilder1;
        string key1 = "PercentGrowth";
        object[] objArray1 = new object[1];
        int index1 = 0;
        string growthPercentString = this.GrowthPercentString;
        objArray1[index1] = (object)growthPercentString;
        string str1 = LanguageDatabase.Translate(key1, objArray1);
        stringBuilder2.AppendLine(str1);
        if (this.LifeStage != PlantLifeStage.Sowing)
        {
            if (this.LifeStage == PlantLifeStage.Growing)
            {
                if (!this.HasEnoughLightToGrow)
                {
                    StringBuilder stringBuilder3 = stringBuilder1;
                    string key2 = "NotGrowingNow";
                    object[] objArray2 = new object[1];
                    int index2 = 0;
                    string str2 = GlowUtility.HumanName(this.def.plant.minGlowToGrow).ToLower();
                    objArray2[index2] = (object)str2;
                    string str3 = LanguageDatabase.Translate(key2, objArray2);
                    stringBuilder3.AppendLine(str3);
                }
                else
                    stringBuilder1.AppendLine(LanguageDatabase.Translate("Growing"));
                int numTicks = (int)((1.0 - (double)this.growthPercent) * (20000.0 / (double)this.def.plant.growthPer20kTicks));
                if (this.def.plant.Harvestable)
                {
                    StringBuilder stringBuilder3 = stringBuilder1;
                    string key2 = "HarvestableIn";
                    object[] objArray2 = new object[1];
                    int index2 = 0;
                    string str2 = GenTime.TicksInDaysString(numTicks);
                    objArray2[index2] = (object)str2;
                    string str3 = LanguageDatabase.Translate(key2, objArray2);
                    stringBuilder3.AppendLine(str3);
                }
                else
                {
                    StringBuilder stringBuilder3 = stringBuilder1;
                    string key2 = "FullyGrownIn";
                    object[] objArray2 = new object[1];
                    int index2 = 0;
                    string str2 = GenTime.TicksInDaysString(numTicks);
                    objArray2[index2] = (object)str2;
                    string str3 = LanguageDatabase.Translate(key2, objArray2);
                    stringBuilder3.AppendLine(str3);
                }
            }
            else if (this.LifeStage == PlantLifeStage.Mature)
            {
                if (this.def.plant.Harvestable)
                    stringBuilder1.AppendLine(LanguageDatabase.Translate("ReadyToHarvest"));
                else
                    stringBuilder1.AppendLine(LanguageDatabase.Translate("Mature"));
            }
        }
        return stringBuilder1.ToString();
    }

    public override void Destroy()
    {
        base.Destroy();
        Find.DesignationManager.RemoveAllDesignationsOn((Thing)this);
    }
}



When I try to compile I am getting two errors originating from the same line.
Error message:

Error   1   The best overloaded method match for 'PlantReproducer.PlantReproducer(Plant)' has some invalid arguments   c:\users\nile\documents\visual studio 2013\Projects\Resource_Grow1\Resource_Grow1\Class1.cs
Error   2   Argument 1: cannot convert from 'Resource_Grow' to 'Plant'   c:\users\nile\documents\visual studio 2013\Projects\Resource_Grow1\Resource_Grow1\Class1.cs

The line of code it refers to is this with the bolded text being the error itself:

public override void SpawnSetup()
    {
        base.SpawnSetup();
        if (this.reproducer == null && (double)this.def.plant.seedEmitAveragePer20kTicks > 0.0)
            this.reproducer = new  PlantReproducer(this);
        if (Find.Map.generating && this.def.plant.LimitedLifespan)
            this.age = Random.Range(0, this.def.plant.lifeSpan + 3000);
        for (int index = 0; index < this.def.plant.maxMeshCount; ++index)
            this.posIndexList.Add(index);
        GenList.Shuffle<int>((IList<int>)this.posIndexList);
    }
   

Lastly I am too lazy to replace my name in the directory paths so ya, my name is really Nile :P
#18
Help / Map Generation Mod?
April 15, 2014, 03:37:24 PM
So looking at the BaseMapGenerators.xml and trying to figure out how I would go about making it so that the game would spawn Crystal stalagmites inside the rock?


<!-- Place minerals inside the rocks -->
<li Class="Genner_ScatterMinerals">
<thingDefs>
<li>Mineral</li>
</thingDefs>
<chunkSize>29</chunkSize>
<minSpacing>5</minSpacing>
<countPer10kSquaresRange>
<min>10</min>
<max>10</max>
</countPer10kSquaresRange>
<forcedPlaceOffsets>
<li>(-5,0,-11)</li>
</forcedPlaceOffsets>
</li>

<!-- Steam geysers -->
<li Class="Genner_ScatterThings">
<thingDefs>
<li>SteamGeyser</li>
</thingDefs>
<minSpacing>35</minSpacing>
        <buildableAreaOnly>true</buildableAreaOnly>
<countPer10kSquaresRange>
<min>0.7</min>
<max>1.0</max>
</countPer10kSquaresRange>
<clearSpaceSize>30</clearSpaceSize>
<minDistToPlayerStart>15</minDistToPlayerStart>
</li>


So i am wondering specifically what the <thingDefs><li>Mineral</li></thingDefs> references and where that reference can be found so that I can begin making a new one for my purpose
#19
Outdated / [MOD] (Alpha 3) Railgun Superweapon
April 13, 2014, 02:41:39 PM
RailGun Superweapon




Description:
This mod was really more for my amusement but I did think it turned out pretty well so I thought I would release it to you folks to check out, if it is well received I will add more features.
It is a heavily armored Railgun that fires single rounds of solid metal at supersonic speeds. In an attempt to balance it out I added a research requirement, made the resources needed to build it high, and it also has a high power consumption.

Features:

  • Custom textures and firing sound
  • New research project
  • New Turret

Mod Team:
  • Kilroy232

How to Install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in the game.

How to use:
Pretty simple, install and activate. Research and destroy the raiders in style.

Download:
To download go to the bottom of this post and click the attached file, I will be adding it to Rimworld Nexus ASAP.

ScreenShots:


Notes:
Due to the high power requirement I suggest you go download Psyckosama's Atomic Power mod.

Thanks again,
Kilroy232

[attachment deleted by admin: too old]
#20
Help / Help with advance turret design
March 03, 2014, 06:36:59 PM
So i am looking to use the rocket and or shells that are already available in the game to design a more powerful turret. I simply want to know if this is possible in this build of the game.

I am also looking into making artillery of some sort and I would like to know if there is a way to set projectiles to go over the 'BuildingTall' height.

Thank you in advance for the advice/help,
Kilroy232