示例#1
0
    //Spread randomly to one Thing in this or an adjacent square
    protected void ThrowSpark()
    {
        IntVec3 targLoc = Position;

        if (Random.value < 0.8f)
        {
            targLoc = Position + GenRadial.ManualRadialPattern[Random.Range(1, 8 + 1)];                 //Spark adjacent
        }
        else
        {
            targLoc = Position + GenRadial.ManualRadialPattern[Random.Range(10, 20 + 1)];               //Spark distant
        }
        Spark sp = (Spark)GenSpawn.Spawn(ThingDef.Named("Spark"), Position);

        sp.Launch(this, new TargetPack(targLoc));
    }
示例#2
0
        protected void TrySpread()
        {
            IntVec3 intVec = base.Position;
            bool    flag;

            Rand.PushState();
            if (Rand.Chance(0.8f))
            {
                intVec = base.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(1, 8)];
                flag   = true;
            }
            else
            {
                intVec = base.Position + GenRadial.ManualRadialPattern[Rand.RangeInclusive(10, 20)];
                flag   = false;
            }
            Rand.PopState();
            if (!intVec.InBounds(base.Map))
            {
                return;
            }
            Rand.PushState();
            if (Rand.Chance(FireUtility.ChanceToStartFireIn(intVec, base.Map)))
            {
                if (!flag)
                {
                    CellRect startRect = CellRect.SingleCell(base.Position);
                    CellRect endRect   = CellRect.SingleCell(intVec);
                    if (!GenSight.LineOfSight(base.Position, intVec, base.Map, startRect, endRect, null))
                    {
                        return;
                    }
                    Spark spark = (Spark)GenSpawn.Spawn(ThingDefOf.Spark, base.Position, base.Map, WipeMode.Vanish);
                    spark.Launch(this, intVec, intVec, ProjectileHitFlags.All, null);
                }
                else
                {
                    FireUtility.TryStartFireIn(intVec, base.Map, 0.1f);
                }
            }
            Rand.PopState();
        }