本文整理汇总了C#中Chraft.World.WorldManager类的典型用法代码示例。如果您正苦于以下问题:C# WorldManager类的具体用法?C# WorldManager怎么用?C# WorldManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorldManager类属于Chraft.World命名空间,在下文中一共展示了WorldManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateB
public override void GenerateB(WorldManager world, int i, int j, int k, int l, byte[] abyte0)
{
int i1 = rand.nextInt(rand.nextInt(rand.nextInt(40) + 1) + 1);
if (rand.nextInt(15) != 0)
{
i1 = 0;
}
for (int j1 = 0; j1 < i1; j1++)
{
double d = i * 16 + rand.nextInt(16);
double d1 = rand.nextInt(rand.nextInt(120) + 8);
double d2 = j * 16 + rand.nextInt(16);
int k1 = 1;
if (rand.nextInt(4) == 0)
{
UnknownA(k, l, abyte0, d, d1, d2);
k1 += rand.nextInt(4);
}
for (int l1 = 0; l1 < k1; l1++)
{
float f = rand.nextFloat() * 3.141593F * 2.0F;
float f1 = ((rand.nextFloat() - 0.5F) * 2.0F) / 8F;
float f2 = rand.nextFloat() * 2.0F + rand.nextFloat();
UnknownB(k, l, abyte0, d, d1, d2, f2, f, f1, 0, 0, 1.0D);
}
}
}
示例2: SpawnMobs
public static void SpawnMobs(WorldManager world, bool spawnHostileMobs, bool spawnPeacefulMobs)
{
var players = world.Server.GetAuthenticatedClients().Where(c => c.Owner.World == world).Select(c => c.Owner).ToArray();
HashSet<int> chunksToSpawnIn = new HashSet<int>();
#region Get a list of all chunks within 8 chunks of any players
foreach (var player in players)
{
UniversalCoords coord = UniversalCoords.FromAbsWorld(player.Position);
for (int x = -MaxSpawnDistance; x <= MaxSpawnDistance; x++)
{
for (int z = -MaxSpawnDistance; z <= MaxSpawnDistance; z++)
{
chunksToSpawnIn.Add(UniversalCoords.FromChunkToPackedChunk(coord.ChunkX + x, coord.ChunkZ + z));
}
}
}
#endregion
// Get a list of Mob entities outside of the loop so we only get it once
Mob[] mobEntities = world.GetEntities().Where(e => e is Mob).Select((e) => e as Mob).ToArray();
// TODO: need to use Biome to get the list of mob types available for each category
// TODO: make the maximum count of mobs per category configurable
if (spawnHostileMobs)
{
DoSpawn(world, chunksToSpawnIn, mobEntities, Monsters, MaxMonsters);
}
if (spawnPeacefulMobs)
{
DoSpawn(world, chunksToSpawnIn, mobEntities, Creatures, MaxCreatures);
DoSpawn(world, chunksToSpawnIn, mobEntities, WaterCreatures, MaxWaterCreatures, true);
}
}
示例3: ChunkBase
internal ChunkBase(WorldManager world, int x, int z)
{
World = world;
X = x;
Z = z;
_UpdateTimer = new Timer(UpdateBlocksToNearbyPlayers, null, Timeout.Infinite, Timeout.Infinite);
}
示例4: ProvideChunk
public Chunk ProvideChunk(int x, int z, WorldManager world)
{
Chunk chunk = new Chunk(world, UniversalCoords.FromChunk(x, z));
InitGen();
byte[] data = new byte[32768];
#if PROFILE
Stopwatch watch = new Stopwatch();
watch.Start();
#endif
GenerateTerrain(chunk, data, x, z);
GenerateFlora(chunk, data, x, z);
chunk.SetAllBlocks(data);
chunk.RecalculateHeight();
chunk.LightToRecalculate = true;
#if PROFILE
watch.Stop();
_World.Logger.Log(Logger.LogLevel.Info, "Chunk {0} {1}, {2}", false, x, z, watch.ElapsedMilliseconds);
#endif
_World.AddChunk(chunk);
chunk.MarkToSave();
return chunk;
}
示例5: Ocelot
internal Ocelot(WorldManager world, int entityId, MobType type, MetaData data)
: base(world, entityId, type, data)
{
Data.IsSitting = false;
Data.IsTamed = false;
Data.IsAggressive = false;
FishUntilTamed = Server.Rand.Next(20);
}
示例6: Wolf
internal Wolf(WorldManager world, int entityId, MetaData data = null)
: base(world, entityId, MobType.Wolf, data)
{
Data.IsSitting = false;
Data.IsTamed = false;
Data.IsAggressive = false;
BonesUntilTamed = Server.Rand.Next(10); // How many bones required to tame this wolf?
}
示例7: Mob
protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
: base(world.Server, entityId, data)
{
this.Type = type;
this.World = world;
this.MobUpdateFrequency = 1;
this.Speed = 0.7;
}
示例8: StopBurning
public static void StopBurning(WorldManager world, UniversalCoords coords)
{
string id = String.Format("{0}-{1},{2},{3}", world.Name, coords.WorldX, coords.WorldY, coords.WorldZ);
lock (_staticLock)
{
if (_furnaceInstances.ContainsKey(id))
_furnaceInstances[id].StopBurning();
}
}
示例9: Mob
public Vector3 gotoPos; // Location entity should move towards
#endregion Fields
#region Constructors
protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
: base(world.Server, entityId)
{
if (data == null)
data = new MetaData();
this.Data = data;
this.Type = type;
this.World = world;
this.Health = this.MaxHealth;
}
示例10: Instance
public static PersistentContainer Instance(WorldManager world, UniversalCoords coords)
{
PersistentContainer container;
Chunk chunk = world.GetChunk(coords) as Chunk;
if (chunk == null)
return null;
BlockData.Blocks block = chunk.GetType(coords);
if (!chunk.Containers.ContainsKey(coords.BlockPackedCoords))
{
switch (block)
{
case BlockData.Blocks.Furnace:
case BlockData.Blocks.Burning_Furnace:
container = new FurnaceContainer();
container.Initialize(world, coords);
(container as FurnaceContainer).StartBurning();
break;
case BlockData.Blocks.Dispenser:
container = new DispenserContainer();
container.Initialize(world, coords);
break;
case BlockData.Blocks.Chest:
// Double chest?
if (IsDoubleChest(chunk, coords))
{
UniversalCoords[] doubleChestCoords = GetDoubleChestCoords(world, coords);
if (doubleChestCoords == null)
return null;
chunk.Containers.TryRemove(doubleChestCoords[0].BlockPackedCoords, out container);
chunk.Containers.TryRemove(doubleChestCoords[1].BlockPackedCoords, out container);
container = new LargeChestContainer(doubleChestCoords[1]);
container.Initialize(world, doubleChestCoords[0]);
chunk.Containers.TryAdd(doubleChestCoords[0].BlockPackedCoords, container);
chunk.Containers.TryAdd(doubleChestCoords[1].BlockPackedCoords, container);
}
else
{
container = new SmallChestContainer();
container.Initialize(world, coords);
}
break;
default:
return null;
}
chunk.Containers.TryAdd(coords.BlockPackedCoords, container);
}
else
{
chunk.Containers.TryGetValue(coords.BlockPackedCoords, out container);
}
return container;
}
示例11: Destroy
public static void Destroy(WorldManager world, UniversalCoords coords)
{
PersistentContainer container = Instance(world, coords);
if (container == null)
return;
Chunk chunk = world.GetChunk(coords);
if (chunk == null)
return;
PersistentContainer unused;
container.Destroy();
chunk.Containers.TryRemove(container.Coords.BlockPackedCoords, out unused);
if (container is LargeChestContainer)
chunk.Containers.TryRemove((container as LargeChestContainer).SecondCoords.BlockPackedCoords, out unused);
}
示例12: Initialize
public virtual void Initialize(WorldManager world, UniversalCoords coords)
{
World = world;
Coords = coords;
Slots = new ItemInventory[SlotsCount];
DataFile = string.Format("x{0}y{1}z{2}.dat", Coords.WorldX, Coords.WorldY, Coords.WorldZ);
string chunkFolder = string.Format("x{0}z{1}", Coords.ChunkX, Coords.ChunkZ);
ContainerFolder = Path.Combine(DataPath, chunkFolder);
if (!Directory.Exists(ContainerFolder))
{
Directory.CreateDirectory(ContainerFolder);
}
Load();
}
示例13: GenerateA
public virtual void GenerateA(ChunkGenerator gen, WorldManager world, int x, int z, byte[] data)
{
int radius = field_947_a;
rand.setSeed(world.GetSeed());
long l = (rand.nextLong() / 2L) * 2L + 1L;
long l1 = (rand.nextLong() / 2L) * 2L + 1L;
for (int ix = x - radius; ix <= x + radius; ix++)
{
for (int iz = z - radius; iz <= z + radius; iz++)
{
rand.setSeed((long)ix * l + (long)iz * l1 ^ world.GetSeed());
GenerateB(world, ix, iz, x, z, data);
}
}
}
示例14: Chunk
internal Chunk(WorldManager world, int x, int z)
: base(world, x, z)
{
/*using(StreamWriter sw = new StreamWriter("chunkStack.log", true))
{
sw.WriteLine("Instance: {0}, {1}, Thread: {2}", X, Z, Thread.CurrentThread.ManagedThreadId);
StackTrace stackTrace = new StackTrace(); // get call stack
StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
// write call stack method names
foreach (StackFrame stackFrame in stackFrames)
{
sw.WriteLine(stackFrame.GetMethod().ReflectedType.FullName + "." + stackFrame.GetMethod().Name + " line: {0}", stackFrame.GetFileLineNumber()); // write method name
}
sw.WriteLine("\r\n");
}*/
}
示例15: GetDoubleChestCoords
public static UniversalCoords[] GetDoubleChestCoords(WorldManager world, UniversalCoords coords)
{
Chunk chunk = world.GetChunk(coords);
if (chunk == null || !IsDoubleChest(chunk, coords))
return null;
// Is this chest the "North or East", or the "South or West"
BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
int nsewCount = 0;
byte? blockId;
chunk.ForNSEW(coords, uc =>
{
blockId = world.GetBlockId(uc) ?? 0;
nsewBlocks[nsewCount] = (BlockData.Blocks)blockId;
nsewBlockPositions[nsewCount] = uc;
nsewCount++;
});
UniversalCoords firstCoords;
UniversalCoords secondCoords;
if ((byte)nsewBlocks[0] == (byte)BlockData.Blocks.Chest) // North
{
firstCoords = nsewBlockPositions[0];
secondCoords = coords;
}
else if ((byte)nsewBlocks[2] == (byte)BlockData.Blocks.Chest) // East
{
firstCoords = nsewBlockPositions[2];
secondCoords = coords;
}
else if ((byte)nsewBlocks[1] == (byte)BlockData.Blocks.Chest) // South
{
firstCoords = coords;
secondCoords = nsewBlockPositions[1];
}
else// if ((byte)nsewBlocks[3] == (byte)BlockData.Blocks.Chest) // West
{
firstCoords = coords;
secondCoords = nsewBlockPositions[3];
}
return new UniversalCoords[] { firstCoords, secondCoords };
}