mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-03 04:36:03 +08:00
Fix Basic Rogue Event
This commit is contained in:
5
Common/Data/Config/Scene/AnchorInfo.cs
Normal file
5
Common/Data/Config/Scene/AnchorInfo.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class AnchorInfo : PositionInfo
|
||||
{
|
||||
}
|
||||
112
Common/Data/Config/Scene/FloorInfo.cs
Normal file
112
Common/Data/Config/Scene/FloorInfo.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using EggLink.DanhengServer.Enums.Scene;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class FloorInfo
|
||||
{
|
||||
[JsonIgnore] public Dictionary<int, PropInfo> CachedTeleports = [];
|
||||
|
||||
[JsonIgnore] public Dictionary<int, GroupInfo> Groups = [];
|
||||
|
||||
[JsonIgnore] public bool Loaded;
|
||||
|
||||
[JsonIgnore] public List<PropInfo> UnlockedCheckpoints = [];
|
||||
|
||||
public int FloorID { get; set; }
|
||||
public int StartGroupIndex { get; set; }
|
||||
public int StartAnchorID { get; set; }
|
||||
|
||||
public List<FloorGroupInfo> GroupInstanceList { get; set; } = [];
|
||||
public List<FloorSavedValueInfo> SavedValues { get; set; } = [];
|
||||
public List<FloorCustomValueInfo> CustomValues { get; set; } = [];
|
||||
public List<FloorDimensionInfo> DimensionList { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public int StartGroupID { get; set; }
|
||||
|
||||
public AnchorInfo? GetAnchorInfo(int groupId, int anchorId)
|
||||
{
|
||||
Groups.TryGetValue(groupId, out var group);
|
||||
if (group == null) return null;
|
||||
|
||||
return group.AnchorList.Find(info => info.ID == anchorId);
|
||||
}
|
||||
|
||||
public void OnLoad()
|
||||
{
|
||||
if (Loaded) return;
|
||||
|
||||
StartGroupID = GroupInstanceList[StartGroupIndex].ID;
|
||||
|
||||
foreach (var dimension in DimensionList) dimension.OnLoad(this);
|
||||
|
||||
// Cache anchors
|
||||
foreach (var group in Groups.Values)
|
||||
foreach (var prop in group.PropList)
|
||||
// Check if prop can be teleported to
|
||||
if (prop.AnchorID > 0)
|
||||
{
|
||||
// Put inside cached teleport list to send to client when they request map info
|
||||
CachedTeleports.TryAdd(prop.MappingInfoID, prop);
|
||||
UnlockedCheckpoints.Add(prop);
|
||||
|
||||
// Force prop to be in the unlocked state
|
||||
prop.State = PropStateEnum.CheckPointEnable;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(prop.InitLevelGraph))
|
||||
{
|
||||
var json = prop.InitLevelGraph;
|
||||
|
||||
// Hacky way to setup prop triggers
|
||||
if (json.Contains("Maze_GroupProp_OpenTreasure_WhenMonsterDie"))
|
||||
{
|
||||
//prop.Trigger = new TriggerOpenTreasureWhenMonsterDie(group.Id);
|
||||
}
|
||||
else if (json.Contains("Common_Console"))
|
||||
{
|
||||
prop.CommonConsole = true;
|
||||
}
|
||||
|
||||
// Clear for garbage collection
|
||||
prop.ValueSource = null;
|
||||
prop.InitLevelGraph = null;
|
||||
}
|
||||
|
||||
Loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class FloorGroupInfo
|
||||
{
|
||||
public string GroupPath { get; set; } = "";
|
||||
public bool IsDelete { get; set; }
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
}
|
||||
|
||||
public class FloorSavedValueInfo
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int DefaultValue { get; set; }
|
||||
}
|
||||
|
||||
public class FloorCustomValueInfo
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string DefaultValue { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class FloorDimensionInfo
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public List<int> GroupIndexList { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public List<int> GroupIDList { get; set; } = [];
|
||||
|
||||
public void OnLoad(FloorInfo floor)
|
||||
{
|
||||
foreach (var index in GroupIndexList) GroupIDList.Add(floor.GroupInstanceList[index].ID);
|
||||
}
|
||||
}
|
||||
134
Common/Data/Config/Scene/GroupInfo.cs
Normal file
134
Common/Data/Config/Scene/GroupInfo.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using EggLink.DanhengServer.Database.Quests;
|
||||
using EggLink.DanhengServer.Enums;
|
||||
using EggLink.DanhengServer.Enums.Mission;
|
||||
using EggLink.DanhengServer.Enums.Scene;
|
||||
using EggLink.DanhengServer.Util;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class GroupInfo
|
||||
{
|
||||
public int Id;
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public GroupLoadSideEnum LoadSide { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public GroupCategoryEnum Category { get; set; }
|
||||
|
||||
public LevelGroupSystemUnlockCondition? SystemUnlockCondition { get; set; } = null;
|
||||
public string LevelGraph { get; set; } = "";
|
||||
public bool LoadOnInitial { get; set; }
|
||||
public string GroupName { get; set; } = "";
|
||||
public LoadCondition LoadCondition { get; set; } = new();
|
||||
public LoadCondition UnloadCondition { get; set; } = new();
|
||||
public LoadCondition ForceUnloadCondition { get; set; } = new();
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public SaveTypeEnum SaveType { get; set; } = SaveTypeEnum.Save;
|
||||
|
||||
public int OwnerMainMissionID { get; set; }
|
||||
public List<AnchorInfo> AnchorList { get; set; } = [];
|
||||
public List<MonsterInfo> MonsterList { get; set; } = [];
|
||||
public List<PropInfo> PropList { get; set; } = [];
|
||||
public List<NpcInfo> NPCList { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public LevelGraphConfigInfo? LevelGraphConfig { get; set; }
|
||||
|
||||
[JsonIgnore] public Dictionary<string, List<int>> PropTriggerCustomString { get; set; } = [];
|
||||
|
||||
public void Load()
|
||||
{
|
||||
foreach (var prop in PropList) prop.Load(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class LoadCondition
|
||||
{
|
||||
public List<Condition> Conditions { get; set; } = [];
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public OperationEnum Operation { get; set; } = OperationEnum.And;
|
||||
|
||||
public bool IsTrue(MissionData mission, bool defaultResult = true)
|
||||
{
|
||||
if (Conditions.Count == 0) return defaultResult;
|
||||
var canLoad = Operation == OperationEnum.And;
|
||||
// check load condition
|
||||
foreach (var condition in Conditions)
|
||||
if (condition.Type == LevelGroupMissionTypeEnum.MainMission)
|
||||
{
|
||||
var info = mission.GetMainMissionStatus(condition.ID);
|
||||
if (!ConfigManager.Config.ServerOption.EnableMission) info = MissionPhaseEnum.Finish;
|
||||
|
||||
condition.Phase = condition.Phase == MissionPhaseEnum.Cancel
|
||||
? MissionPhaseEnum.Finish
|
||||
: condition.Phase;
|
||||
|
||||
if (info != condition.Phase)
|
||||
{
|
||||
if (Operation == OperationEnum.And)
|
||||
{
|
||||
canLoad = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Operation == OperationEnum.Or)
|
||||
{
|
||||
canLoad = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// sub mission
|
||||
var status = mission.GetSubMissionStatus(condition.ID);
|
||||
if (!ConfigManager.Config.ServerOption.EnableMission) status = MissionPhaseEnum.Finish;
|
||||
condition.Phase = condition.Phase == MissionPhaseEnum.Cancel
|
||||
? MissionPhaseEnum.Finish
|
||||
: condition.Phase;
|
||||
if (status != condition.Phase)
|
||||
{
|
||||
if (Operation == OperationEnum.And)
|
||||
{
|
||||
canLoad = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Operation == OperationEnum.Or)
|
||||
{
|
||||
canLoad = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return canLoad;
|
||||
}
|
||||
}
|
||||
|
||||
public class Condition
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public LevelGroupMissionTypeEnum Type { get; set; } = LevelGroupMissionTypeEnum.MainMission;
|
||||
|
||||
public int ID { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public MissionPhaseEnum Phase { get; set; } = MissionPhaseEnum.Accept;
|
||||
}
|
||||
|
||||
public class LevelGroupSystemUnlockCondition
|
||||
{
|
||||
public List<int> Conditions { get; set; } = [];
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public OperationEnum Operation { get; set; }
|
||||
}
|
||||
9
Common/Data/Config/Scene/MonsterInfo.cs
Normal file
9
Common/Data/Config/Scene/MonsterInfo.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class MonsterInfo : PositionInfo
|
||||
{
|
||||
public int NPCMonsterID { get; set; }
|
||||
public int EventID { get; set; }
|
||||
public int FarmElementID { get; set; }
|
||||
public bool IsClientOnly { get; set; }
|
||||
}
|
||||
7
Common/Data/Config/Scene/NpcInfo.cs
Normal file
7
Common/Data/Config/Scene/NpcInfo.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class NpcInfo : PositionInfo
|
||||
{
|
||||
public int NPCID { get; set; }
|
||||
public bool IsClientOnly { get; set; }
|
||||
}
|
||||
36
Common/Data/Config/Scene/PositionInfo.cs
Normal file
36
Common/Data/Config/Scene/PositionInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using EggLink.DanhengServer.Util;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class PositionInfo
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public float PosX { get; set; }
|
||||
public float PosY { get; set; }
|
||||
public float PosZ { get; set; }
|
||||
public bool IsDelete { get; set; }
|
||||
public string Name { get; set; } = "";
|
||||
public float RotX { get; set; }
|
||||
public float RotY { get; set; }
|
||||
public float RotZ { get; set; }
|
||||
|
||||
public Position ToPositionProto()
|
||||
{
|
||||
return new Position
|
||||
{
|
||||
X = (int)(PosX * 1000f),
|
||||
Y = (int)(PosY * 1000f),
|
||||
Z = (int)(PosZ * 1000f)
|
||||
};
|
||||
}
|
||||
|
||||
public Position ToRotationProto()
|
||||
{
|
||||
return new Position
|
||||
{
|
||||
Y = (int)(RotY * 1000f),
|
||||
X = (int)(RotX * 1000f),
|
||||
Z = (int)(RotZ * 1000f)
|
||||
};
|
||||
}
|
||||
}
|
||||
100
Common/Data/Config/Scene/PropInfo.cs
Normal file
100
Common/Data/Config/Scene/PropInfo.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using EggLink.DanhengServer.Enums.Scene;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace EggLink.DanhengServer.Data.Config.Scene;
|
||||
|
||||
public class PropInfo : PositionInfo
|
||||
{
|
||||
[JsonIgnore] public bool CommonConsole = false;
|
||||
public int MappingInfoID { get; set; }
|
||||
public int AnchorGroupID { get; set; }
|
||||
public int AnchorID { get; set; }
|
||||
public int PropID { get; set; }
|
||||
public int EventID { get; set; }
|
||||
public int CocoonID { get; set; }
|
||||
public int FarmElementID { get; set; }
|
||||
public bool IsClientOnly { get; set; }
|
||||
|
||||
public PropValueSource? ValueSource { get; set; }
|
||||
public string? InitLevelGraph { get; set; }
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public PropStateEnum State { get; set; } = PropStateEnum.Closed;
|
||||
|
||||
[JsonIgnore] public Dictionary<int, List<int>> UnlockDoorID { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public Dictionary<int, List<int>> UnlockControllerID { get; set; } = [];
|
||||
|
||||
[JsonIgnore] public bool IsLevelBtn { get; set; }
|
||||
|
||||
public void Load(GroupInfo info)
|
||||
{
|
||||
if (ValueSource != null)
|
||||
{
|
||||
if (Name.StartsWith("Button_") &&
|
||||
ValueSource.Values.Find(x => x["Key"]?.ToString() == "AnchorName") != null)
|
||||
IsLevelBtn = true;
|
||||
|
||||
foreach (var v in ValueSource.Values)
|
||||
try
|
||||
{
|
||||
var key = v["Key"];
|
||||
var value = v["Value"];
|
||||
if (value != null && key != null)
|
||||
{
|
||||
if (key.ToString() == "ListenTriggerCustomString")
|
||||
{
|
||||
info.PropTriggerCustomString.TryGetValue(value.ToString(), out var list);
|
||||
if (list == null)
|
||||
{
|
||||
list = [];
|
||||
info.PropTriggerCustomString.Add(value.ToString(), list);
|
||||
}
|
||||
|
||||
list.Add(ID);
|
||||
}
|
||||
else if (key.ToString().Contains("Door") ||
|
||||
key.ToString().Contains("Bridge") ||
|
||||
key.ToString().Contains("UnlockTarget") ||
|
||||
key.ToString().Contains("Rootcontamination") ||
|
||||
key.ToString().Contains("Portal"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UnlockDoorID.ContainsKey(int.Parse(value.ToString().Split(",")[0])) == false)
|
||||
UnlockDoorID.Add(int.Parse(value.ToString().Split(",")[0]), []);
|
||||
UnlockDoorID[int.Parse(value.ToString().Split(",")[0])]
|
||||
.Add(int.Parse(value.ToString().Split(",")[1]));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (key.ToString().Contains("Controller"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UnlockControllerID.ContainsKey(int.Parse(value.ToString().Split(",")[0])) == false)
|
||||
UnlockControllerID.Add(int.Parse(value.ToString().Split(",")[0]), []);
|
||||
UnlockControllerID[int.Parse(value.ToString().Split(",")[0])]
|
||||
.Add(int.Parse(value.ToString().Split(",")[1]));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PropValueSource
|
||||
{
|
||||
public List<JObject> Values { get; set; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user