Exemplo n.º 1
0
        public static void ThrowSmoke(Vector3 loc, float size, Map map, string DefName)
        {
            if (!loc.ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }

            //Rand.PushState();
            //MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Smoke, 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));
            //Rand.PopState();
            //GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish);

            Rand.PushState();
            FleckCreationData dataStatic = FleckMaker.GetDataStatic(loc, map, FleckDefOf.Smoke, Rand.Range(1.5f, 2.5f) * size);

            dataStatic.rotationRate  = Rand.Range(-30f, 30f);
            dataStatic.velocityAngle = (float)Rand.Range(30, 40);
            dataStatic.velocitySpeed = Rand.Range(0.5f, 0.7f);

            Rand.PopState();
            map.flecks.CreateFleck(dataStatic);
        }
Exemplo n.º 2
0
        static bool Prefix(ref FleckCreationData fleckData)
        {
            if (fleckData.def == FleckDefOf.FeedbackGoto)
            {
                return(true);
            }

            return(!CancelFeedbackNotTargetedAtMe.Cancel);
        }
Exemplo n.º 3
0
        public static void PlaceFootprint(Vector3 loc, Map map, float rot)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, FleckDefOf.Footprint, 0.5f);
                data.rotation = rot;
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 4
0
        public static void ConnectingLine(Vector3 start, Vector3 end, FleckDef fleckDef, Map map, float width = 1f)
        {
            Vector3           positionDiff = end - start;
            float             dist         = positionDiff.MagnitudeHorizontal();
            Vector3           halfway      = start + positionDiff * 0.5f;
            FleckCreationData data         = AdeptusFleckMaker.GetDataStatic(halfway, map, fleckDef, 1f);

            data.exactScale = new Vector3?(new Vector3(dist, 1f, width));
            data.rotation   = Mathf.Atan2(-positionDiff.z, positionDiff.x) * 57.29578f;
            map.flecks.CreateFleck(data);
        }
Exemplo n.º 5
0
        public static void ThrowExplosionInterior(Vector3 loc, Map map, FleckDef fleckDef)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, fleckDef, Rand.Range(3f, 4.5f));
                data.rotationRate  = Rand.Range(-30f, 30f);
                data.velocityAngle = (float)Rand.Range(0, 360);
                data.velocitySpeed = Rand.Range(0.48f, 0.72f);
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 6
0
        public static void ThrowDustPuffThick(Vector3 loc, Map map, float scale, Color color)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, FleckDefOf.DustPuffThick, scale);
                data.rotationRate  = (float)Rand.Range(-60, 60);
                data.velocityAngle = (float)Rand.Range(0, 360);
                data.velocitySpeed = Rand.Range(0.6f, 0.75f);
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 7
0
        public static void ThrowAirPuffUp(Vector3 loc, Map map)
        {
            bool flag = !loc.ToIntVec3().ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc + new Vector3(Rand.Range(-0.02f, 0.02f), 0f, Rand.Range(-0.02f, 0.02f)), map, FleckDefOf.AirPuff, 1.5f);
                data.rotationRate  = (float)Rand.RangeInclusive(-240, 240);
                data.velocityAngle = (float)Rand.Range(-45, 45);
                data.velocitySpeed = Rand.Range(1.2f, 1.5f);
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 8
0
        public static void ThrowMetaPuff(Vector3 loc, Map map)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, FleckDefOf.MetaPuff, 1.9f);
                data.rotationRate  = (float)Rand.Range(-60, 60);
                data.velocityAngle = (float)Rand.Range(0, 360);
                data.velocitySpeed = Rand.Range(0.6f, 0.78f);
                map.flecks.CreateFleck(data);
            }
        }
 public void ThrowFleck(Vector3 loc, Map map, float throwAngle, Vector3 inheritVelocity)
 {
     if (loc.ToIntVec3().ShouldSpawnMotesAt(map))
     {
         FleckCreationData dataStatic = FleckMaker.GetDataStatic(loc + new Vector3(Rand.Range(-0.005f, 0.005f), 0f, Rand.Range(-0.005f, 0.005f)), map, Props.fleckDefOnPawn, Rand.Range(0.6f, 0.7f));
         dataStatic.rotationRate  = Rand.RangeInclusive(-240, 240);
         dataStatic.velocityAngle = throwAngle + (float)Rand.Range(-10, 10);
         dataStatic.velocitySpeed = Rand.Range(0.1f, 0.8f);
         dataStatic.velocity      = inheritVelocity * 0.5f;
         dataStatic.instanceColor = Props.fleckColor;
         dataStatic.scale         = Props.fleckScale;
         map.flecks.CreateFleck(dataStatic);
     }
 }
Exemplo n.º 10
0
        public static void ThrowBreathPuff(Vector3 loc, Map map, float throwAngle, Vector3 inheritVelocity)
        {
            bool flag = !loc.ToIntVec3().ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc + new Vector3(Rand.Range(-0.005f, 0.005f), 0f, Rand.Range(-0.005f, 0.005f)), map, FleckDefOf.AirPuff, Rand.Range(0.6f, 0.7f));
                data.rotationRate  = (float)Rand.RangeInclusive(-240, 240);
                data.velocityAngle = throwAngle + (float)Rand.Range(-10, 10);
                data.velocitySpeed = Rand.Range(0.1f, 0.8f);
                data.velocity      = new Vector3?(inheritVelocity * 0.5f);
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 11
0
        public static void ThrowMicroSparks(Vector3 loc, Map map)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                loc -= new Vector3(0.5f, 0f, 0.5f);
                loc += new Vector3(Rand.Value, 0f, Rand.Value);
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, FleckDefOf.MicroSparks, Rand.Range(0.8f, 1.2f));
                data.rotationRate  = Rand.Range(-12f, 12f);
                data.velocityAngle = (float)Rand.Range(35, 45);
                data.velocitySpeed = 1.2f;
                map.flecks.CreateFleck(data);
            }
        }
 private static void ThrowObjectAt(Pawn thrower, IntVec3 targetCell, FleckDef fleck)
 {
     if (thrower.Position.ShouldSpawnMotesAt(thrower.Map))
     {
         float   num    = Rand.Range(9.8f, 15.6f);
         Vector3 vector = targetCell.ToVector3Shifted() + Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(SkillDefOf.Shooting).Level / 20f) * 1.8f);
         vector.y = thrower.DrawPos.y;
         FleckCreationData dataStatic = FleckMaker.GetDataStatic(thrower.DrawPos, thrower.Map, fleck);
         dataStatic.rotationRate  = 0;
         dataStatic.rotation      = thrower.Rotation.AsAngle;
         dataStatic.velocityAngle = (vector - dataStatic.spawnPosition).AngleFlat();
         dataStatic.velocitySpeed = num;
         dataStatic.airTimeLeft   = Mathf.RoundToInt((dataStatic.spawnPosition - vector).MagnitudeHorizontal() / num);
         thrower.Map.flecks.CreateFleck(dataStatic);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Attempts to get the weapon from the equipper of the weapon that launched the projectile
        /// </summary>
        /// <param name="launcher">The equipper of the weapon that launched the projectile</param>
        /// <returns>Weapon if one is found, null if not</returns>

        /*
         * Fundamentally broken - will null ref if launcher pawn drops equipment in-between firing the projectile and it impacting -NIA
         * public static Thing GetWeaponFromLauncher(Thing launcher)
         * {
         *  if (launcher is Pawn pawn)
         *      return pawn.equipment?.Primary;
         *  if (launcher is Building_TurretGunCE turretCE)
         *      return turretCE.Gun;
         *  return null;
         * }
         */

        #endregion Misc

        #region MoteThrower
        public static void ThrowEmptyCasing(Vector3 loc, Map map, FleckDef casingFleckDef, float size = 1f)
        {
            if (!Controller.settings.ShowCasings || !loc.ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }
            FleckCreationData creationData = FleckMaker.GetDataStatic(loc, map, casingFleckDef);

            creationData.airTimeLeft   = 60;
            creationData.scale         = Rand.Range(0.5f, 0.3f) * size;
            creationData.rotation      = Rand.Range(-3f, 4f);
            creationData.spawnPosition = loc;
            creationData.velocitySpeed = (float)Rand.Range(0.7f, 0.5f);
            creationData.velocityAngle = (float)Rand.Range(160, 200);
            map.flecks.CreateFleck(creationData);
        }
Exemplo n.º 14
0
        // edited
        public static void ThrowExplosionCell(IntVec3 cell, Map map, FleckDef fleckDef, Color color, Color?dustColor = null)
        {
            bool flag = !cell.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(cell.ToVector3Shifted(), map, fleckDef, 1f);
                data.rotation      = (float)(90 * Rand.RangeInclusive(0, 3));
                data.instanceColor = new Color?(color);
                map.flecks.CreateFleck(data);
                bool flag2 = Rand.Value < 0.7f;
                if (flag2)
                {
                    AdeptusFleckMaker.ThrowDustPuff(cell, map, 1.2f, null, dustColor);
                }
            }
        }
Exemplo n.º 15
0
        public static void ThrowLightningBolt(Vector3 loc, Map map, float size, Color?color = null)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc + size * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f), map, FleckDefOf.LightningGlow, Rand.Range(4f, 6f) * size);
                data.rotationRate  = Rand.Range(-3f, 3f);
                data.velocityAngle = (float)Rand.Range(0, 360);
                data.velocitySpeed = 1.2f;
                if (color.HasValue)
                {
                    data.instanceColor = color.Value;
                }
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 16
0
        private static void ThrowObjectAt(Pawn thrower, IntVec3 targetCell, FleckDef fleck)
        {
            bool flag = !thrower.Position.ShouldSpawnMotesAt(thrower.Map);

            if (!flag)
            {
                float   speed       = Rand.Range(3.8f, 5.6f);
                Vector3 exactTarget = targetCell.ToVector3Shifted() + Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(SkillDefOf.Shooting).Level / 20f) * 1.8f);
                exactTarget.y = thrower.DrawPos.y;
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(thrower.DrawPos, thrower.Map, fleck, 1f);
                data.rotationRate  = (float)Rand.Range(-300, 300);
                data.velocityAngle = (exactTarget - data.spawnPosition).AngleFlat();
                data.velocitySpeed = speed;
                data.airTimeLeft   = new float?((float)Mathf.RoundToInt((data.spawnPosition - exactTarget).MagnitudeHorizontal() / speed));
                thrower.Map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 17
0
        public static void ThrowGenericFleck(FleckDef fleckDef, Vector3 loc, Map map, float scale, float solidTime, float fadeIn, float fadeOut, int rotationRate, float velocity, float velocityAngle, float lookAngle)
        {
            if (!loc.ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }            

            FleckCreationData dataStatic = default(FleckCreationData);
            dataStatic.def = fleckDef;
            dataStatic.scale = scale;            
            dataStatic.spawnPosition = loc;
            dataStatic.rotationRate = rotationRate;
            dataStatic.velocityAngle = velocityAngle;
            dataStatic.velocitySpeed = velocity;
            dataStatic.solidTimeOverride = solidTime;
            dataStatic.rotation = lookAngle;
            map.flecks.CreateFleck(dataStatic);
        }
Exemplo n.º 18
0
        // edited AdeptusFleckMaker.ThrowDustPuff
        public static void ThrowDustPuff(Vector3 loc, Map map, float scale, FleckDef def = null, Color?color = null)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, def ?? FleckDefOf.DustPuff, 1.9f * scale);
                data.rotationRate  = (float)Rand.Range(-60, 60);
                data.velocityAngle = (float)Rand.Range(0, 360);
                data.velocitySpeed = Rand.Range(0.6f, 0.75f);
                if (color.HasValue)
                {
                    data.instanceColor = color.Value;
                    //    moteThrown.instanceColor = new Color(0.368f, 0f, 1f);
                }
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 19
0
        public void ThrowFleck(float angle, float rotationRate, float speed, FleckDef fleckDef, float size)
        {
            FleckCreationData dataStatic = FleckMaker.GetDataStatic(cachedParticleOffset, cachedMap, fleckDef, size);

            dataStatic.rotationRate  = rotationRate;
            dataStatic.velocityAngle = angle;
            dataStatic.velocitySpeed = (fastRandom.Next(1, 20) / 100f) + speed;

            if (fleckSystemCache != null)
            {
                dataStatic.spawnPosition.y = cachedAltitude;
                fleckSystemCache.CreateFleck(dataStatic);
            }
            else
            {
                cachedMap.flecks.CreateFleck(dataStatic);
            }
        }
Exemplo n.º 20
0
        public static void ThrowFireGlow(Vector3 c, Map map, float size)
        {
            bool flag = !c.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                Vector3 loc   = c + size * new Vector3(Rand.Value - 0.5f, 0f, Rand.Value - 0.5f);
                bool    flag2 = !loc.InBounds(map);
                if (!flag2)
                {
                    FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, FleckDefOf.FireGlow, Rand.Range(4f, 6f) * size);
                    data.rotationRate  = Rand.Range(-3f, 3f);
                    data.velocityAngle = (float)Rand.Range(0, 360);
                    data.velocitySpeed = 0.12f;
                    map.flecks.CreateFleck(data);
                }
            }
        }
Exemplo n.º 21
0
        public static bool CreateFleck(FleckSystemBase <FleckThrown> __instance, FleckCreationData creationData)
        {
            FleckThrown fleck = new FleckThrown();

            fleck.Setup(creationData);
            if (creationData.def.realTime)
            {
                lock (__instance.dataGametime)
                {
                    __instance.dataRealtime.Add(fleck);
                }
            }
            else
            {
                lock (__instance.dataGametime)
                {
                    __instance.dataGametime.Add(fleck);
                }
            }
            return(false);
        }
Exemplo n.º 22
0
        public override IEnumerable <PreCastAction> GetPreCastActions()
        {
            if (Props.type == DeepStrikeType.Teleport)
            {
                yield return(new PreCastAction
                {
                    action = delegate(LocalTargetInfo t, LocalTargetInfo d)
                    {
                        if (!this.parent.def.HasAreaOfEffect)
                        {
                            Pawn pawn = t.Pawn;
                            if (pawn != null)
                            {
                                FleckCreationData creationData = FleckMaker.GetDataAttachedOverlay(pawn, FleckDefOf.PsycastSkipFlashEntry, Vector3.zero, 1f, -1f);
                                creationData.link.detachAfterTicks = 5;
                                pawn.Map.flecks.CreateFleck(creationData);
                            }
                            else
                            {
                                FleckMaker.Static(t.CenterVector3, this.parent.pawn.Map, FleckDefOf.PsycastSkipFlashEntry, 1f);
                            }
                            FleckMaker.Static(d.Cell, this.parent.pawn.Map, FleckDefOf.PsycastSkipInnerExit, 1f);
                        }
                        if (this.Props.destination != AbilityEffectDestination.RandomInRange)
                        {
                            FleckMaker.Static(d.Cell, this.parent.pawn.Map, FleckDefOf.PsycastSkipOuterRingExit, 1f);
                        }
                        if (!this.parent.def.HasAreaOfEffect)
                        {
                            SoundDefOf.Psycast_Skip_Entry.PlayOneShot(new TargetInfo(t.Cell, this.parent.pawn.Map, false));
                            SoundDefOf.Psycast_Skip_Exit.PlayOneShot(new TargetInfo(d.Cell, this.parent.pawn.Map, false));
                        }
                    },
                    ticksAwayFromCast = 5
                });
            }

            yield break;
        }
Exemplo n.º 23
0
        // edited
        public static void ThrowSmoke(Vector3 loc, float size, Map map, FleckDef def = null, Color?color = null, float?exactRotation = null)
        {
            bool flag = !loc.ShouldSpawnMotesAt(map);

            if (!flag)
            {
                FleckCreationData data = AdeptusFleckMaker.GetDataStatic(loc, map, def ?? FleckDefOf.Smoke, Rand.Range(1.5f, 2.5f) * size);
                data.rotationRate  = Rand.Range(-30f, 30f);
                data.velocityAngle = (float)Rand.Range(30, 40);
                data.spawnPosition = loc;
                data.velocitySpeed = Rand.Range(0.5f, 0.7f);
                if (color.HasValue)
                {
                    data.instanceColor = color.Value;
                    //    moteThrown.instanceColor = new Color(0.368f, 0f, 1f);
                }
                if (exactRotation.HasValue)
                {
                    data.rotation += exactRotation.Value;
                }
                map.flecks.CreateFleck(data);
            }
        }
