Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/SpawnInfra/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ internal class Configuration
[JsonProperty("使用说明5", Order = -11)]
public string Text5 { get; set; } = "每次重置服务器前使用一遍:/rm 重置,或者直接把这个指令写进重置插件里";
[JsonProperty("使用说明6", Order = -11)]
public string Text6 { get; set; } = "以下参数仅适用于大地图,小地图需自己调试适配";
public string Text6 { get; set; } = "以下参数仅适用于大地图,中地图需自己调试适配";
[JsonProperty("使用说明7", Order = -11)]
public string Text7 { get; set; } = "[设置刷怪率]需所有在线玩家在刷怪场中心且击败[肉山]后生效";

[JsonProperty("开服自动基建", Order = -10)]
public bool Enabled { get; set; } = true;

[JsonProperty("开服指令表", Order = -1)]
public string[] CommandList { get; set; } = new string[] { };

[JsonProperty("自建微光湖", Order = 0)]
public List<ItemData4> SpawnShimmerBiome { get; set; } = new List<ItemData4>();

Expand Down Expand Up @@ -178,9 +181,7 @@ public class ItemData2

[JsonProperty("实体块包围左海平台(天顶必开)", Order = 11)]
public bool Enclose { get; set; } = true;
[JsonProperty("左右实体块是否对齐上下(加载很慢)", Order = 11)]
public bool AccordantY { get; set; } = false;
[JsonProperty("左海平台产生液(非空岛不需要开)", Order = 13)]
[JsonProperty("左海平台产生液体(非空岛不需要开)", Order = 12)]
public bool PlaceLiquid { get; set; } = false;

public ItemData2(int id, int style, int tileY, int height, int limit, int limit2, int wide, int height2, int interval)
Expand Down Expand Up @@ -314,7 +315,7 @@ public void Ints()

this.WorldPlatform = new List<ItemData2>
{
new ItemData2(19, 43, -200 ,35,150,50,270,200,30),
new ItemData2(19, 43, -100 ,35,150,50,270,200,30),
};

this.HellTunnel = new List<ItemData3>
Expand Down Expand Up @@ -354,5 +355,4 @@ public static Configuration Read()
}
}
#endregion

}
106 changes: 60 additions & 46 deletions src/SpawnInfra/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Plugin : TerrariaPlugin
#region 插件信息
public override string Name => "生成基础建设";
public override string Author => "羽学";
public override Version Version => new Version(1, 5, 5);
public override Version Version => new Version(1, 5, 6);
public override string Description => "给新世界创建NPC住房、仓库、洞穴刷怪场、地狱/微光直通车、地表和地狱世界级平台(轨道)";
#endregion

Expand Down Expand Up @@ -70,23 +70,26 @@ private static void OnGamePostInitialize(EventArgs args)

if (Config.Enabled)
{
foreach (var item in Config.Chests)
foreach (var cmd in Config.CommandList)
{
SpawnChest(Main.spawnTileX + item.spawnTileX, Main.spawnTileY + item.spawnTileY, item.ClearHeight, item.ChestWidth, item.ChestCount, item.ChestLayers);
Commands.HandleCommand(TSPlayer.Server, cmd);
}

foreach (var item in Config.WorldPlatform)
//监狱
foreach (var item in Config.Prison)
{
if (Main.zenithWorld || Main.remixWorld) //天顶 颠倒以天空层往下算
{
WorldPlatform((int) sky - item.WorldPlatformY, item.WorldPlatformClearY);
}
else //正常世界从出生点算
{
WorldPlatform(Main.spawnTileY + item.WorldPlatformY, item.WorldPlatformClearY);
}
GenLargeHouse(Main.spawnTileX + item.spawnTileX, Main.spawnTileY + item.spawnTileY, item.BigHouseWidth, item.BigHouseHeight);
}


//箱子
foreach (var item in Config.Chests)
{
SpawnChest(Main.spawnTileX + item.spawnTileX, Main.spawnTileY + item.spawnTileY, item.ClearHeight, item.ChestWidth, item.ChestCount, item.ChestLayers);
}



//自建微光湖
foreach (var item in Config.SpawnShimmerBiome)
{
Expand All @@ -106,6 +109,7 @@ private static void OnGamePostInitialize(EventArgs args)
}
}


