Пример #1
0
        public static Thing MoteSpawner_ThrowObjectAt(this JobDriver_ThrowRocks JDTR)
        {
            IntVec3  targetCell = JDTR.TargetCell;
            Pawn     thrower    = JDTR.pawn;
            ThingDef moteDef    = JDTR.MoteDef;
            SkillDef skillDef   = JDTR.SkillDefScaling;

            if (!thrower.Position.ShouldSpawnMotesAt(thrower.Map) || thrower.Map.moteCounter.Saturated)
            {
                return(null);
            }

            float   randomSpeed     = JDTR.Speed.RandomInRange;
            Vector3 destinationCell =
                targetCell.ToVector3Shifted() +
                Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(skillDef).Level / 20f) * 1.8f);

            destinationCell.y = thrower.DrawPos.y;
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(moteDef);

            moteThrown.Scale         = 1f;
            moteThrown.rotationRate  = JDTR.Rotation.RandomInRange;
            moteThrown.exactPosition = thrower.DrawPos;
            moteThrown.SetVelocity((destinationCell - moteThrown.exactPosition).AngleFlat(), randomSpeed);

            moteThrown.airTimeLeft = Mathf.RoundToInt((moteThrown.exactPosition - destinationCell).MagnitudeHorizontal() / randomSpeed);

            return(GenSpawn.Spawn(moteThrown, thrower.Position, thrower.Map));
        }
Пример #2
0
        public static void Initialization(this ShadowMote SM, JobDriver_ThrowRocks JDTR, Vector3 DestinationCell)
        {
            SM.JDTR_parent = JDTR;

            SM.InitCoordinates(DestinationCell);
            //SM.InitGroundShadowGraphic();
        }
Пример #3
0
        public static Thing ShadowMoteSpawner_ThrowObjectAt(this JobDriver_ThrowRocks JDTR)
        {
            bool   MyDebug  = JDTR.gameSettings.debug;
            string debugStr = MyDebug ? JDTR.PawnLabel + "ShadowMoteSpawner_ThrowObjectAt - " : "";

            Pawn     thrower    = JDTR.pawn;
            IntVec3  targetCell = JDTR.TargetCell;
            SkillDef skillDef   = JDTR.SkillDefScaling;

            ThingDef moteDef = JDTR.MoteDef;

            if (!thrower.AllowedMoteSpawn())
            {
                return(null);
            }

            float   randomSpeed     = JDTR.Speed.RandomInRange;
            Vector3 destinationCell =
                targetCell.ToVector3Shifted() +
                Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(skillDef).Level / 20f) * 1.8f);

            destinationCell.y = thrower.DrawPos.y;
            if (moteDef == null)
            {
                Tools.Warn(debugStr + "found no moteDef", MyDebug);
                return(null);
            }

            ShadowMote moteThrown = (ShadowMote)ThingMaker.MakeThing(moteDef);

            //moteThrown.Initialization(thrower.DrawPos, destinationCell, PGTG.PetanqueSpotCell.ToVector3Shifted(), thrower);
            moteThrown.Initialization(JDTR, destinationCell);

            moteThrown.Scale         = 1f;
            moteThrown.rotationRate  = JDTR.Rotation.RandomInRange;
            moteThrown.exactPosition = thrower.DrawPos;
            moteThrown.SetVelocity((destinationCell - moteThrown.exactPosition).AngleFlat(), randomSpeed);

            moteThrown.airTimeLeft = Mathf.RoundToInt((moteThrown.exactPosition - destinationCell).MagnitudeHorizontal() / randomSpeed);

            return(GenSpawn.Spawn(moteThrown, thrower.Position, thrower.Map));
        }
Пример #4
0
        public static bool RetrieveProjectileParam(this JobDriver_ThrowRocks JDTR)
        {
            bool myDebug = JDTR.gameSettings.debug;

            string DebugStr = JDTR.pawn.LabelShort + " - RetrieveProjectileParam";

            Tools.Warn(DebugStr + " - Entering", myDebug);

            int randomIndex = JDTR.gameSettings.GetWeightedRandomIndex();

            JDTR.projectileOption = JDTR.gameSettings.projectileOptionList[randomIndex];

            if (JDTR.projectileOption.IsShadowMoteType)
            {
                JDTR.PickedMoteParam = JDTR.projectileOption.shadowMote;
                Tools.Warn(DebugStr + " - Found shadow mote", myDebug);
            }
            else
            {
                Tools.Warn(DebugStr + " - Found nothing", myDebug);
            }

            return(JDTR.HasProjectileOption);
        }
Пример #5
0
 public static void ResetPickedOption(this JobDriver_ThrowRocks JDTR)
 {
     JDTR.projectileOption = null;
     JDTR.PickedMoteParam  = null;
     JDTR.RetrieveProjectileParam();
 }