protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map) { Item item = CreateItem(); item.OnBeforeSpawn(loc, map); item.MoveToWorld(loc, map); item.OnAfterSpawn(); return(item); }
public override object Spawn( SpawnEntry entry ) { Region region = entry.Region; Map map = region.Map; Point3D loc = entry.RandomSpawnLocation( this.Height, this.Land, this.Water ); if ( loc == Point3D.Zero ) return null; return Construct( entry, loc, map ); }
public override ISpawnable Spawn(SpawnEntry entry) { Region region = entry.Region; Map map = region.Map; Point3D loc = entry.RandomSpawnLocation(this.Height, this.Land, this.Water); if (loc == Point3D.Zero) { return(null); } return(Construct(entry, loc, map)); }
public override object Spawn( SpawnEntry entry ) { int index = Utility.Random( m_TotalWeight ); for ( int i = 0; i < m_Elements.Length; i++ ) { SpawnGroupElement element = m_Elements[i]; if ( index < element.Weight ) return element.SpawnDefinition.Spawn( entry ); index -= element.Weight; } return null; }
public override ISpawnable Spawn(SpawnEntry entry) { int index = Utility.Random(m_TotalWeight); for (int i = 0; i < m_Elements.Length; i++) { SpawnGroupElement element = m_Elements[i]; if (index < element.Weight) { return(element.SpawnDefinition.Spawn(entry)); } index -= element.Weight; } return(null); }
protected override object Construct( SpawnEntry entry, Point3D loc, Map map ) { Mobile mobile = CreateMobile(); BaseCreature creature = mobile as BaseCreature; if ( creature != null ) { creature.Home = entry.Home; creature.RangeHome = entry.Range; } if ( entry.Direction != SpawnEntry.InvalidDirection ) mobile.Direction = entry.Direction; mobile.OnBeforeSpawn( loc, map ); mobile.MoveToWorld( loc, map ); mobile.OnAfterSpawn(); return mobile; }
protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map) { Mobile mobile = CreateMobile(); if (mobile is BaseCreature creature) { creature.Home = entry.HomeLocation; creature.RangeHome = entry.HomeRange; } if (entry.Direction != SpawnEntry.InvalidDirection) { mobile.Direction = entry.Direction; } mobile.OnBeforeSpawn(loc, map); mobile.MoveToWorld(loc, map); mobile.OnAfterSpawn(); return(mobile); }
public static bool CanSpawn(Region region, params Type[] types) { while (region != null) { if (!region.AllowSpawn()) { return(false); } BaseRegion br = region as BaseRegion; if (br != null) { if (br.Spawns != null) { for (int i = 0; i < br.Spawns.Length; i++) { SpawnEntry entry = br.Spawns[i]; if (entry.Definition.CanSpawn(types)) { return(true); } } } if (br.ExcludeFromParentSpawns) { return(false); } } region = region.Parent; } return(false); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadEncodedInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { int id = reader.ReadInt(); SpawnEntry entry = (SpawnEntry)SpawnEntry.Table[id]; if (entry != null) { entry.Deserialize(reader, version); } else { SpawnEntry.Remove(reader, version); } } }
protected override ISpawnable Construct( SpawnEntry entry, Point3D loc, Map map ) { Item item = CreateItem(); item.OnBeforeSpawn( loc, map ); item.MoveToWorld( loc, map ); item.OnAfterSpawn(); return item; }
public abstract ISpawnable Spawn( SpawnEntry entry );
protected override ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map) { Mobile mobile = CreateMobile(); BaseCreature creature = mobile as BaseCreature; if ( creature != null ) { creature.Home = entry.HomeLocation; creature.HomeMap = map; creature.RangeHome = entry.HomeRange; } if ( entry.Direction != SpawnEntry.InvalidDirection ) mobile.Direction = entry.Direction; mobile.OnBeforeSpawn( loc, map ); mobile.MoveToWorld( loc, map ); mobile.OnAfterSpawn(); return mobile; }
public override ISpawnable Spawn( SpawnEntry entry ) { Region region = entry.Region; Map map = region.Map; Point3D loc = entry.RandomSpawnLocation( this.Height, this.Land, this.Water ); if ( loc == Point3D.Zero ) return null; return Construct( entry, loc, map ); }
protected abstract ISpawnable Construct( SpawnEntry entry, Point3D loc, Map map );
public abstract object Spawn( SpawnEntry entry );
protected abstract object Construct( SpawnEntry entry, Point3D loc, Map map );
public override ISpawnable Spawn(SpawnEntry entry) { int index = Utility.Random( m_TotalWeight ); for ( int i = 0; i < m_Elements.Length; i++ ) { SpawnGroupElement element = m_Elements[i]; if ( index < element.Weight ) return element.SpawnDefinition.Spawn( entry ); index -= element.Weight; } return null; }
public BaseRegion( XmlElement xml, Map map, Region parent ) : base( xml, map, parent ) { ReadString( xml["rune"], "name", ref m_RuneName, false ); bool logoutDelayActive = true; ReadBoolean( xml["logoutDelay"], "active", ref logoutDelayActive, false ); m_NoLogoutDelay = !logoutDelayActive; XmlElement spawning = xml["spawning"]; if ( spawning != null ) { ReadBoolean( spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false ); SpawnZLevel zLevel = SpawnZLevel.Lowest; ReadEnum(spawning, "zLevel", ref zLevel, false); m_SpawnZLevel = zLevel; List<SpawnEntry> list = new List<SpawnEntry>(); foreach ( XmlNode node in spawning.ChildNodes ) { XmlElement el = node as XmlElement; if ( el != null ) { SpawnDefinition def = SpawnDefinition.GetSpawnDefinition( el ); if ( def == null ) continue; int id = 0; if ( !ReadInt32( el, "id", ref id, true ) ) continue; int amount = 0; if ( !ReadInt32( el, "amount", ref amount, true ) ) continue; TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime; ReadTimeSpan( el, "minSpawnTime", ref minSpawnTime, false ); TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime; ReadTimeSpan( el, "maxSpawnTime", ref maxSpawnTime, false ); Point3D home = Point3D.Zero; int range = 0; XmlElement homeEl = el["home"]; if ( ReadPoint3D( homeEl, map, ref home, false ) ) ReadInt32( homeEl, "range", ref range, false ); Direction dir = SpawnEntry.InvalidDirection; ReadEnum(el["direction"], "value", ref dir, false); SpawnEntry entry = new SpawnEntry( id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime ); list.Add( entry ); } } if ( list.Count > 0 ) { m_Spawns = list.ToArray(); } } }
protected abstract ISpawnable Construct(SpawnEntry entry, Point3D loc, Map map);
public BaseRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent) { ReadString(xml["rune"], "name", ref m_RuneName, false); bool logoutDelayActive = true; ReadBoolean(xml["logoutDelay"], "active", ref logoutDelayActive, false); m_NoLogoutDelay = !logoutDelayActive; XmlElement spawning = xml["spawning"]; if (spawning != null) { ReadBoolean(spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false); SpawnZLevel zLevel = SpawnZLevel.Lowest; ReadEnum(spawning, "zLevel", ref zLevel, false); m_SpawnZLevel = zLevel; List <SpawnEntry> list = new List <SpawnEntry>(); foreach (XmlNode node in spawning.ChildNodes) { XmlElement el = node as XmlElement; if (el != null) { SpawnDefinition def = SpawnDefinition.GetSpawnDefinition(el); if (def == null) { continue; } int id = 0; if (!ReadInt32(el, "id", ref id, true)) { continue; } int amount = 0; if (!ReadInt32(el, "amount", ref amount, true)) { continue; } TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime; ReadTimeSpan(el, "minSpawnTime", ref minSpawnTime, false); TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime; ReadTimeSpan(el, "maxSpawnTime", ref maxSpawnTime, false); Point3D home = Point3D.Zero; int range = 0; XmlElement homeEl = el["home"]; if (ReadPoint3D(homeEl, map, ref home, false)) { ReadInt32(homeEl, "range", ref range, false); } Direction dir = SpawnEntry.InvalidDirection; ReadEnum(el["direction"], "value", ref dir, false); SpawnEntry entry = new SpawnEntry(id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime); list.Add(entry); } } if (list.Count > 0) { m_Spawns = list.ToArray(); } } }
public abstract ISpawnable Spawn(SpawnEntry entry);