mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Squashed commit of the following: commit fd22196a5e93ef3b1e83696900475f674f6f285b Merge: 1b6aa6acab051129b5Author: Ty Conner <tyconner@itcproductions.com> Date: Fri Nov 19 18:56:09 2021 -0500 Merge branch 'master' into telev2 commit 1b6aa6aca8fff594d380643a3c704d295f1d509c Merge: d0645c74b9d915f069Author: Ty Conner <tyconner@itcproductions.com> Date: Wed Aug 11 17:26:54 2021 -0400 Merge branch 'master' into telev2 commit d0645c74bc6dfc45fd35f720bf758fa2c71c16c9 Merge: d7c31f9ebefef90444Author: Ty Conner <tyconner@itcproductions.com> Date: Tue Mar 2 01:31:50 2021 -0500 Merge master commit d7c31f9eb764d64f69140ddc25ee4d687546f68f Author: Ty Conner <tyconner@itcproductions.com> Date: Tue Mar 2 00:27:25 2021 -0500 .. commit 0f1ae29b917af3440d7e1512dbb758544b4a1233 Author: Ty Conner <tyconner@itcproductions.com> Date: Sat Feb 20 17:15:59 2021 -0500 . commit 883a34bef979ec96f52bd4a1534cc33267419ec2 Author: Ty Conner <tyconner@itcproductions.com> Date: Fri Sep 18 13:41:08 2020 -0400 hardcoded vloc.txt output commit 87915f70ff3bbb826d44e98069be078123083561 Merge: 61f026059599c865f5Author: Ty Conner <tyconner@itcproductions.com> Date: Sun Sep 13 14:23:26 2020 -0400 Merge branch 'master' into telev commit 61f0260594928540b5f3fc73223b71630c63d301 Merge: 854b7fcae0ec7ddca9Author: Ty Conner <tyconner@itcproductions.com> Date: Thu Sep 10 03:17:06 2020 -0400 Merge branch 'master' into telev commit 854b7fcae5d546cae3a0a6b7e6b7ab29803d292c Author: Ty Conner <tyconner@itcproductions.com> Date: Tue Sep 8 18:59:07 2020 -0400 . commit 3f9c8f9914879a5c241a0ca256ae9d68fc99f1d7 Author: Ty Conner <tyconner@itcproductions.com> Date: Sun Aug 30 17:48:43 2020 -0400 Add `telev` command * Wire up vloc2loc command * Update PositionExtensions.cs * Update DeveloperContentCommands.cs
158 lines
5 KiB
C#
158 lines
5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using ACE.DatLoader.Entity;
|
|
using ACE.Server.Physics.Animation;
|
|
|
|
namespace ACE.Server.Physics.Common
|
|
{
|
|
public class BuildingObj : PhysicsObj
|
|
{
|
|
public List<EnvCell> BuildingCells;
|
|
public List<BldPortal> Portals;
|
|
public List<PartCell> LeafCells;
|
|
public List<ShadowPart> ShadowList;
|
|
public uint NumLeaves;
|
|
|
|
public uint LandblockID { get => CurCell.ID | 0xFFFF; }
|
|
|
|
public BuildingObj() : base()
|
|
{
|
|
Portals = new List<BldPortal>();
|
|
LeafCells = new List<PartCell>();
|
|
ShadowList = new List<ShadowPart>();
|
|
}
|
|
|
|
public void add_to_cell(SortCell newCell)
|
|
{
|
|
newCell.add_building(this);
|
|
set_cell_id(newCell.ID);
|
|
CurCell = newCell;
|
|
}
|
|
|
|
public void add_to_stablist(ref List<ushort> blockStabList, ref uint maxSize, ref uint stabNum)
|
|
{
|
|
foreach (var portal in Portals)
|
|
portal.add_to_stablist(ref blockStabList, ref maxSize, ref stabNum);
|
|
}
|
|
|
|
public TransitionState find_building_collisions(Transition transition)
|
|
{
|
|
if (PartArray == null)
|
|
return TransitionState.OK;
|
|
|
|
transition.SpherePath.BuildingCheck = true;
|
|
var transitionState = PartArray.Parts[0].FindObjCollisions(transition);
|
|
transition.SpherePath.BuildingCheck = false;
|
|
|
|
if (transitionState != TransitionState.OK && !transition.ObjectInfo.State.HasFlag(ObjectInfoState.Contact))
|
|
transition.CollisionInfo.CollidedWithEnvironment = true;
|
|
|
|
return transitionState;
|
|
}
|
|
|
|
public void find_building_transit_cells(Position pos, int numSphere, List<Sphere> sphere, CellArray cellArray, SpherePath path)
|
|
{
|
|
foreach (var portal in Portals)
|
|
{
|
|
var otherCell = portal.GetOtherCell(CurCell.ID);
|
|
if (otherCell != null)
|
|
otherCell.check_building_transit(portal.OtherPortalId, pos, numSphere, sphere, cellArray, path);
|
|
}
|
|
}
|
|
|
|
public void find_building_transit_cells(int numParts, List<PhysicsPart> parts, CellArray cellArray)
|
|
{
|
|
foreach (var portal in Portals)
|
|
{
|
|
var otherCell = portal.GetOtherCell(CurCell.ID);
|
|
if (otherCell != null)
|
|
otherCell.check_building_transit(portal.OtherPortalId, numParts, parts, cellArray);
|
|
}
|
|
}
|
|
|
|
public List<EnvCell> get_building_cells()
|
|
{
|
|
if (BuildingCells != null) return BuildingCells;
|
|
|
|
BuildingCells = new List<EnvCell>();
|
|
|
|
// entry points into the building,
|
|
// aka cells touching the outdoor landblock
|
|
foreach (var portal in Portals)
|
|
{
|
|
var entrypoint = portal.GetOtherCell(LandblockID);
|
|
add_cells_recursive(entrypoint);
|
|
}
|
|
return BuildingCells;
|
|
}
|
|
|
|
public void add_cells_recursive(EnvCell cell)
|
|
{
|
|
if (cell == null || BuildingCells.Contains(cell)) return;
|
|
|
|
BuildingCells.Add(cell);
|
|
|
|
foreach (var visibleCell in cell.VisibleCells.Values)
|
|
add_cells_recursive(visibleCell);
|
|
}
|
|
|
|
public PhysicsObj get_object(int objectID)
|
|
{
|
|
// visited cells?
|
|
return null;
|
|
}
|
|
|
|
public static BuildingObj makeBuilding(uint buildingID, List<CBldPortal> portals, uint numLeaves)
|
|
{
|
|
var building = new BuildingObj();
|
|
|
|
if (!building.InitObjectBegin(0, false) || !building.InitPartArrayObject(buildingID, true))
|
|
return null;
|
|
|
|
building.ID = buildingID;
|
|
|
|
building.NumLeaves = numLeaves;
|
|
building.LeafCells = new List<PartCell>();
|
|
for (var i = 0; i < numLeaves; i++)
|
|
building.LeafCells.Add(null);
|
|
|
|
building.Portals = new List<BldPortal>();
|
|
foreach (var portal in portals)
|
|
building.Portals.Add(new BldPortal(portal));
|
|
|
|
if (!building.InitObjectEnd())
|
|
return null;
|
|
|
|
return building;
|
|
}
|
|
|
|
public float GetMinZ()
|
|
{
|
|
get_building_cells();
|
|
|
|
var minZ = float.MaxValue;
|
|
|
|
foreach (var buildingCell in BuildingCells.Where(i => i.Environment != null))
|
|
{
|
|
if (buildingCell.Environment == null) continue;
|
|
|
|
foreach (var cellStruct in buildingCell.Environment.Cells.Values)
|
|
{
|
|
foreach (var vertex in cellStruct.VertexArray.Vertices.Values)
|
|
if (vertex.Origin.Z < minZ)
|
|
minZ = vertex.Origin.Z;
|
|
}
|
|
}
|
|
return minZ;
|
|
}
|
|
|
|
public void remove()
|
|
{
|
|
var sortCell = (SortCell)CurCell;
|
|
sortCell.remove_building();
|
|
set_cell_id(0);
|
|
CurCell = null;
|
|
}
|
|
}
|
|
}
|