Exemplo n.º 1
0
        public void Dismount()
        {
            Building_Reloadable turret = (parent as Building_Reloadable);

            if (turret != null)
            {
                turret.dontReload = false;
            }

            if (Driver.RaceProps.Humanlike)
            {
                Driver.AllComps?.Remove(driverComp);
                driverComp.vehicle = null;
                driverComp.parent  = null;
            }

            MapComponent_ToolsForHaul.currentVehicle.Remove(Driver);

            Driver.RaceProps.makesFootprints = true;

            //if (Find.Reservations.IsReserved(parent, Driver.Faction))
            Find.Reservations.ReleaseAllForTarget(parent);
            if (Driver.Faction != Faction.OfPlayer)
            {
                parent.SetForbidden(true);
                parent.SetFaction(null);
            }

            Driver = null;

            if (sustainerAmbient != null)
            {
                sustainerAmbient.End();
            }


            //  Find.ListerBuildings.Add(parent as Building);
        }
Exemplo n.º 2
0
        public void MountOn(Pawn pawn)
        {
            if (Driver != null)
            {
                return;
            }

            Building_Reloadable turret = (parent as Building_Reloadable);

            if (turret != null)
            {
                turret.dontReload = true;
            }

            // Check to make pawns not mount two vehicles at once
            if (ToolsForHaulUtility.IsDriver(pawn))
            {
                if (ToolsForHaulUtility.GetCartByDriver(pawn) != null)
                {
                    ToolsForHaulUtility.GetCartByDriver(pawn).mountableComp.Dismount();
                }

                if (ToolsForHaulUtility.GetTurretByDriver(pawn) != null)
                {
                    ToolsForHaulUtility.GetTurretByDriver(pawn).mountableComp.Dismount();
                }
            }

            Driver = pawn;

            MapComponent_ToolsForHaul.currentVehicle.Add(pawn, parent);

            if (Driver.RaceProps.Humanlike)
            {
                Driver.RaceProps.makesFootprints = false;
            }

            if (pawn.RaceProps.Humanlike)
            {
                driverComp = new CompDriver {
                    vehicle = parent as Building
                };
                Driver?.AllComps?.Add(driverComp);
                driverComp.parent = Driver;
            }

            Vehicle_Cart vehicleCart = parent as Vehicle_Cart;

            if (vehicleCart != null)
            {
                // Set faction of vehicle to whoever mounts it
                if (vehicleCart.Faction != Driver.Faction && vehicleCart.ClaimableBy(Driver.Faction))
                {
                    parent.SetFaction(Driver.Faction);
                }


                if (vehicleCart.IsCurrentlyMotorized())
                {
                    SoundInfo info = SoundInfo.InWorld(parent);
                    sustainerAmbient = vehicleCart.vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                }


                return;
            }

            Vehicle_Turret vehicleTurret = parent as Vehicle_Turret;

            if (vehicleTurret != null)
            {
                // Set faction of vehicle to whoever mounts it
                if (vehicleTurret.Faction != Driver.Faction && vehicleTurret.ClaimableBy(Driver.Faction))
                {
                    parent.SetFaction(Driver.Faction);
                }

                if (vehicleTurret.IsCurrentlyMotorized())
                {
                    SoundInfo info = SoundInfo.InWorld(parent);
                    sustainerAmbient = vehicleTurret.vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                }

                return;
            }
        }