Exemple #1
0
 public VehicleHandlerTemp(VehicleHandlerGroup originHandler)
 {
     uniqueID = Find.UniqueIDsManager.GetNextThingID();
     vehicle  = originHandler.vehicle;
     role     = originHandler.role;
     if (handlers == null)
     {
         handlers = new List <Pawn>(); // ThingOwner<Pawn>(this, false, LookMode.Reference);
     }
     if ((originHandler.handlers?.Count ?? 0) > 0)
     {
         foreach (var p in originHandler.handlers)
         {
             if (p.Spawned)
             {
                 p.DeSpawn();
             }
             if (p.holdingOwner != null)
             {
                 p.holdingOwner = null;
             }
             if (!p.IsWorldPawn())
             {
                 Find.WorldPawns.PassToWorld(p, PawnDiscardDecideMode.Decide);
             }
         }
     }
     handlers.AddRange(originHandler.handlers);
     //this.handlers = newHandlers;
 }
Exemple #2
0
 public VehicleRole(VehicleHandlerGroup group)
 {
     label             = group.role.label;
     labelPlural       = group.role.labelPlural;
     handlingTypes     = group.role.handlingTypes;
     slots             = group.role.slots;
     slotsToOperate    = group.role.slotsToOperate;
     slotTag           = group.role.slotTag;
     preferredHandlers = group.role.preferredHandlers;
 }
Exemple #3
0
 public VehicleRole(VehicleHandlerGroup group)
 {
     this.label             = group.role.label;
     this.labelPlural       = group.role.labelPlural;
     this.handlesMovement   = group.role.handlesMovement;
     this.handlesWeapons    = group.role.handlesWeapons;
     this.slots             = group.role.slots;
     this.slotsToOperate    = group.role.slotsToOperate;
     this.slotTag           = group.role.slotTag;
     this.preferredHandlers = group.role.preferredHandlers;
 }
Exemple #4
0
        public void GiveLoadJob(Thing thingToLoad, VehicleHandlerGroup group)
        {
            if (thingToLoad is Pawn pawn)
            {
                Job newJob = new Job(DefDatabase <JobDef> .GetNamed("CompVehicle_LoadPassenger"), this.Pawn);
                pawn.jobs.TryTakeOrderedJob(newJob);

                if (this.bills != null && this.bills.Count > 0)
                {
                    Bill_LoadVehicle bill = this.bills.FirstOrDefault((Bill_LoadVehicle x) => x.pawnToLoad == pawn);
                    if (bill != null)
                    {
                        bill.group = group;
                        return;
                    }
                }
                this.bills.Add(new Bill_LoadVehicle(pawn, this.Pawn, group));
            }
        }
Exemple #5
0
        public void GetVehicleButtonFloatMenu(VehicleHandlerGroup group, bool canLoad)
        {
            var list     = new List <FloatMenuOption>();
            var map      = Pawn.Map;
            var tempList = group?.handlers?.InnerListForReading != null
                ? new List <Pawn>(group.handlers.InnerListForReading)
                : new List <Pawn>();

            if (canLoad && tempList.Count == 0)
            {
                SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                //Additions by Swenzi 1/1/2018
                //Allow animals to ride in vehicles or pull vehicles (animals only allowed to be in slots that allow movement)
                if (Props.animalDrivers && (group.role.handlingTypes & HandlingTypeFlags.Movement) != HandlingTypeFlags.None)
                {
                    Find.Targeter.BeginTargeting(
                        new TargetingParameters
                    {
                        validator = ti => ti.Thing is Pawn p && p.Faction != null && p.Faction.IsPlayer && p.training != null && p.training.IsCompleted(DefDatabase <TrainableDef> .GetNamed("Haul")) && p.BodySize > Props.minBodySize
                    }, delegate(LocalTargetInfo target) { GiveLoadJob(target.Thing, group); }, null, null, null);
Exemple #6
0
        public void GetVehicleButtonFloatMenu(VehicleHandlerGroup group, bool canLoad)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();
            Map         map             = this.Pawn.Map;
            List <Pawn> tempList        = new List <Pawn>(group.handlers);

            if (canLoad)
            {
                string text = "CompVehicle_Load".Translate(group.role.label);
                //Func<Rect, bool> extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, handler);
                list.Add(new FloatMenuOption(text, delegate
                {
                    SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                    Find.Targeter.BeginTargeting(TargetingParameters.ForAttackAny(), delegate(LocalTargetInfo target)
                    {
                        GiveLoadJob(target.Thing, group);
                    }, null, null, null);
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }
            if (tempList.Count != 0)
            {
                foreach (Pawn handler in tempList)
                {
                    string text = "CompVehicle_Unload".Translate(handler.Name.ToStringFull);
                    List <FloatMenuOption> arg_121_0      = list;
                    Func <Rect, bool>      extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, handler);
                    list.Add(new FloatMenuOption(text, delegate
                    {
                        Eject(handler, group.handlers);
                    }, MenuOptionPriority.Default, null, null, 29f, extraPartOnGUI, null));
                }
            }
            else
            {
                list.Add(new FloatMenuOption("NoPrisoners".Translate(), delegate
                {
                }, MenuOptionPriority.Default));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
 public Bill_LoadVehicle(Pawn newLoad, Pawn newVehicle, VehicleHandlerGroup newGroup)
 {
     this.pawnToLoad = newLoad;
     this.group      = newGroup;
 }