//地狱直通车与刷怪场
foreach (var item in Config.HellTunnel)
{
Expand Down Expand Up @@ -173,10 +177,17 @@ private static void OnGamePostInitialize(EventArgs args)
UnderworldPlatform(Main.UnderworldLayer + item.HellPlatformY, item.HellPlatformY);
}

//监狱
foreach (var item in Config.Prison)
//世界平台
foreach (var item in Config.WorldPlatform)
{
GenLargeHouse(Main.spawnTileX + item.spawnTileX, Main.spawnTileY + item.spawnTileY, item.BigHouseWidth, item.BigHouseHeight);
if (Main.zenithWorld || Main.remixWorld) //天顶 颠倒以天空层往下算
{
WorldPlatform((int) sky - item.WorldPlatformY, item.WorldPlatformClearY);
}
else //正常世界从出生点往上算
{
WorldPlatform(Main.spawnTileY + item.WorldPlatformY, item.WorldPlatformClearY);
}
}

TShock.Utils.Broadcast(
Expand All @@ -185,7 +196,6 @@ private static void OnGamePostInitialize(EventArgs args)

Commands.HandleCommand(TSPlayer.Server, "/save");
Commands.HandleCommand(TSPlayer.Server, "/clear i 9999");

Configuration.Read();
Config.Enabled = false;
Config.Write();
Expand Down Expand Up @@ -312,7 +322,10 @@ private static void RockTrialField(double posY, int Height, int Width, int Cente
WorldGen.PlaceWall(CenterRight + j - 8 - CenterVal, middle + i, 164, false); // 右 62 - 84格刷怪区 放红玉晶莹墙警示
}
}

if (Main.tile[x, y].wall != Terraria.ID.WallID.None)
{
continue;
}
WorldGen.PlaceTile(x, middle + 11 + CenterVal, Config.HellTunnel[0].Hell_BM_TileID, false, true, -1, 0); //中间下11格放箱子的实体块

WorldGen.PlaceTile(x, middle + 10 + CenterVal, Config.Chests[0].ChestTileID, false, true, -1, Config.Chests[0].ChestStyle); //中间下10格放箱子
Expand Down Expand Up @@ -703,6 +716,7 @@ private static void OceanPlatforms(int sky, int wide, int height, int interval,
}

var clear = Math.Max(0, height);

