Пример #1
0
        public VehicleHandler(VehiclePawn vehiclePawn, VehicleRole newRole)
        {
            List <Pawn> newHandlers = new List <Pawn>();

            uniqueID         = VehicleIdManager.Instance.GetNextHandlerId();
            this.vehiclePawn = vehiclePawn;
            role             = new VehicleRole(newRole);
            if (handlers is null)
            {
                handlers = new ThingOwner <Pawn>(this, false, LookMode.Reference);
            }
            if ((newHandlers?.Count ?? 0) > 0)
            {
                foreach (Pawn p in newHandlers)
                {
                    if (p.Spawned)
                    {
                        p.DeSpawn();
                    }
                    if (p.holdingOwner != null)
                    {
                        p.holdingOwner = null;
                    }
                    if (!p.IsWorldPawn())
                    {
                        Find.WorldPawns.PassToWorld(p, PawnDiscardDecideMode.Decide);
                    }
                }
                handlers.TryAddRangeOrTransfer(newHandlers);
            }
        }
Пример #2
0
 public VehicleRole(VehicleRole reference)
 {
     if (string.IsNullOrEmpty(reference.key))
     {
         Log.Error($"Missing Key on VehicleRole {reference.label}");
     }
     key           = reference.key;
     label         = reference.label;
     handlingTypes = new List <HandlingTypeFlags>();
     if (reference.handlingTypes != null)
     {
         handlingTypes.AddRange(reference.handlingTypes);
     }
     slots          = reference.slots;
     slotsToOperate = reference.slotsToOperate;
     cannonIds      = reference.cannonIds;
     hitbox         = reference.hitbox;
 }