Exemplo n.º 1
0
 public void TryChangeGraphics()
 {
     if (Props.growthStages != null)
     {
         var stage = GetCurrentStage();
         if (stage != null && stage != curStage)
         {
             ChangeGraphics(stage);
             curStage = stage;
         }
     }
 }
Exemplo n.º 2
0
        public void ChangeGraphics(GrowthStage growthStage)
        {
            Log.Message("Changed graphics: " + growthStage.graphicPath);
            Log.Message("Result: " + growthStage.massStage + " - innerMass: " + innerMass + " - Props.totalAbsorbableMass: " + Props.totalAbsorbableMass);

            var pawn = this.parent as Pawn;

            pawn.Drawer.renderer.graphics.ResolveAllGraphics();
            pawn.Drawer.renderer.graphics.nakedGraphic = GraphicDatabase.Get <Graphic_Multi>(growthStage.graphicPath, ShaderDatabase.CutoutSkin,
                                                                                             new Vector2(growthStage.drawSize, growthStage.drawSize), growthStage.color);
            if (growthStage.baseHungerRate > 0f)
            {
                ChangeHungerRate(growthStage);
            }
        }
Exemplo n.º 3
0
        public GrowthStage GetCurrentStage()
        {
            var         keys   = Props.growthStages.growthStages.OrderBy(x => x.massStage);
            GrowthStage result = null;

            foreach (var key in keys)
            {
                var progress = innerMass / Props.totalAbsorbableMass;
                if (key.massStage <= progress)
                {
                    result = key;
                }
            }
            return(result);
        }
Exemplo n.º 4
0
 public void ChangeHungerRate(GrowthStage growthStage)
 {
     //var hediffDef = new HediffDef()
     //{
     //	defName = "SlimeHungerRate" + this.parent.ThingID,
     //	label = "SlimeHungerRate" + this.parent.ThingID,
     //	stages = new List<HediffStage>
     //	{
     //		new HediffStage()
     //		{
     //			hungerRateFactor = growthStage.baseHungerRate
     //		}
     //	}
     //};
     //var pawn = this.parent as Pawn;
     //var hungerHediff = HediffMaker.MakeHediff(hediffDef, pawn);
     //var oldHediff = pawn.health.hediffSet.hediffs.Where(x => x.def.defName.StartsWith("SlimeHungerRate")).FirstOrDefault();
     //if (oldHediff != null)
     //{
     //	pawn.health.hediffSet.hediffs.Remove(oldHediff);
     //}
     //pawn.health.AddHediff(hungerHediff);
 }
Exemplo n.º 5
0
        public void LoadDataFromXmlCustom(XmlNode xmlRoot)
        {
            Log.Message("LoadDataFromXmlCustom: " + xmlRoot.ChildNodes.Count);
            growthStages = new List <GrowthStage>(new GrowthStage[xmlRoot.ChildNodes.Count]);
            var regex = new Regex("([0-9]+)$");

            foreach (XmlNode childNode in xmlRoot.ChildNodes)
            {
                if (!(childNode is XmlComment))
                {
                    var growthStage = new GrowthStage();
                    foreach (XmlNode childNode2 in childNode.ChildNodes)
                    {
                        if (!(childNode2 is XmlComment))
                        {
                            if (childNode2.Name == "massStage")
                            {
                                growthStage.massStage = float.Parse(childNode2.InnerText);
                            }
                            else if (childNode2.Name == "drawSize")
                            {
                                growthStage.drawSize = float.Parse(childNode2.InnerText);
                            }
                            else if (childNode2.Name == "color")
                            {
                                growthStage.color = ParseHelper.ParseColor(childNode2.InnerText);
                            }
                            else if (childNode2.Name == "graphicPath")
                            {
                                growthStage.graphicPath = childNode2.InnerText;
                            }
                            else if (childNode2.Name == "drawSize")
                            {
                                growthStage.drawSize = float.Parse(childNode2.InnerText);
                            }
                            else if (childNode2.Name == "massConversionEfficiency")
                            {
                                growthStage.massConversionEfficiency = float.Parse(childNode2.InnerText);
                            }
                            else if (childNode2.Name == "massConversionRate")
                            {
                                growthStage.massConversionRate = float.Parse(childNode2.InnerText);
                            }
                            else if (childNode2.Name == "baseHungerRate")
                            {
                                growthStage.baseHungerRate = float.Parse(childNode2.InnerText);
                            }
                        }
                    }
                    var index = int.Parse(regex.Match(childNode.Name).Groups[1].Value) - 1;
                    growthStages[index] = growthStage;
                    Log.Message("index: " + index + " - " + growthStages[index]?.graphicPath);
                }
            }

            for (var ind = 0; ind < growthStages.Count; ind++)
            {
                Log.Message("1: " + ind + " - " + growthStages[ind].massStage);
            }
            Log.Message("END");
        }
Exemplo n.º 6
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     curStage = GetCurrentStage();
 }