Corpses appear on top of custom grave instead of being invisible

Started by ItchyFlea, March 14, 2015, 06:46:57 PM

Previous topic - Next topic

ItchyFlea

For some reason, when using my custom code to have a different grave graphic shown for a full grave, corpses are shown on top of the grave instead of being made invisible like normal graves.

I had to remove a part of the grave code which I suspect is the responsible part, because ILSpy gives me this which is useless, and I don't know how to write my own:
public override IEnumerable<IntVec3> AllSlotCells()
{
Building_Grave.<AllSlotCells>c__Iterator97 <AllSlotCells>c__Iterator = new Building_Grave.<AllSlotCells>c__Iterator97();
<AllSlotCells>c__Iterator.<>f__this = this;
Building_Grave.<AllSlotCells>c__Iterator97 expr_0E = <AllSlotCells>c__Iterator;
expr_0E.$PC = -2;
return expr_0E;
}


Any suggestions on why it's not hiding the corpse if the missing IEnumerable isn't the problem.
Or can someone write an IEnumerable that I could use for the grave?

EDIT: Even when using the thingclass the game gives to normal graves the corpse is still visible. Is there any way to override the game and make the corpse invisible once it's been put into the grave?
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

skullywag

doesnt it treat it like a container? look at the crypto casket or my auto heal casket for example.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

ItchyFlea

Not really.

The thing that hides the corpse, at least as far as I can tell, is in the corpse code (Verse.Corpse). I have no idea how to override it.
public override void DrawAt(Vector3 drawLoc)
{
Building building = this.StoringBuilding();
if (building != null && building.def == ThingDefOf.Grave)
{
return;
}
BodyDrawType bodyDrawType = BodyDrawType.Normal;
CompRottable comp = base.GetComp<CompRottable>();
if (comp != null)
{
if (comp.Stage == RotStage.Rotting)
{
bodyDrawType = BodyDrawType.Rotting;
}
else
{
if (comp.Stage == RotStage.Dessicated)
{
bodyDrawType = BodyDrawType.Dessicated;
}
}
}
this.innerPawn.drawer.renderer.RenderPawnAt(drawLoc, bodyDrawType);
}
All my mods are licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
Ask for permission before using in ModPacks

Click here for a list of the mods I've created

skullywag

Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Leeman

[...]
Edit:  nvm. sorry. didn't see the 'Edit' in the first post

Leeman

Not sure it counts as new Post if I edit my old post so you could see that there's a new reply here @ItchyFlea.. I have a little workarround for your problem if interrested ;)

What you can do is create a MapComponent that runs every so often and checks if a grave was built and set the def of that grave to ThinkDefOf.Grave if it is not the case.. I'll add my xml and my code here so you can see how I did it and then adjust it to your needs. I do not have anything in regards of different materials for the graves or a mass grave but I looked at a way to make it so the corpses get hidden in the custom graves^^


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


  <ThingDef Name="BuildingBase" Abstract="True">
    <category>Building</category>
    <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
    <selectable>true</selectable>
    <drawerType>MapMeshAndRealTime</drawerType>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <repairEffect>Repair</repairEffect>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <filthLeaving>BuildingRubble</filthLeaving>
  </ThingDef>

  <!-- Grave building definition -->

<ThingDef ParentName="BuildingBase">
    <defName>Grave</defName>
    <eType>BuildingInert</eType>
    <label>Common Grave</label>
    <thingClass>Building_Grave</thingClass>
    <graphicPath>Things/Building/Misc/GraveEmpty</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <graphicOverdraw>true</graphicOverdraw>
    <constructEffect>ConstructDirt</constructEffect>
    <altitudeLayer>FloorEmplacement</altitudeLayer>
    <useStandardHealth>false</useStandardHealth>
    <description>Place the dead in graves to give them a decent final resting place.</description>
    <size>(1,2)</size>
    <statBases>
      <WorkToMake>650</WorkToMake>
    </statBases>
    <passability>Standable</passability>
    <building>
      <fixedStorageSettings>
        <allowances>
          <categories>
            <li>Corpses</li>
          </categories>
        </allowances>
      </fixedStorageSettings>
      <defaultStorageSettings>
        <priority>Important</priority>
        <allowances>
          <categories>
            <li>CorpsesHumanoid</li>
          </categories>
          <specialFiltersToAllow>
            <li>AllowBuried</li>
          </specialFiltersToAllow>
        </allowances>
      </defaultStorageSettings>
    </building>
    <inspectorTabs>
      <li>ITab_Storage</li>
    </inspectorTabs>
    <terrainAffordanceNeeded>Diggable</terrainAffordanceNeeded>
    <designationCategory>Misc</designationCategory>
    <itemSurface>true</itemSurface>
    <designationHotkey>G</designationHotkey>
  </ThingDef>
 
