Added config option to allow control of how statue spawn limits work. Updated binary to work with new hooks.

This commit is contained in:
Zack Piispanen 2012-04-27 00:48:38 -04:00
parent bcf6636df8
commit 653e609e25
3 changed files with 23 additions and 0 deletions

View file

@ -220,6 +220,15 @@ namespace TShockAPI
[Description("Allows hallow to spread when a world is hardmode.")] public bool AllowHallowCreep = true;
[Description("How many things a statue can spawn within 200 pixels(?) before it stops spawning. Default = 3")]
public int StatueSpawn200 = 3;
[Description("How many things a statue can spawn within 600 pixels(?) before it stops spawning. Default = 6")]
public int StatueSpawn600 = 6;
[Description("How many things a statue spawns can exist in the world before it stops spawning. Default = 10")]
public int StatueSpawnWorld = 10;
public static ConfigFile Read(string path)
{
if (!File.Exists(path))

View file

@ -204,6 +204,7 @@ namespace TShockAPI
GameHooks.PostInitialize += OnPostInit;
GameHooks.Update += OnUpdate;
GameHooks.HardUpdate += OnHardUpdate;
GameHooks.StatueSpawn += OnStatueSpawn;
ServerHooks.Connect += OnConnect;
ServerHooks.Join += OnJoin;
ServerHooks.Leave += OnLeave;
@ -283,6 +284,7 @@ namespace TShockAPI
GameHooks.PostInitialize -= OnPostInit;
GameHooks.Update -= OnUpdate;
GameHooks.HardUpdate -= OnHardUpdate;
GameHooks.StatueSpawn -= OnStatueSpawn;
ServerHooks.Connect -= OnConnect;
ServerHooks.Join -= OnJoin;
ServerHooks.Leave -= OnLeave;
@ -643,6 +645,18 @@ namespace TShockAPI
}
}
private void OnStatueSpawn( StatueSpawnEventArgs args )
{
if( args.Within200 < Config.StatueSpawn200 && args.Within600 < Config.StatueSpawn600 && args.WorldWide < Config.StatueSpawnWorld )
{
args.Handled = true;
}
else
{
args.Handled = false;
}
}
private void OnConnect(int ply, HandledEventArgs handler)
{
var player = new TSPlayer(ply);