protected void MakeMote(TargetInfo A)
        {
            Vector3 vector = (A.HasThing ? A.Thing.DrawPos : A.Cell.ToVector3Shifted());

            if (!vector.ShouldSpawnMotesAt(A.Map))
            {
                return;
            }
            int randomInRange = def.burstCount.RandomInRange;

            for (int i = 0; i < randomInRange; i++)
            {
                Mote mote = (Mote)ThingMaker.MakeThing(def.moteDef);
                mote.Scale         = def.scale.RandomInRange;
                mote.exactPosition = vector + def.positionOffset + Gen.RandomHorizontalVector(def.positionRadius);
                mote.rotationRate  = def.rotationRate.RandomInRange;
                mote.exactRotation = def.rotation.RandomInRange;
                MoteThrown moteThrown = mote as MoteThrown;
                if (moteThrown != null)
                {
                    moteThrown.airTimeLeft = def.airTime.RandomInRange;
                    moteThrown.SetVelocity(def.angle.RandomInRange, def.speed.RandomInRange);
                }
                if (A.HasThing)
                {
                    mote.Attach(A);
                }
                GenSpawn.Spawn(mote, vector.ToIntVec3(), A.Map);
            }
        }
Example #2
0
        protected void MakeMote(TargetInfo A)
        {
            Vector3 vector = (!A.HasThing) ? A.Cell.ToVector3Shifted() : A.Thing.DrawPos;

            if (vector.ShouldSpawnMotesAt(A.Map))
            {
                int randomInRange = this.def.burstCount.RandomInRange;
                for (int i = 0; i < randomInRange; i++)
                {
                    Mote mote = (Mote)ThingMaker.MakeThing(this.def.moteDef, null);
                    mote.Scale         = this.def.scale.RandomInRange;
                    mote.exactPosition = vector + Gen.RandomHorizontalVector(this.def.positionRadius);
                    mote.rotationRate  = this.def.rotationRate.RandomInRange;
                    mote.exactRotation = this.def.rotation.RandomInRange;
                    MoteThrown moteThrown = mote as MoteThrown;
                    if (moteThrown != null)
                    {
                        moteThrown.airTimeLeft = this.def.airTime.RandomInRange;
                        moteThrown.SetVelocity(this.def.angle.RandomInRange, this.def.speed.RandomInRange);
                    }
                    if (A.HasThing)
                    {
                        mote.Attach(A);
                    }
                    GenSpawn.Spawn(mote, vector.ToIntVec3(), A.Map, WipeMode.Vanish);
                }
            }
        }
Example #3
0
        protected void MakeMote(TargetInfo A, TargetInfo B)
        {
            Vector3 vector = Vector3.zero;

            switch (def.spawnLocType)
            {
            case MoteSpawnLocType.OnSource:
                vector = A.CenterVector3;
                break;

            case MoteSpawnLocType.BetweenPositions:
            {
                Vector3 vector2 = (!A.HasThing) ? A.Cell.ToVector3Shifted() : A.Thing.DrawPos;
                Vector3 vector3 = (!B.HasThing) ? B.Cell.ToVector3Shifted() : B.Thing.DrawPos;
                vector = ((A.HasThing && !A.Thing.Spawned) ? vector3 : ((!B.HasThing || B.Thing.Spawned) ? (vector2 * def.positionLerpFactor + vector3 * (1f - def.positionLerpFactor)) : vector2));
                break;
            }

            case MoteSpawnLocType.RandomCellOnTarget:
                vector = ((!B.HasThing) ? CellRect.CenteredOn(B.Cell, 0) : B.Thing.OccupiedRect()).RandomCell.ToVector3Shifted();
                break;

            case MoteSpawnLocType.BetweenTouchingCells:
                vector = A.Cell.ToVector3Shifted() + (B.Cell - A.Cell).ToVector3().normalized * 0.5f;
                break;
            }
            if (parent != null)
            {
                Rand.PushState(parent.GetHashCode());
                if (A.CenterVector3 != B.CenterVector3)
                {
                    vector += (B.CenterVector3 - A.CenterVector3).normalized * parent.def.offsetTowardsTarget.RandomInRange;
                }
                vector += Gen.RandomHorizontalVector(parent.def.positionRadius);
                Rand.PopState();
            }
            Map   map = A.Map ?? B.Map;
            float num = (!def.absoluteAngle) ? (B.Cell - A.Cell).AngleFlat : 0f;

            if (map != null && vector.ShouldSpawnMotesAt(map))
            {
                int randomInRange = def.burstCount.RandomInRange;
                for (int i = 0; i < randomInRange; i++)
                {
                    Mote mote = (Mote)ThingMaker.MakeThing(def.moteDef);
                    GenSpawn.Spawn(mote, vector.ToIntVec3(), map);
                    mote.Scale         = def.scale.RandomInRange;
                    mote.exactPosition = vector + Gen.RandomHorizontalVector(def.positionRadius);
                    mote.rotationRate  = def.rotationRate.RandomInRange;
                    mote.exactRotation = def.rotation.RandomInRange + num;
                    MoteThrown moteThrown = mote as MoteThrown;
                    if (moteThrown != null)
                    {
                        moteThrown.airTimeLeft = def.airTime.RandomInRange;
                        moteThrown.SetVelocity(def.angle.RandomInRange + num, def.speed.RandomInRange);
                    }
                }
            }
        }
Example #4
0
        // Token: 0x060026BE RID: 9918 RVA: 0x00126340 File Offset: 0x00124740
        public static void ThrowBoltSmoke(Vector3 loc, Map map, float size)
        {
            if (!loc.ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("OG_Mote_BoltTrailPuff"), null);

            moteThrown.Scale         = Rand.Range(1.5f, 2.5f) * size;
            moteThrown.rotationRate  = Rand.Range(-30f, 30f);
            moteThrown.exactPosition = loc;
            moteThrown.SetVelocity((float)Rand.Range(30, 40), Rand.Range(0.5f, 0.7f));
            GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish);
        }
        protected void MakeMote(TargetInfo A, TargetInfo B)
        {
            Vector3 vector = Vector3.zero;

            switch (base.def.spawnLocType)
            {
            case MoteSpawnLocType.OnSource:
                vector = A.Cell.ToVector3Shifted();
                break;

            case MoteSpawnLocType.BetweenPositions:
            {
                Vector3 vector2 = (!A.HasThing) ? A.Cell.ToVector3Shifted() : A.Thing.DrawPos;
                Vector3 vector3 = (!B.HasThing) ? B.Cell.ToVector3Shifted() : B.Thing.DrawPos;
                vector = ((!A.HasThing || A.Thing.Spawned) ? ((!B.HasThing || B.Thing.Spawned) ? (vector2 * base.def.positionLerpFactor + vector3 * (float)(1.0 - base.def.positionLerpFactor)) : vector2) : vector3);
                break;
            }

            case MoteSpawnLocType.RandomCellOnTarget:
                vector = ((!B.HasThing) ? CellRect.CenteredOn(B.Cell, 0) : B.Thing.OccupiedRect()).RandomCell.ToVector3Shifted();
                break;

            case MoteSpawnLocType.BetweenTouchingCells:
                vector = A.Cell.ToVector3Shifted() + (B.Cell - A.Cell).ToVector3().normalized * 0.5f;
                break;
            }
            Map map = A.Map ?? B.Map;

            if (map != null && vector.ShouldSpawnMotesAt(map))
            {
                int randomInRange = base.def.burstCount.RandomInRange;
                for (int i = 0; i < randomInRange; i++)
                {
                    Mote mote = (Mote)ThingMaker.MakeThing(base.def.moteDef, null);
                    GenSpawn.Spawn(mote, vector.ToIntVec3(), map);
                    mote.Scale         = base.def.scale.RandomInRange;
                    mote.exactPosition = vector + Gen.RandomHorizontalVector(base.def.positionRadius);
                    mote.rotationRate  = base.def.rotationRate.RandomInRange;
                    float num = (float)((!base.def.absoluteAngle) ? (B.Cell - A.Cell).AngleFlat : 0.0);
                    mote.exactRotation = base.def.rotation.RandomInRange + num;
                    MoteThrown moteThrown = mote as MoteThrown;
                    if (moteThrown != null)
                    {
                        moteThrown.airTimeLeft = base.def.airTime.RandomInRange;
                        moteThrown.SetVelocity(base.def.angle.RandomInRange + num, base.def.speed.RandomInRange);
                    }
                }
            }
        }
Example #6
0
        public override void Spawn(Map map, Vector3 origin)
        {
            for (int i = 0; i < moteCount; i++)
            {
                MoteThrown moteThrown = ThingMaker.MakeThing(mote, null) as MoteThrown;
                if (moteThrown == null)
                {
                    return;
                }

                float   angle = Rand.Range(0f, 360f);
                Vector3 dir   = new Vector3(1f, 0f, 0f).RotatedBy(angle);

                float magnitude   = Rand.Range(0f, 1f);
                float actualScale = scale.LerpThroughRange(magnitude);
                moteThrown.exactPosition = origin + dir * radius.LerpThroughRange(magnitude);
                moteThrown.exactRotation = angle + 90;
                moteThrown.exactScale    = new Vector3(actualScale, actualScale, actualScale);
                moteThrown.SetVelocity(angle + 90, magnitude * speed);
                GenSpawn.Spawn(moteThrown, origin.ToIntVec3(), map, WipeMode.Vanish);
                moteThrown.spawnTick -= (int)(magnitude * 0.75f * (mote.mote.fadeOutTime * 60));
            }
        }