<ThingDef ParentName="BuildingBase">
    <defName>ColonistGrave</defName>
    <eType>BuildingInert</eType>
    <label>Grave for Colonists</label>
    <thingClass>Building_Grave</thingClass>
    <graphicPath>Things/Building/Misc/GraveEmpty</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <graphicOverdraw>true</graphicOverdraw>
    <constructEffect>ConstructDirt</constructEffect>
    <altitudeLayer>FloorEmplacement</altitudeLayer>
    <useStandardHealth>false</useStandardHealth>
    <description>Place the dead in graves to give them a decent final resting place. Preset for Colonists only</description>
    <size>(1,2)</size>
    <statBases>
      <WorkToMake>650</WorkToMake>
    </statBases>
    <passability>Standable</passability>
    <building>
      <fixedStorageSettings>
        <allowances>
          <categories>
            <li>Corpses</li>
          </categories>
        </allowances>
      </fixedStorageSettings>
      <defaultStorageSettings>
        <priority>Important</priority>
        <allowances>
          <categories>
            <li>CorpsesHumanoid</li>
          </categories>
          <specialFiltersToAllow>
            <li>AllowBuried</li>
          </specialFiltersToAllow>
  <specialFiltersToDisallow>
    <li>AllowCorpsesStranger</li>
  </specialFiltersToDisallow>
        </allowances>
      </defaultStorageSettings>
    </building>
    <inspectorTabs>
      <li>ITab_Storage</li>
    </inspectorTabs>
    <terrainAffordanceNeeded>Diggable</terrainAffordanceNeeded>
    <designationCategory>Misc</designationCategory>
    <itemSurface>true</itemSurface>
  </ThingDef>

  <ThingDef ParentName="BuildingBase">
    <defName>StrangerGrave</defName>
    <eType>BuildingInert</eType>
    <label>Grave for Strangers</label>
    <thingClass>Building_Grave</thingClass>
    <graphicPath>Things/Building/Misc/GraveEmpty</graphicPath>
    <graphicClass>Graphic_Single</graphicClass>
    <graphicOverdraw>true</graphicOverdraw>
    <constructEffect>ConstructDirt</constructEffect>
    <altitudeLayer>FloorEmplacement</altitudeLayer>
    <useStandardHealth>false</useStandardHealth>
    <description>Place the dead in graves to give them a decent final resting place. Preset for Strangers only</description>
    <size>(1,2)</size>
    <statBases>
      <WorkToMake>650</WorkToMake>
    </statBases>
    <passability>Standable</passability>
    <building>
      <fixedStorageSettings>
        <allowances>
          <categories>
            <li>Corpses</li>
          </categories>
        </allowances>
      </fixedStorageSettings>
      <defaultStorageSettings>
        <priority>Important</priority>
        <allowances>
          <categories>
            <li>CorpsesHumanoid</li>
          </categories>
          <specialFiltersToAllow>
            <li>AllowBuried</li>
          </specialFiltersToAllow>
  <specialFiltersToDisallow>
    <li>AllowCorpsesColonist</li>
  </specialFiltersToDisallow>
        </allowances>
      </defaultStorageSettings>
    </building>
    <inspectorTabs>
      <li>ITab_Storage</li>
    </inspectorTabs>
    <terrainAffordanceNeeded>Diggable</terrainAffordanceNeeded>
    <designationCategory>Misc</designationCategory>
    <itemSurface>true</itemSurface>
  </ThingDef> 
</Buildings>



using System;
using System.Collections.Generic;
using RimWorld;
using Verse;

namespace Graves
{
    class MapComponent_Graves : MapComponent
    {
        private int updateCounter = 0;
        private const int updateInterval = 500;

        public override void MapComponentOnGUI()
        {
            --this.updateCounter;
            if (this.updateCounter > 0)
                return;
            this.updateCounter = 500;
            List<Building> buildings = Find.ListerBuildings.allBuildingsColonist;

            foreach (Building current in buildings)
            {
                if (current.GetType() == typeof(Building_Grave) && current.def != ThingDefOf.Grave)
                {
                    current.def = ThingDefOf.Grave;
                }
            }
        }
    }
}