Пример #1
0
        private static void Strategy()
        {
            var me = new Myself();

            me.ChangeStrategy(new RainWearingStrategy());
            me.GoOutside();
            var myFriend = new Myself();

            myFriend.ChangeStrategy(new SunshineWearingStrategy());
            myFriend.GoOutside();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var me = new Myself(new DefaultWearingStrategy());

            me.GoOutside();

            me.ChangeStrategy(new RainWearingStrategy());
            me.GoOutside();

            me.ChangeStrategy(new SunshineWearingStrategy());
            me.GoOutside();
        }
        static PossessionCategory EnsureCategory(Myself myself, string category)
        {
            var c = myself.possessions.FirstOrDefault(p => p.name == category);

            if (c == null)
            {
                var list = myself.possessions.ToList();
                c = new PossessionCategory
                {
                    appearance  = "Default",
                    name        = category,
                    categories  = new[] { category },
                    possessions = new Possession[0]
                };
                list.Add(c);
                myself.possessions = list.ToArray();
            }
            return(c);
        }
        public static void SetPossession(this Myself myself, string category, string item, int amount)
        {
            var cat = EnsureCategory(myself, category);

            var pos = cat.possessions.FirstOrDefault(p => p.name == item);

            if (pos == null)
            {
                pos = new Possession
                {
                    name           = item,
                    level          = amount,
                    category       = category,
                    effectiveLevel = amount
                };
                var list = cat.possessions.ToList();
                list.Add(pos);
                cat.possessions = list.ToArray();
            }
            pos.level = pos.effectiveLevel = amount;
        }
Пример #5
0
 public Job TryMakeBipodJob()
 {
     return(new Job(Myself.TryGetComp <Biped2>().yalla, Myself));
 }
