mirror of
https://git.muiegratis.online/suikoakari/Campofinale
synced 2025-12-12 17:44:37 +01:00
61 lines
2.3 KiB
C#
61 lines
2.3 KiB
C#
using Campofinale.Game.Entities;
|
|
using Campofinale.Network;
|
|
using Campofinale.Protocol;
|
|
using static Campofinale.Resource.ResourceManager;
|
|
|
|
namespace Campofinale.Packets.Cs
|
|
{
|
|
public class HandleCsSceneSetSafeZone
|
|
{
|
|
|
|
[Server.Handler(CsMsgId.CsSceneSetSafeZone)]
|
|
public static void Handle(Player session, CsMsgId cmdId, Packet packet)
|
|
{
|
|
CsSceneSetSafeZone req = packet.DecodeBody<CsSceneSetSafeZone>();
|
|
|
|
if (req.InZone)
|
|
{
|
|
var entity = session.sceneManager.GetEntity(req.Id) as EntityInteractive;
|
|
if (entity != null)
|
|
{
|
|
Vector3f position = new();
|
|
Vector3f rotation = new();
|
|
foreach(var i in entity.properties)
|
|
{
|
|
var val = i.ToProto();
|
|
switch(i.key)
|
|
{
|
|
case "position":
|
|
position = new()
|
|
{
|
|
x = val.ValueFloatList[0],
|
|
y = val.ValueFloatList[1],
|
|
z = val.ValueFloatList[2]
|
|
};
|
|
break;
|
|
case "rotation":
|
|
rotation = new()
|
|
{
|
|
x = val.ValueFloatList[0],
|
|
y = val.ValueFloatList[1],
|
|
z = val.ValueFloatList[2]
|
|
};
|
|
|
|
break;
|
|
}
|
|
}
|
|
Logger.Print($"Set safe zone for player {session.accountId} to (sceneNum:{entity.sceneNumId} position:{position.ToProto()} rotation:{rotation.ToProto()})");
|
|
session.savedSaveZone.sceneNumId = entity.sceneNumId;
|
|
session.savedSaveZone.position = position;
|
|
session.savedSaveZone.rotation = rotation;
|
|
}
|
|
else
|
|
Logger.PrintError($"Cannot find Waypoint entity with ID {req.Id}");
|
|
}
|
|
|
|
Logger.Print($"CsSceneSetSafeZone:" + req.ToString());
|
|
}
|
|
|
|
}
|
|
}
|