diff --git a/Campofinale/Game/Entities/Entity.cs b/Campofinale/Game/Entities/Entity.cs index 4cb04aa..264e3f1 100644 --- a/Campofinale/Game/Entities/Entity.cs +++ b/Campofinale/Game/Entities/Entity.cs @@ -21,6 +21,7 @@ namespace Campofinale.Game.Entities public List properties=new(); public int sceneNumId; public bool spawned = false; + public bool defaultHide = false; public Entity() { diff --git a/Campofinale/Game/Entities/EntityInteractive.cs b/Campofinale/Game/Entities/EntityInteractive.cs index c543430..9034815 100644 --- a/Campofinale/Game/Entities/EntityInteractive.cs +++ b/Campofinale/Game/Entities/EntityInteractive.cs @@ -14,6 +14,7 @@ namespace Campofinale.Game.Entities { } + public EntityInteractive(string templateId, ulong worldOwner, Vector3f pos, Vector3f rot, int scene, ulong g=0) { if (g == 0) @@ -86,6 +87,7 @@ namespace Campofinale.Game.Entities (bool, int) index = GetPropertyIndex(prop.key, proto.Properties.Keys.Count > 0 ? proto.Properties.Keys.Max() : 0); if (p != null && index.Item1) { + if(!proto.Properties.ContainsKey(index.Item2)) proto.Properties.Add(index.Item2, p); } diff --git a/Campofinale/Game/SceneManager.cs b/Campofinale/Game/SceneManager.cs index 3e3ad7c..d66768f 100644 --- a/Campofinale/Game/SceneManager.cs +++ b/Campofinale/Game/SceneManager.cs @@ -253,6 +253,8 @@ namespace Campofinale.Game public List entities = new(); [BsonIgnore, JsonIgnore] public bool alreadyLoaded = false; + [BsonIgnore, JsonIgnore] + public List activeScripts = new(); public int GetCollection(string id) { if (collections.ContainsKey(id)) @@ -379,53 +381,35 @@ namespace Campofinale.Game } public void SpawnEntity(Entity en,bool spawnedCheck=true) { + if (!activeScripts.Contains(en.belongLevelScriptId) && en.defaultHide && en.belongLevelScriptId != 0) + { + return; + } en.spawned = true; - List toSpawn = new List(); - toSpawn.Add(en); - foreach (Entity e in GetEntityExcludingChar().FindAll(e => e.belongLevelScriptId == en.belongLevelScriptId && e.spawned == false)) + ParamKeyValue targetList=en.properties.Find(p => p.key == "target_list"); + if(targetList!=null) + foreach (Entity e in GetEntityExcludingChar().FindAll(e=>e.spawned == false && targetList.value.valueArray.Any(v=>v.valueBit64== (long)e.levelLogicId))) { - e.spawned = true; - toSpawn.Add(e); + SpawnEntity(e); } - /*if(en.belongLevelScriptId != 0) - if (spawnedCheck) - { - foreach (Entity e in GetEntityExcludingChar().FindAll(e => e.belongLevelScriptId == en.belongLevelScriptId && e.spawned == false && e.Position.Distance(GetOwner().position) < 100)) - { - e.spawned = true; - toSpawn.Add(e); - } - } - else - { - foreach (Entity e in GetEntityExcludingChar().FindAll(e => e.belongLevelScriptId == en.belongLevelScriptId && e != en)) - { - e.spawned = true; - toSpawn.Add(e); - - } - }*/ - - toSpawn.ForEach(e => - { - GetOwner().Send(new PacketScObjectEnterView(GetOwner(), new List() { e})); - }); + GetOwner().Send(new PacketScObjectEnterView(GetOwner(), new List() { en})); } public void UpdateShowEntities() { foreach(Entity en in GetEntityExcludingChar()) { - float minDis = en is EntityInteractive ? 180 : 50; + float minDis = 100; + //todo new system if (en.Position.DistanceXZ(GetOwner().position) < minDis) { if (!en.spawned) { SpawnEntity(en); - - + + } } else diff --git a/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs b/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs index fe8532c..8c90662 100644 --- a/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs +++ b/Campofinale/Packets/Cs/HandleCsSceneSetLevelScriptActive.cs @@ -25,7 +25,13 @@ namespace Campofinale.Packets.Cs State = 3 }; + + if (!session.sceneManager.GetCurScene().activeScripts.Contains(req.ScriptId)) + { + session.sceneManager.GetCurScene().activeScripts.Add(req.ScriptId); + } session.Send(ScMsgId.ScSceneLevelScriptStateNotify, rsp); + } @@ -45,7 +51,7 @@ namespace Campofinale.Packets.Cs State = 4 }; - + session.Send(ScMsgId.ScSceneLevelScriptStateNotify, rsp,packet.csHead.UpSeqid); } @@ -69,6 +75,15 @@ namespace Campofinale.Packets.Cs UnlockSystemType type = (UnlockSystemType)Enum.Parse(typeof(UnlockSystemType), action.valueStr[0]); player.UnlockSystem(type); break; + case ScriptActionType.EnterScene: + player.EnterScene((int)action.valueUlong[0]); + break; + case ScriptActionType.AddMission: + player.missionSystem.AddMission(action.valueStr[0]); + break; + case ScriptActionType.CompleteMission: + //player.missionSystem.C(action.valueStr[0]); + break; default: Logger.PrintWarn("Script Action not implemented"); break; diff --git a/Campofinale/Resource/Table/LevelScriptEvent.cs b/Campofinale/Resource/Table/LevelScriptEvent.cs index 3ba79db..e57fc4a 100644 --- a/Campofinale/Resource/Table/LevelScriptEvent.cs +++ b/Campofinale/Resource/Table/LevelScriptEvent.cs @@ -26,6 +26,8 @@ namespace Campofinale.Resource.Table ProcessQuest = 2, SpawnEnemy = 3, UnlockSystem = 4, - + EnterScene = 5, + AddMission = 6, + CompleteMission = 7, } } diff --git a/Dotfuscator1.xml b/Dotfuscator1.xml new file mode 100644 index 0000000..44bfed3 --- /dev/null +++ b/Dotfuscator1.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file