Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
113
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Cube3D.cs
Normal file
113
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Cube3D.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
public class Cube3D : Shape3D
|
||||
{
|
||||
private int _Radius;
|
||||
private bool _Hollow;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Radius
|
||||
{
|
||||
get => _Radius;
|
||||
set
|
||||
{
|
||||
if (_Radius == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Radius = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public bool Hollow
|
||||
{
|
||||
get => _Hollow;
|
||||
set
|
||||
{
|
||||
if (_Hollow == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Hollow = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Cube3D(int radius)
|
||||
: this(Point3D.Zero, radius)
|
||||
{ }
|
||||
|
||||
public Cube3D(IPoint3D center, int radius)
|
||||
: this(center, radius, false)
|
||||
{ }
|
||||
|
||||
public Cube3D(IPoint3D center, int radius, bool hollow)
|
||||
: base(center)
|
||||
{
|
||||
_Radius = radius;
|
||||
_Hollow = hollow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This cube always has an odd width, height and depth, never even.
|
||||
/// This preserves the center point.
|
||||
/// </summary>
|
||||
protected override void OnRender()
|
||||
{
|
||||
const int h = 5;
|
||||
|
||||
for (var z = -Radius; z <= Radius; z++)
|
||||
{
|
||||
for (var x = -Radius; x <= Radius; x++)
|
||||
{
|
||||
for (var y = -Radius; y <= Radius; y++)
|
||||
{
|
||||
if (!Hollow || (z == -Radius || z == Radius || x == -Radius || x == Radius || y == -Radius || y == Radius))
|
||||
{
|
||||
Add(new Block3D(Center.Clone3D(x, y, z * h), h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_Radius);
|
||||
writer.Write(_Hollow);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_Radius = reader.ReadInt();
|
||||
_Hollow = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
148
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Cylinder3D.cs
Normal file
148
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Cylinder3D.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
public class Cylinder3D : Shape3D
|
||||
{
|
||||
private int _Radius;
|
||||
private bool _Hollow;
|
||||
private bool _EndCaps;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Radius
|
||||
{
|
||||
get => _Radius;
|
||||
set
|
||||
{
|
||||
if (_Radius == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Radius = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public bool Hollow
|
||||
{
|
||||
get => _Hollow;
|
||||
set
|
||||
{
|
||||
if (_Hollow == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Hollow = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public bool EndCaps
|
||||
{
|
||||
get => _EndCaps;
|
||||
set
|
||||
{
|
||||
if (_EndCaps == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_EndCaps = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Cylinder3D(int radius)
|
||||
: this(Point3D.Zero, radius)
|
||||
{ }
|
||||
|
||||
public Cylinder3D(IPoint3D center, int radius)
|
||||
: this(center, radius, false)
|
||||
{ }
|
||||
|
||||
public Cylinder3D(IPoint3D center, int radius, bool hollow)
|
||||
: this(center, radius, hollow, true)
|
||||
{
|
||||
Hollow = hollow;
|
||||
}
|
||||
|
||||
public Cylinder3D(IPoint3D center, int radius, bool hollow, bool endCaps)
|
||||
: base(center)
|
||||
{
|
||||
_Radius = radius;
|
||||
_Hollow = hollow;
|
||||
_EndCaps = endCaps;
|
||||
}
|
||||
|
||||
public Cylinder3D(GenericReader reader)
|
||||
: base(reader)
|
||||
{ }
|
||||
|
||||
protected override void OnRender()
|
||||
{
|
||||
const int h = 5;
|
||||
|
||||
for (var z = -Radius; z <= Radius; z++)
|
||||
{
|
||||
if (Hollow && !EndCaps && (z == -Radius || z == Radius))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var x = -Radius; x <= Radius; x++)
|
||||
{
|
||||
for (var y = -Radius; y <= Radius; y++)
|
||||
{
|
||||
var dist = (int)Math.Sqrt(x * x + y * y);
|
||||
|
||||
if ((!Hollow || z == -Radius || z == Radius || dist >= Radius) && dist <= Radius)
|
||||
{
|
||||
Add(new Block3D(Center.Clone3D(x, y, z * h), h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_Radius);
|
||||
writer.Write(_Hollow);
|
||||
writer.Write(_EndCaps);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_Radius = reader.ReadInt();
|
||||
_Hollow = reader.ReadBool();
|
||||
_EndCaps = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Disc3D.cs
Normal file
114
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Disc3D.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
public class Disc3D : Shape3D
|
||||
{
|
||||
private int _Radius;
|
||||
private bool _Hollow;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Radius
|
||||
{
|
||||
get => _Radius;
|
||||
set
|
||||
{
|
||||
if (_Radius == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Radius = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public bool Hollow
|
||||
{
|
||||
get => _Hollow;
|
||||
set
|
||||
{
|
||||
if (_Hollow == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Hollow = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Disc3D(int radius)
|
||||
: this(Point3D.Zero, radius)
|
||||
{ }
|
||||
|
||||
public Disc3D(IPoint3D center, int radius)
|
||||
: this(center, radius, false)
|
||||
{ }
|
||||
|
||||
public Disc3D(IPoint3D center, int radius, bool hollow)
|
||||
: base(center)
|
||||
{
|
||||
_Radius = radius;
|
||||
_Hollow = hollow;
|
||||
}
|
||||
|
||||
public Disc3D(GenericReader reader)
|
||||
: base(reader)
|
||||
{ }
|
||||
|
||||
protected override void OnRender()
|
||||
{
|
||||
const int h = 5;
|
||||
|
||||
for (var x = -Radius; x <= Radius; x++)
|
||||
{
|
||||
for (var y = -Radius; y <= Radius; y++)
|
||||
{
|
||||
var dist = (int)Math.Sqrt(x * x + y * y);
|
||||
|
||||
if ((!Hollow || dist >= Radius) && dist <= Radius)
|
||||
{
|
||||
Add(new Block3D(Center.Clone3D(x, y), h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_Radius);
|
||||
writer.Write(_Hollow);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_Radius = reader.ReadInt();
|
||||
_Hollow = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
110
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Plane3D.cs
Normal file
110
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Plane3D.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
public class Plane3D : Shape3D
|
||||
{
|
||||
private int _Radius;
|
||||
private bool _Hollow;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Radius
|
||||
{
|
||||
get => _Radius;
|
||||
set
|
||||
{
|
||||
if (_Radius == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Radius = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public bool Hollow
|
||||
{
|
||||
get => _Hollow;
|
||||
set
|
||||
{
|
||||
if (_Hollow == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Hollow = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Plane3D(int radius)
|
||||
: this(Point3D.Zero, radius)
|
||||
{ }
|
||||
|
||||
public Plane3D(IPoint3D center, int radius)
|
||||
: this(center, radius, false)
|
||||
{ }
|
||||
|
||||
public Plane3D(IPoint3D center, int radius, bool hollow)
|
||||
: base(center)
|
||||
{
|
||||
_Radius = radius;
|
||||
_Hollow = hollow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This plane always has an odd width, height and depth, never even.
|
||||
/// This preserves the center point.
|
||||
/// </summary>
|
||||
protected override void OnRender()
|
||||
{
|
||||
const int h = 5;
|
||||
|
||||
for (var x = -Radius; x <= Radius; x++)
|
||||
{
|
||||
for (var y = -Radius; y <= Radius; y++)
|
||||
{
|
||||
if (!Hollow || (x == -Radius || x == Radius || y == -Radius || y == Radius))
|
||||
{
|
||||
Add(new Block3D(Center.Clone3D(x, y), h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_Radius);
|
||||
writer.Write(_Hollow);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_Radius = reader.ReadInt();
|
||||
_Hollow = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Ring3D.cs
Normal file
121
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Ring3D.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
public class Ring3D : Shape3D
|
||||
{
|
||||
private int _RadiusMin;
|
||||
private int _RadiusMax;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int RadiusMin
|
||||
{
|
||||
get => _RadiusMin;
|
||||
set
|
||||
{
|
||||
if (_RadiusMin == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_RadiusMin = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int RadiusMax
|
||||
{
|
||||
get => _RadiusMax;
|
||||
set
|
||||
{
|
||||
if (_RadiusMax == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_RadiusMax = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Ring3D(int radius)
|
||||
: this(radius, radius)
|
||||
{ }
|
||||
|
||||
public Ring3D(int radiusMin, int radiusMax)
|
||||
: this(Point3D.Zero, radiusMin, radiusMax)
|
||||
{ }
|
||||
|
||||
public Ring3D(IPoint3D center, int radius)
|
||||
: this(center, radius, radius)
|
||||
{ }
|
||||
|
||||
public Ring3D(IPoint3D center, int radiusMin, int radiusMax)
|
||||
: base(center)
|
||||
{
|
||||
_RadiusMin = Math.Min(radiusMin, radiusMax);
|
||||
_RadiusMax = Math.Max(radiusMin, radiusMax);
|
||||
}
|
||||
|
||||
public Ring3D(GenericReader reader)
|
||||
: base(reader)
|
||||
{ }
|
||||
|
||||
protected override void OnRender()
|
||||
{
|
||||
var min = Math.Min(RadiusMin, RadiusMax);
|
||||
var max = Math.Max(RadiusMin, RadiusMax);
|
||||
|
||||
const int h = 5;
|
||||
|
||||
for (var x = -max; x <= max; x++)
|
||||
{
|
||||
for (var y = -max; y <= max; y++)
|
||||
{
|
||||
var dist = (int)Math.Sqrt(x * x + y * y);
|
||||
|
||||
if (dist >= min && dist <= max)
|
||||
{
|
||||
Add(new Block3D(Center.Clone3D(x, y), h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_RadiusMin);
|
||||
writer.Write(_RadiusMax);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_RadiusMin = reader.ReadInt();
|
||||
_RadiusMax = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
276
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Shape3D.cs
Normal file
276
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Shape3D.cs
Normal file
@@ -0,0 +1,276 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
[PropertyObject]
|
||||
public abstract class Shape3D : DynamicWireframe, IPoint3D
|
||||
{
|
||||
private bool _InitialRender;
|
||||
|
||||
public override List<Block3D> Blocks
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
return base.Blocks;
|
||||
}
|
||||
set => base.Blocks = value;
|
||||
}
|
||||
|
||||
public override int Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
return base.Volume;
|
||||
}
|
||||
}
|
||||
|
||||
protected Point3D _Center;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public Point3D Center
|
||||
{
|
||||
get => _Center;
|
||||
set
|
||||
{
|
||||
if (_Center == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Center = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int X
|
||||
{
|
||||
get => _Center.X;
|
||||
set
|
||||
{
|
||||
if (_Center.X == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Center.X = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Y
|
||||
{
|
||||
get => _Center.Y;
|
||||
set
|
||||
{
|
||||
if (_Center.Z == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Center.Y = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Z
|
||||
{
|
||||
get => _Center.Z;
|
||||
set
|
||||
{
|
||||
if (_Center.Z == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Center.Z = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Shape3D()
|
||||
: this(Point3D.Zero)
|
||||
{ }
|
||||
|
||||
public Shape3D(IPoint3D center)
|
||||
{
|
||||
_Center = center.Clone3D();
|
||||
}
|
||||
|
||||
public Shape3D(GenericReader reader)
|
||||
: base(reader)
|
||||
{ }
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (Rendering)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_InitialRender = Rendering = true;
|
||||
|
||||
Clear();
|
||||
OnRender();
|
||||
|
||||
Rendering = false;
|
||||
}
|
||||
|
||||
protected abstract void OnRender();
|
||||
|
||||
public override void Add(Block3D item)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base.Add(item);
|
||||
}
|
||||
|
||||
public override void AddRange(IEnumerable<Block3D> collection)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base.AddRange(collection);
|
||||
}
|
||||
|
||||
public override bool Remove(Block3D item)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
return base.Remove(item);
|
||||
}
|
||||
|
||||
public override int RemoveAll(Predicate<Block3D> match)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
return base.RemoveAll(match);
|
||||
}
|
||||
|
||||
public override void RemoveAt(int index)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base.RemoveAt(index);
|
||||
}
|
||||
|
||||
public override void RemoveRange(int index, int count)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base.RemoveRange(index, count);
|
||||
}
|
||||
|
||||
public override void ForEach(Action<Block3D> action)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base.ForEach(action);
|
||||
}
|
||||
|
||||
public override IEnumerator<Block3D> GetEnumerator()
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
return base.GetEnumerator();
|
||||
}
|
||||
|
||||
public override Block3D this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
return base[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
if (!_InitialRender)
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_Center);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
_InitialRender = true;
|
||||
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_Center = reader.ReadPoint3D();
|
||||
}
|
||||
}
|
||||
}
|
||||
136
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Sphere3D.cs
Normal file
136
Scripts/SubSystem/VitaNex/Core/Geometry/Shapes/Sphere3D.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
#region Header
|
||||
// _,-'/-'/
|
||||
// . __,-; ,'( '/
|
||||
// \. `-.__`-._`:_,-._ _ , . ``
|
||||
// `:-._,------' ` _,`--` -: `_ , ` ,' :
|
||||
// `---..__,,--' (C) 2023 ` -'. -'
|
||||
// # Vita-Nex [http://core.vita-nex.com] #
|
||||
// {o)xxx|===============- # -===============|xxx(o}
|
||||
// # #
|
||||
#endregion
|
||||
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace VitaNex.Geometry
|
||||
{
|
||||
public class Sphere3D : Shape3D
|
||||
{
|
||||
private int _Radius;
|
||||
private bool _Hollow;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int Radius
|
||||
{
|
||||
get => _Radius;
|
||||
set
|
||||
{
|
||||
if (_Radius == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Radius = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public bool Hollow
|
||||
{
|
||||
get => _Hollow;
|
||||
set
|
||||
{
|
||||
if (_Hollow == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_Hollow = value;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
public Sphere3D(int radius)
|
||||
: this(Point3D.Zero, radius)
|
||||
{ }
|
||||
|
||||
public Sphere3D(IPoint3D center, int radius)
|
||||
: this(center, radius, false)
|
||||
{ }
|
||||
|
||||
public Sphere3D(IPoint3D center, int radius, bool hollow)
|
||||
: base(center)
|
||||
{
|
||||
_Radius = radius;
|
||||
_Hollow = hollow;
|
||||
}
|
||||
|
||||
public Sphere3D(GenericReader reader)
|
||||
: base(reader)
|
||||
{ }
|
||||
|
||||
protected override void OnRender()
|
||||
{
|
||||
const int h = 5;
|
||||
|
||||
var layers = Radius * 2;
|
||||
|
||||
for (var z = -layers; z <= layers; z++)
|
||||
{
|
||||
var p = z / Math.Max(1.0, layers);
|
||||
|
||||
var r = 2 * Radius;
|
||||
|
||||
if (p < 0.5)
|
||||
{
|
||||
r = (int)Math.Ceiling(r * p);
|
||||
}
|
||||
else if (p > 0.5)
|
||||
{
|
||||
r = (int)Math.Ceiling(r - (r * p));
|
||||
}
|
||||
else
|
||||
{
|
||||
r = Radius;
|
||||
}
|
||||
|
||||
for (var x = -r; x <= r; x++)
|
||||
{
|
||||
for (var y = -r; y <= r; y++)
|
||||
{
|
||||
var dist = (int)Math.Sqrt(x * x + y * y);
|
||||
|
||||
if ((!Hollow || z == -layers || z == layers || dist >= r) && dist <= r)
|
||||
{
|
||||
Add(new Block3D(Center.Clone3D(x, y, z * h), h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.SetVersion(0);
|
||||
|
||||
writer.Write(_Radius);
|
||||
writer.Write(_Hollow);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.GetVersion();
|
||||
|
||||
_Radius = reader.ReadInt();
|
||||
_Hollow = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user