for (var y = Main.oceanBG; y < sky + clear; y += interval)
{
for (var top = y - IntlClear; top < y; top++)
Expand Down Expand Up @@ -736,51 +750,46 @@ private static void OceanPlatforms(int sky, int wide, int height, int interval,
WorldGen.PlaceLiquid(x, y, 0, 255);
}

//开启实体块包围左海平台
// 开启实体块包围左海平台
if (Config.WorldPlatform[0].Enclose)
{
//清理顶部上面一层
// 清理顶部上面一层
for (var j = 1; j < clear; j++)
{
Main.tile[x, sky - clear + height - j].ClearTile(); // 清除方块
if (sky - clear + height - j >= 0 && sky - clear + height - j < Main.maxTilesY)
{
Main.tile[x, sky - clear + height - j].ClearTile();
}
}
//左海平台顶部放1层格栅让海水流下来
WorldGen.PlaceTile(x, sky - clear + height, 546, false, false, -1, 0);

//清理底部上面一层
for (var j = 1; j < IntlClear; j++)
// 放置左海平台顶部格栅
if (sky - clear + height >= 0 && sky - clear + height < Main.maxTilesY)
{
Main.tile[x, sky + clear - j].ClearEverything(); // 清除所有
WorldGen.PlaceTile(x, sky - clear + height, 546, false, false, -1, 0);
}
//左海平台底部放1层
WorldGen.PlaceTile(x, sky + clear, 38, false, true, -1, 0);

// 左右侧实体块对上下对齐 (这个对CPU算力要求很高 加载超级慢
if (Config.WorldPlatform[0].AccordantY)
// 清理底部上面一层
for (var j = 1; j < IntlClear; j++)
{
for (var y2 = sky - clear + height; y2 < sky + clear; y2++)
if (sky + clear - j >= 0 && sky + clear - j < Main.maxTilesY)
{
WorldGen.PlaceTile(0, y2, 38, false, true, -1, 0);
WorldGen.PlaceTile(wide - 1, y2, 38, false, true, -1, 0);
Main.tile[x, sky + clear - j].ClearEverything();
}
}
else
{
//左边放一列 这列只能从地图编辑器看(41以内的x轴坐标已经超出地图边界外了)
WorldGen.PlaceTile(0, x + y - IntlClear, Config.HellTunnel[0].Hell_BM_TileID, false, true, -1, 0);

//考虑十周年有些出生点离左海太近 所以不放右侧
if (Math.Abs(wide - Main.spawnTileX) < Radius)
{
continue;
}
else
{
//正常出生点的左海都会放右侧墙
WorldGen.PlaceTile(wide, x + y - IntlClear, Config.HellTunnel[0].Hell_BM_TileID, false, true, -1, 0);
}
// 放置左海平台底部
if (sky + clear >= 0 && sky + clear < Main.maxTilesY)
{
WorldGen.PlaceTile(x, sky + clear, 38, false, true, -1, 0);
}

// 放置左边一列特定方块
var leftX = 0;
var leftY = x + y - IntlClear;
if (leftY >= 0 && leftY < Main.maxTilesY)
{
WorldGen.PlaceTile(leftX, leftY, Config.HellTunnel[0].Hell_BM_TileID, false, true, -1, 0);
}
}
}
}
Expand All @@ -805,6 +814,11 @@ private static void WorldPlatform(int posY, int hight)

for (var y = posY - clear; y <= posY; y++)
{
if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
{
continue;
}

Main.tile[x, y].ClearEverything();
}

Expand Down
12 changes: 11 additions & 1 deletion src/SpawnInfra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@

## 更新日志
```
v1.5.6
移除左右实体块是否对齐上下配置项
给世界平台加了判断阻拦,如果进入太空层则不生成
重新排列了一下世界平台的生成顺序
(放最后,避免建了小地图导致平台放置,导致索引越界妨碍其他建筑的放置)
声明此插件不适用于小地图,如果是中地图请自己修改相关配置参数进行调试

v1.5.5
完善卸载函数
配置项加入开服指令表,用于配合【奖励箱】插件,
它会先执行指令再放置建筑物
(仅在开启【开服自动基建】时会执行1次)

v1.5.4
给刷怪场加入提高刷怪率方法
Expand Down Expand Up @@ -102,7 +112,7 @@ v1.0.0
"使用说明3": "改[箱子数量]要同时改[出生点偏移X],改[箱子层数]要同时改[出生点偏移Y],[层数间隔]和[箱子宽度]不建议动",
"使用说明4": "给玩家用的建晶塔房指令:/rm 数量 权限名:room.use (千万别在出生点用,有炸图风险)",
"使用说明5": "每次重置服务器前使用一遍:/rm 重置,或者直接把这个指令写进重置插件里",
"使用说明6": "以下参数仅适用于大地图,小地图需自己调试适配",
"使用说明6": "以下参数仅适用于大地图,中地图需自己调试适配",
"使用说明7": "[设置刷怪率]需所有在线玩家在刷怪场中心且击败[肉山]后生效",
"开服自动基建": true,
"自建微光湖": [
Expand Down