Where to store pawn custom information

Started by soulkata, February 15, 2015, 07:47:38 PM

Previous topic - Next topic

soulkata

Hi, I am making my first Dll mod, It will be a new enemy faction of Ants. Right now, I am working on a 'Ant Queen' unit, their have a special hability, in time to time, they will spawn a new 'Ant Warrior' to attack the colony!

I allready completed the task of creating a new Ant, my problem is: I need to store in some place the gametime of the last spawed ant (Handling Save and Load), to give some time until de next spawn action!

I allready read the post about save structure, but I cannot understand how to save custom mod information in these files!

mrofa

Store pawn in pawn like
private Pawn myPawn

Save pawn with
Scribe_References.LookReference<Pawn>(ref myPawn, "myPawn");
All i do is clutter all around.

soulkata

Thanks mrofa!

Your ansfer guide me to right direction, but, I still need some advice! The 'LookReference' method Persists only local information... For example, the 'JobDriver' is a 'Saveable', if I call 'LookReference' inside it, I will be getting information about the current Job, not about the previous, that is waht I need...

In my case, its a litle more complicated, since I need to do a custom 'ThinkNode_ConditionalFunc', that isnt even a 'Saveable'!

In short, what I need is: In a 'ThinkNode_ConditionalFunc' get how many Ticks passed since last sucess result, if is great than a constant, it will store the current game time and return true, otherwise, return false (Every ant queen shoud have his 'LastSucessSpawnTick')...

Haplo

You can make a MapComponent and code in its tick function your watching code.  :)

soulkata

#4
Thanks Haplo,

MapComponent really handles my needs! I had to create a Saveable object to handle the custom information anexed to the pawns... Below how my code began...


    public class AnthillMapComponent : MapComponent
    {
        public List<AntQueenTick> antQueenData = new List<AntQueenTick>();

        public override void ExposeData()
        {
            base.ExposeData();

            Scribe_Collections.LookList(ref this.antQueenData, "AntQueen", LookMode.Deep);
        }
    }

    public class AntQueenTick : Saveable
    {
        public int count;
        public int nextTick;
        public Pawn pawn;

        public void ExposeData()
        {
            Scribe_References.LookReference(ref this.pawn, "pawn");
            Scribe_Values.LookValue(ref this.count, "count");
            Scribe_Values.LookValue(ref this.nextTick, "nextTick");
        }
    }