private void StartChoosingDestination()
        {
            CameraJumper.TryJump(CameraJumper.GetWorldTarget(TargetA.ToGlobalTargetInfo(this.Map)));
            Find.WorldSelector.ClearSelection();
            int tile = this.pawn.Map.Tile;

            Find.WorldTargeter.BeginTargeting(new Func <GlobalTargetInfo, bool>(this.ChooseWorldTarget), true, JobDriver_PortalDestination.TargeterMouseAttachment, true, delegate
            {
                GenDraw.DrawWorldRadiusRing(tile, (int)this.portalBldg.MaxLaunchDistance);  //center, max launch distance
            }, delegate(GlobalTargetInfo target)
            {
                if (!target.IsValid)
                {
                    return(null);
                }
                int num = Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile);
                if (num <= portalBldg.MaxLaunchDistance) // <= max launch distance
                {
                    return(null);
                }
                if (num > portalBldg.MaxLaunchDistance) //this.MaxLaunchDistanceEverPossible
                {
                    return("TM_PortalDestinationInvalid".Translate());
                }
                return("TM_PortalDestinationInvalid".Translate());
            });
        }
 private static TargetA FillFrom(this TargetA target,
                                 Dictionary <string, string> dictionary)
 {
     // throw exception if required keys not found
     target.Foo = dictionary["foo"];
     return(target);
 }
        public override IEnumerable <Toil> MakeNewToils()
        {
            //have pawn, and  destination.
            //Check that pawn can reach  destination with Dijkstra.
            //yield break if not.
            //Otherwise, calculate toils to go, then toils to destination and return them one at a time.
            ZLogger.Message($"JobDriver GoToLocation About to call findRouteWithStairs, with pawn {pawn}, dest { TargetA.ToTargetInfo(pawn.Map)}, instance {this}");

            foreach (var v in Toils_ZLevels.FindRouteWithStairs(pawn, TargetA.ToTargetInfo(pawn.Map), this))
            {
                yield return(v);
            }
        }
Example #4
0
        public override IViolation <T> Check(T subject, IBehaviors context = null)
        {
            IViolation <T> va = TargetA.Check(subject, context);
            IViolation <T> vb = TargetB.Check(subject, context);

            if (va == NonViolation <T> .Instance &&
                vb == NonViolation <T> .Instance)
            {
                return(NonViolation <T> .Instance);
            }

            return(new Violation <T>(
                       this,
                       Reduce(
                           MakeValid( ),
                           subject)));
        }
Example #5
0
        public void TestCopyTo()
        {
            IServiceCollection sc = new ServiceCollection()
                                    .AddLightweightMapper();

            IServiceProvider sp       = sc.BuildServiceProvider();
            IMapperProvider  provider = sp.GetRequiredService <IMapperProvider>();

            SourceA a = new SourceA()
            {
                A = "A",
                B = "B",
                C = "C"
            };
            TargetA ta = new TargetA();

            provider.CopyTo <SourceA, TargetA>(a, ta);
            Assert.Equal("A", ta.A);
            Assert.Equal("B", ta.D);
            Assert.Equal("C", ta.E);
            Assert.Equal("A", ta.X1);
            Assert.Equal("C", ta.X2);
        }
Example #6
0
        public void TestCopyDefine()
        {
            IServiceCollection sc = new ServiceCollection()
                                    .AddLightweightMapper();

            IServiceProvider sp       = sc.BuildServiceProvider();
            IMapperProvider  provider = sp.GetRequiredService <IMapperProvider>();

            SourceA a = new SourceA()
            {
                A = "A",
                B = "B",
                C = "C"
            };
            TargetA ta       = new TargetA();
            var     copyFunc = provider.DefineCopyTo <SourceA, TargetA>();

            copyFunc(a, ta);
            Assert.Equal("A", ta.A);
            Assert.Equal("B", ta.D);
            Assert.Equal("C", ta.E);
            Assert.Equal("A", ta.X1);
            Assert.Equal("C", ta.X2);

            var copyFunc2 = provider.DefineCopyTo <SourceA, TargetA>(t => new
            {
                A = t.A
            });

            ta = new TargetA();
            copyFunc2(a, ta);
            Assert.Null(ta.A);
            Assert.Equal("B", ta.D);
            Assert.Equal("C", ta.E);
            Assert.Null(ta.X1);
            Assert.Equal("C", ta.X2);
        }
 public bool IsTargetingArea()
 {
     return(TargetA.IsArea() || TargetB.IsArea());
 }
Example #8
0
 public AdapterA(TargetA a)
 {
     this.A = a;
 }