This commit is contained in:
/
2024-12-29 21:15:58 +01:00
commit 547655c326
77 changed files with 7313 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System.Collections.Generic;
using Global.Shared.API;
using Global.Shared.Plugin;
using Sandbox.Game.Entities;
using Sandbox.Game.Entities.Character;
using VRage.Game.Components;
using VRageMath;
namespace Global.Shared.OcTree.Data
{
public class ControllableEntityData : IControllableEntityData, IOcTreeData
{
public ControllableEntityData(IMyControllableEntity entity)
{
Entity = entity;
Id = entity.Entity.EntityId;
Recompute();
entity.Entity.PositionComp.OnPositionChanged += PositionChanged;
}
public IMyControllableEntity Entity { get; set; }
public long Id { get; }
public List<long> ChildIds { get; } = new List<long>();
public long Flags { get; private set; }
public BoundingBoxD BoundingBox { get; private set; }
public void Recompute()
{
Flags = PlayerFlag.None;
Flags |= Entity is MyCharacter ? PlayerFlag.Character : PlayerFlag.Controlled;
BoundingBox = Entity.Entity.PositionComp.WorldAABB;
}
public void Update()
{
Recompute();
}
public void Dispose()
{
Entity.Entity.PositionComp.OnPositionChanged -= PositionChanged;
Entity = null;
BoundingBox = default;
}
private void PositionChanged(MyPositionComponentBase obj)
{
GlobalStatic.OcTreeHandler.CharacterTree.Update(Id);
}
}
}