#W# Source and Scripts added. Added Scripts/Settings.cs to expose some basic tweak able settings.
This commit is contained in:
parent
b51c58f514
commit
3045c83799
3512 changed files with 627673 additions and 0 deletions
80
Scripts/Engines/Factions/Core/Generator.cs
Normal file
80
Scripts/Engines/Factions/Core/Generator.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using Server.Commands;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Factions
|
||||
{
|
||||
public class Generator
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "GenerateFactions", AccessLevel.Administrator, new CommandEventHandler( GenerateFactions_OnCommand ) );
|
||||
}
|
||||
|
||||
public static void GenerateFactions_OnCommand( CommandEventArgs e )
|
||||
{
|
||||
new FactionPersistance();
|
||||
|
||||
List<Faction> factions = Faction.Factions;
|
||||
|
||||
foreach ( Faction faction in factions )
|
||||
Generate( faction );
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
foreach ( Town town in towns )
|
||||
Generate( town );
|
||||
}
|
||||
|
||||
public static void Generate( Town town )
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
|
||||
TownDefinition def = town.Definition;
|
||||
|
||||
if ( !CheckExistance( def.Monolith, facet, typeof( TownMonolith ) ) )
|
||||
{
|
||||
TownMonolith mono = new TownMonolith( town );
|
||||
mono.MoveToWorld( def.Monolith, facet );
|
||||
mono.Sigil = new Sigil( town );
|
||||
}
|
||||
|
||||
if ( !CheckExistance( def.TownStone, facet, typeof( TownStone ) ) )
|
||||
new TownStone( town ).MoveToWorld( def.TownStone, facet );
|
||||
}
|
||||
|
||||
public static void Generate( Faction faction )
|
||||
{
|
||||
Map facet = Faction.Facet;
|
||||
|
||||
List<Town> towns = Town.Towns;
|
||||
|
||||
StrongholdDefinition stronghold = faction.Definition.Stronghold;
|
||||
|
||||
if ( !CheckExistance( stronghold.JoinStone, facet, typeof( JoinStone ) ) )
|
||||
new JoinStone( faction ).MoveToWorld( stronghold.JoinStone, facet );
|
||||
|
||||
if ( !CheckExistance( stronghold.FactionStone, facet, typeof( FactionStone ) ) )
|
||||
new FactionStone( faction ).MoveToWorld( stronghold.FactionStone, facet );
|
||||
|
||||
for ( int i = 0; i < stronghold.Monoliths.Length; ++i )
|
||||
{
|
||||
Point3D monolith = stronghold.Monoliths[i];
|
||||
|
||||
if ( !CheckExistance( monolith, facet, typeof( StrongholdMonolith ) ) )
|
||||
new StrongholdMonolith( towns[i], faction ).MoveToWorld( monolith, facet );
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckExistance( Point3D loc, Map facet, Type type )
|
||||
{
|
||||
foreach ( Item item in facet.GetItemsInRange( loc, 0 ) )
|
||||
{
|
||||
if ( type.IsAssignableFrom( item.GetType() ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue