Files
BITFALL/Assets/Artists/Scripts/Entity/KinematicMovement/MovementService.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2023-06-08 14:09:50 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text;
using Net.Client;
using BITKit;
using BITKit.Entities;
using BITKit.SubSystems;
using Net.Share;
namespace BITFALL
{
public class MovementService : SubBITSystem
{
public override void OnCreate()
{
BITNet.AddRpcHandle(this);
}
[Rpc]
public void SyncMovement(int entityId, Net.Vector3 currentVelocity, Net.Vector3 currentPos,Net.Quaternion currentRot,bool isGrounded)
{
try
{
EntitiesManager
.GetOrAdd(entityId)
.Get<IEntityMovement>()
.SyncMovement(currentVelocity, currentPos, currentRot,isGrounded);
}
catch (System.Exception e)
{
StringBuilder stringBuilder = new();
var entity = EntitiesManager.GetOrAdd(entityId);
stringBuilder.AppendLine($"Entity:{entityId}@{entity}");
var movement = entity.Get<IEntityMovement>();
stringBuilder.AppendLine($"Movement@{movement}");
BIT4Log.Warnning(stringBuilder);
Debug.LogException(e);
}
}
}
}