Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.Prefabs.WorldExtensions Class Reference

Extension methods to help manage prefabs More...

Static Public Member Functions

static IPrefab CreatePrefab (this IWorldReadonly world, Vector3i pos, Size3i size, Vector3i center)
 Create a prefab from a position in the world More...
 
static IPrefab CreatePrefab (this IWorldReadonly world, Vector3i pos, Size3i size)
 Create a prefab from a position in the world More...
 
static PrefabInstance ConstructPrefab (this IWorldReadonly world, IReadonlyPrefab prefab, Vector3i pos)
 Construct a prefab within the world at a position More...
 

Detailed Description

Extension methods to help manage prefabs

Member Function Documentation

static PrefabInstance essentials.Prefabs.WorldExtensions.ConstructPrefab ( this IWorldReadonly  world,
IReadonlyPrefab  prefab,
Vector3i  pos 
)
static

Construct a prefab within the world at a position

Returns
The prefab.
Parameters
worldWorld.
prefabPrefab.
posPosition.
56  {
57  var inst = prefab.CreateInstance(pos);
58  inst.Construct();
59  return inst;
60  }
static IPrefab essentials.Prefabs.WorldExtensions.CreatePrefab ( this IWorldReadonly  world,
Vector3i  pos,
Size3i  size,
Vector3i  center 
)
static

Create a prefab from a position in the world

Returns
The prefab.
Parameters
worldWorld.
posPosition.
sizeSize.
centerCenter.

Attribute: x,y,z] = world[new Vector3i(x,y,z) - center + pos

.Id;

21  {
22  var prefab = new Prefab(size, center);
23  for (int x=0; x<size.Width; ++x)
24  {
25  for (int y=0; y<size.Length; ++y)
26  {
27  for (int z=0; z<size.Height; ++z)
28  {
29  prefab[x,y,z] = world[new Vector3i(x,y,z) - center + pos].Id;
30  }
31  }
32  }
33  return prefab;
34  }
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
int Height
Definition: Size3i.cs:7
int Width
Definition: Size3i.cs:7
int Length
Definition: Size3i.cs:7
static IPrefab essentials.Prefabs.WorldExtensions.CreatePrefab ( this IWorldReadonly  world,
Vector3i  pos,
Size3i  size 
)
static

Create a prefab from a position in the world

Returns
The prefab.
Parameters
worldWorld.
posPosition.
sizeSize.
44  {
45  return CreatePrefab(world, pos, size, Vector3i.Zero);
46  }
static IPrefab CreatePrefab(this IWorldReadonly world, Vector3i pos, Size3i size, Vector3i center)
Create a prefab from a position in the world
Definition: WorldExtensions.cs:20
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
static readonly Vector3i Zero
Vector (0,0,0)
Definition: Vector3i.cs:59

The documentation for this class was generated from the following file: