public void DockBoat(BaseBoat boat, BaseHouse house) { foreach (var entity in boat.GetEntitiesOnBoard()) { if (!(entity is Item) || entity == this || boat.IsComponentItem(entity) || entity is EffectItem || entity == boat.TillerMan) { continue; } Item item = entity as Item; if (!item.Deleted && boat.Contains(item)) { if (item is AddonComponent || item is BaseAddon) { BaseAddon addon = item is AddonComponent ? ((AddonComponent)item).Addon : (BaseAddon)item; Item deed = addon.Deed; bool retainDeedHue = false; int hue = 0; if (addon != null && addon.RetainDeedHue) { retainDeedHue = true; for (int j = 0; hue == 0 && j < addon.Components.Count; ++j) { AddonComponent c = addon.Components[j]; if (c.Hue != 0) { hue = c.Hue; } } } if (deed != null) { if (retainDeedHue) { deed.Hue = hue; } house.DropToMovingCrate(deed); } } else { item.Delete(); } } Container cont; if (boat is BaseGalleon) { cont = ((BaseGalleon)boat).GalleonHold; } else { cont = boat.Hold; } if (cont != null) { cont.Items.ForEach(i => { if (i is BaseWeapon) { house.DropToMovingCrate(i); } else { i.Delete(); } }); } } BaseDockedBoat model = boat.BoatItem; if (model == null || model.Deleted) { model = boat.DockedBoat; } if (model == null) { return; } model.BoatItem = boat; if (boat.IsClassicBoat && boat.Owner != null) { boat.RemoveKeys(boat.Owner); } house.DropToMovingCrate(model); boat.OnDryDock(null); boat.Refresh(); boat.Internalize(); }
public void CheckEnter(BaseBoat boat) { if (boat == null || Map == null || Map == Map.Internal) { return; } //Do not enter corgul region if we aren't in this region anymore Region r = Region.Find(boat.Location, boat.Map); if (r != null && !r.IsPartOf(this)) { return; } Map map = Map; List <PlayerMobile> pms = new List <PlayerMobile>(); bool hasMap = false; foreach (PlayerMobile i in boat.GetEntitiesOnBoard().OfType <PlayerMobile>().Where(pm => pm.NetState != null)) { pms.Add(i); PlayerMobile pm = i; if (pm.Backpack == null) { continue; } Item item = pm.Backpack.FindItemByType(typeof(CorgulIslandMap)); if (item != null && item is CorgulIslandMap && Contains(((CorgulIslandMap)item).DestinationPoint)) { hasMap = true; break; } } if (hasMap) { int x = boat.X - m_Bounds.X; int y = boat.Y - m_Bounds.Y; int z = map.GetAverageZ(x, y); Point3D ePnt = new Point3D(CorgulAltar.CorgulBounds.X + x, CorgulAltar.CorgulBounds.Y + y, 0); int offsetX = ePnt.X - boat.X; int offsetY = ePnt.Y - boat.Y; int offsetZ = map.GetAverageZ(ePnt.X, ePnt.Y) - boat.Z; if (boat.CanFit(ePnt, Map, boat.ItemID)) { boat.Teleport(offsetX, offsetY, offsetZ); //int z = this.Map.GetAverageZ(boat.X, boat.Y); if (boat.Z != 0) { boat.Z = 0; } if (boat.TillerMan != null) { boat.TillerManSay(501425); //Ar, turbulent water! } } else { boat.StopMove(true); boat.SendMessageToAllOnBoard("The boat has struck a coral reef!"); } } }