Ejemplo n.º 1
0
 public static T FailOnChangingTerrain <T>(this T f, TargetIndex index, List <WaterTerrainType> waterTerrainTypeList) where T : IJobEndable
 {
     f.AddEndCondition(() =>
     {
         Thing thing           = f.GetActor().jobs.curJob.GetTarget(index).Thing;
         TerrainDef terrainDef = thing.Map.terrainGrid.TerrainAt(thing.Position);
         if (!waterTerrainTypeList.Contains(terrainDef.GetWaterTerrainType()))
         {
             return(JobCondition.Incompletable);
         }
         return(JobCondition.Ongoing);
     });
     return(f);
 }
Ejemplo n.º 2
0
        public static Toil FinishDrinkTerrain(TargetIndex terrainVecIndex)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn       actor      = toil.actor;
                Need_Water need_water = actor.needs.water();

                float numWater = need_water.MaxLevel - need_water.CurLevel;

                TerrainDef       terrain          = actor.Map.terrainGrid.TerrainAt(actor.CurJob.GetTarget(terrainVecIndex).Cell);
                WaterTerrainType drankTerrainType = terrain.GetWaterTerrainType();

                if (actor.needs.mood != null)
                {
                    // 直接飲んだ
                    if (actor.CanManipulate())
                    {
                        actor.needs.mood.thoughts.memories.TryGainMemory(MizuDef.Thought_DrankScoopedWater);
                    }
                    else
                    {
                        actor.needs.mood.thoughts.memories.TryGainMemory(MizuDef.Thought_SippedWaterLikeBeast);
                    }

                    ThoughtDef thoughtDef = MizuUtility.GetThoughtDefFromTerrainType(drankTerrainType);
                    if (thoughtDef != null)
                    {
                        // 水の種類による心情
                        actor.needs.mood.thoughts.memories.TryGainMemory(thoughtDef);
                    }
                }

                if (drankTerrainType == WaterTerrainType.SeaWater)
                {
                    // 海水の場合の健康状態悪化
                    actor.health.AddHediff(HediffMaker.MakeHediff(MizuDef.Hediff_DrankSeaWater, actor));
                }

                if (!actor.Dead)
                {
                    actor.needs.water().CurLevel += numWater;
                }
                actor.records.AddTo(MizuDef.Record_WaterDrank, numWater);
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
        protected override Thing FinishAction()
        {
            // 現在の地形から水の種類を決定
            TerrainDef terrainDef       = this.Map.terrainGrid.TerrainAt(this.job.GetTarget(BillGiverInd).Thing.Position);
            var        waterTerrainType = terrainDef.GetWaterTerrainType();
            var        waterThingDef    = MizuUtility.GetWaterThingDefFromTerrainType(waterTerrainType);

            if (waterThingDef == null)
            {
                return(null);
            }

            // 水を生成
            var createThing = ThingMaker.MakeThing(waterThingDef);

            if (createThing == null)
            {
                return(null);
            }

            // 個数設定
            createThing.stackCount = this.Ext.getItemCount;
            return(createThing);
        }