Exemplo n.º 24
0
        public override void Tick()
        {
            base.Tick();

            timer++;
            if (timer % 60 == 0)
            {
                isBlocked = false;
                blockedBy = null;
                foreach (var cell in GetLaunchCells())
                {
                    if (IsCellBlocked(cell, out blockedBy))
                    {
                        isBlocked = true;
                        break;
                    }
                }
            }

            var comp = GetComp <CompRefuelable>();

            comp.Props.fuelLabel      = CurrentShellDef.LabelCap;
            comp.Props.fuelGizmoLabel = CurrentShellDef.LabelCap;

            if (isFlying)
            {
                bool spawnSmoke = false;
                bool spawnFire  = false;
                ticksFlying++;
                if (ticksFlying <= TicksToLeave)
                {
                    Vector3 start = GetDroneIdlePos();
                    Vector3 end   = GetDroneIdlePos() + GetDroneTravelDirection() * 350;
                    float   p     = Mathf.Clamp01((float)ticksFlying / TicksToLeave);
                    float   t     = launchCurve.Evaluate(p);
                    droneDrawPos = Vector3.Lerp(start, end, t);
                    spawnSmoke   = true;
                    spawnFire    = true;
                }
                else if (ticksFlying >= TicksToLeave + TicksInMiddle)
                {
                    if (ticksFlying > TicksToLeave + TicksInMiddle + TicksToReturn)
                    {
                        isFlying = false;
                    }
                    else
                    {
                        Vector3 start = GetDroneIdlePos() + GetDroneReturnDirection() * 350;
                        Vector3 end   = GetDroneIdlePos();
                        float   p     = Mathf.Clamp01((float)(ticksFlying - TicksToLeave - TicksInMiddle) / TicksToReturn);
                        float   t     = launchCurve.Evaluate(p);
                        droneDrawPos = Vector3.Lerp(start, end, t);
                        spawnSmoke   = true;
                    }
                }

                Map map = Map;
                if (spawnFire)
                {
                    Vector3 pos2 = droneDrawPos + Rand.InsideUnitCircleVec3 * 0.5f;
                    if (pos2.ToIntVec3().InBounds(map))
                    {
#if V13
                        FleckMaker.ThrowFireGlow(pos2, map, 1f);
#else
                        MoteThrown moteThrown2 = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_FireGlow);
                        moteThrown2.Scale         = Rand.Range(4f, 6f) * 1f;
                        moteThrown2.rotationRate  = Rand.Range(-3f, 3f);
                        moteThrown2.exactPosition = pos2;
                        moteThrown2.SetVelocity(Rand.Range(0, 360), 0.12f);
                        GenSpawn.Spawn(moteThrown2, pos2.ToIntVec3(), map);
#endif
                    }
                }
                if (spawnSmoke)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Vector3 pos = droneDrawPos + Rand.InsideUnitCircleVec3 * 2f;
                        if (pos.ToIntVec3().InBounds(map))
                        {
#if V13
                            FleckCreationData dataStatic = FleckMaker.GetDataStatic(pos, map, FleckDefOf.Smoke, Rand.Range(1.5f, 2.5f) * 1f);
                            dataStatic.spawnPosition = pos;
                            dataStatic.rotationRate  = Rand.Range(-30f, 30f);
                            dataStatic.velocityAngle = (float)Rand.Range(30, 40);
                            dataStatic.velocitySpeed = Rand.Range(0.5f, 0.7f);
                            map.flecks.CreateFleck(dataStatic);
#else
                            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Smoke);
                            moteThrown.Scale         = Rand.Range(1.5f, 2.5f) * 1f;
                            moteThrown.rotationRate  = Rand.Range(-30f, 30f);
                            moteThrown.exactPosition = pos;
                            moteThrown.SetVelocity(Rand.Range(30, 40), Rand.Range(0.5f, 0.7f));
                            GenSpawn.Spawn(moteThrown, pos.ToIntVec3(), map);
#endif
                        }
                    }
                }
            }
            else
            {
                droneDrawPos = GetDroneIdlePos();
            }
        }