Пример #6
0
        protected override bool TryCastShot()
        {
            if (yes != 1)
            {
                NeededFloat = this.VerbPropsCE.warmupTime;
                yes         = 1;
            }
            if (Myself.TryGetComp <Biped2>() != null)
            {
                if (Myself.TryGetComp <Biped2>().BipodSetUp)
                {
                    Log.Error(NeededFloat.ToString());
                    this.VerbPropsCE.warmupTime = NeededFloat / 2;
                    Log.Error(this.VerbPropsCE.warmupTime.ToString());
                }
                else
                {
                    this.VerbPropsCE.warmupTime = NeededFloat;
                    Log.Error(this.VerbPropsCE.warmupTime.ToString());
                }
            }
            else
            {
                Log.Error("missing comp");
            }
            bool flag = base.CompAmmo != null;

            if (flag)
            {
                bool flag2 = !base.CompAmmo.TryReduceAmmoCount(base.VerbPropsCE.ammoConsumedPerShotCount);
                if (flag2)
                {
                    return(false);
                }
            }
            bool flag3 = base.TryCastShot();
            bool result;

            if (flag3)
            {
                bool flag4 = base.ShooterPawn != null;
                if (flag4)
                {
                    base.ShooterPawn.records.Increment(RecordDefOf.ShotsFired);
                }
                bool flag5 = base.VerbPropsCE.ejectsCasings && base.projectilePropsCE.dropsCasings;

                bool flag6 = base.CompAmmo != null && !base.CompAmmo.HasMagazine && base.CompAmmo.UseAmmo;
                if (flag6)
                {
                    bool flag7 = !base.CompAmmo.Notify_ShotFired();
                    if (flag7)
                    {
                        bool flag8 = base.VerbPropsCE.muzzleFlashScale > 0.01f;
                        if (flag8)
                        {
                            MoteMaker.MakeStaticMote(this.caster.Position, this.caster.Map, ThingDefOf.Mote_ShotFlash, base.VerbPropsCE.muzzleFlashScale);
                        }
                        bool flag9 = base.VerbPropsCE.soundCast != null;
                        if (flag9)
                        {
                            base.VerbPropsCE.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false));
                        }
                        bool flag10 = base.VerbPropsCE.soundCastTail != null;
                        if (flag10)
                        {
                            base.VerbPropsCE.soundCastTail.PlayOneShotOnCamera(null);
                        }
                        bool flag11 = base.ShooterPawn != null;
                        if (flag11)
                        {
                            bool flag12 = base.ShooterPawn.thinker != null;
                            if (flag12)
                            {
                                base.ShooterPawn.mindState.lastEngageTargetTick = Find.TickManager.TicksGame;
                            }
                        }
                    }
                    result = base.CompAmmo.Notify_PostShotFired();
                }
                else
                {
                    result = true;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
Пример #7
0
        public override void VerbTickCE()
        {
            //if (CasterPawn != null)
            //{
            //List<IntVec3> cheese = CasterPawn.CellsAdjacent8WayAndInside().ToList();
            //if (cheese != null)
            //{
            //if (this.CasterPawn.jobs.posture != PawnPosture.Standing)
            //{
            //this.CasterPawn.jobs.posture = PawnPosture.Standing;
            //}
            //foreach (IntVec3 element in cheese)
            //{
            //if (element != null)
            //{

            //if (Verse.GridsUtility.GetCover(element, CasterPawn.Map) != null)
            //{
            //Building ting = Verse.GridsUtility.GetCover(element, CasterPawn.Map) as Building;
            //float flat = ting.def.fillPercent;
            //if (this.CasterPawn.jobs.posture != PawnPosture.Standing)
            //{
            //this.CasterPawn.jobs.posture = PawnPosture.Standing;
            //}

            //Log.Error(Verse.GridsUtility.GetCover(element, CasterPawn.Map).ToString());

            //}
            //else
            //{
            //if (!CasterPawn.pather.MovingNow)
            //{
            //if (BipodComp.BipodSetUp)
            //{

            //this.CasterPawn.jobs.posture = PawnPosture.LayingOnGroundNormal;



            //}


            //}

            //}

            //}

            //}
            //}
            //else
            //{
            //Log.Error("cheesent");
            //}

            //}


            //CasterPawn.cell
            if (BipodComp.Props.Recoilchange == this.VerbPropsCE.recoilAmount)
            {
                Log.Error(this.VerbPropsCE.recoilAmount.ToString());
            }
            if (CasterPawn != null)
            {
                if (BipodComp.BipodSetUp)
                {
                    this.VerbPropsCE.recoilAmount = BipodComp.Props.Recoilchange;
                }
                else
                {
                    this.VerbPropsCE.recoilAmount = BipodComp.InitRecoil;
                }
            }
            if (!Myself.TryGetComp <Biped2>().shoe)
            {
                if (Myself.ParentHolder != Myself.Map)
                {
                    if (CasterPawn != null)
                    {
                        if (daPawn != null)
                        {
                            if (daPawn.pather.Moving)
                            {
                                Myself.TryGetComp <Biped2>().BipodSetUp = false;
                            }

                            if (daPawn.Drafted)
                            {
                                if (Myself.TryGetComp <Biped2>().ShouldSetUpBipodGizmoBool)
                                {
                                    if (!daPawn.pather.Moving)
                                    {
                                        if (!daPawn.pather.MovingNow)
                                        {
                                            ThinkNode       jobGiver            = null;
                                            Pawn_JobTracker jobs                = this.CasterPawn.jobs;
                                            Job             job                 = this.TryMakeBipodJob();
                                            Job             newJob              = job;
                                            JobCondition    lastJobEndCondition = JobCondition.InterruptForced;
                                            Job             curJob              = this.CasterPawn.CurJob;
                                            if (jobs.curJob != job)
                                            {
                                                if (Myself.TryGetComp <Biped2>().BipodSetUp != true)
                                                {
                                                    jobs.StartJob(newJob, lastJobEndCondition, jobGiver, ((curJob != null) ? curJob.def : null) != job.def, true, null, null, false, false);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }



            bool isAiming = this._isAiming;

            if (isAiming)
            {
                bool flag = !this.ShouldAim;
                if (flag)
                {
                    this.WarmupComplete();
                }
                bool flag2;
                if (!(this.caster is Building_TurretGunCE))
                {
                    Pawn shooterPawn = base.ShooterPawn;
                    Type left;
                    if (shooterPawn == null)
                    {
                        left = null;
                    }
                    else
                    {
                        Pawn_StanceTracker stances = shooterPawn.stances;
                        if (stances == null)
                        {
                            left = null;
                        }
                        else
                        {
                            Stance curStance = stances.curStance;
                            left = ((curStance != null) ? curStance.GetType() : null);
                        }
                    }
                    flag2 = (left != typeof(Stance_Warmup));
                }
                else
                {
                    flag2 = false;
                }
                bool flag3 = flag2;
                if (flag3)
                {
                    this._isAiming = false;
                }
            }
        }
Пример #8
0
 public Job TryMakeBipodJobComp()
 {
     return(new Job(Myself.TryGetComp <Biped2>().yalla, pawnHolding));
 }
Пример #9
0
 public function run()
 {
     var me = new Myself();
     me.ChangeStrategy(new RainWearingStrategy());
     me.GoOutside();
 }