private void RenderInfo() { if (_page.ContainsKey("pageID")) { _writer.AppendLine("<div style='text-align: center; margin: 5px 0; width: 1245px'>"); _writer.AppendLine( $"Origin: [{_page["_origin"].AsString}] - Position: {_page["_position"].AsInt64} - Free bytes: {_page["freeBytes"]}"); _writer.AppendLine("</div>"); } }
public static T ConvertTo <T>(BsonDocument bd) where T : new() { T model = new T(); PropertyInfo[] propertyInfos = model.GetType().GetProperties(); foreach (var property in propertyInfos) { if (property != null && bd.ContainsKey(property.Name)) { property.SetValue(model, bd[property.Name], null); } } return(model); }
/// <summary> /// Loads the chunk from save data. /// </summary> /// <param name="det">The block data.</param> /// <param name="ents">The entity data.</param> public void LoadFromSaveData(ChunkDetails det, ChunkDetails ents) { if (det.Version != 2 || ents.Version != 2) { throw new Exception("invalid save data VERSION: " + det.Version + " and " + ents.Version + "!"); } Flags = det.Flags & ~(ChunkFlags.POPULATING); SetBlockAt(0, 0, 0, BlockInternal.AIR); // Ensure generated if (det.Blocks.Length > 0) { for (int i = 0; i < BlocksInternal.Length; i++) { BlocksInternal[i]._BlockMaterialInternal = Utilities.BytesToUShort(Utilities.BytesPartial(det.Blocks, i * 2, 2)); BlocksInternal[i].BlockData = det.Blocks[BlocksInternal.Length * 2 + i]; BlocksInternal[i].BlockLocalData = det.Blocks[BlocksInternal.Length * 3 + i]; BlocksInternal[i]._BlockPaintInternal = det.Blocks[BlocksInternal.Length * 4 + i]; } FromFile = true; } for (int i = 0; i < Reachability.Length; i++) { Reachability[i] = det.Reachables[i] == 1; } if (ents.Blocks != null && ents.Blocks.Length > 0 && entsToSpawn.Count == 0) { BsonDocument bsd = BsonSerializer.Deserialize(ents.Blocks); if (bsd.ContainsKey("list")) { List <BsonValue> docs = bsd["list"]; for (int i = 0; i < docs.Count; i++) { BsonDocument ent = (BsonDocument)docs[i]; EntityType etype = (EntityType)Enum.Parse(typeof(EntityType), ent["ENTITY_TYPE"].AsString); try { Entity e = OwningRegion.ConstructorFor(etype).Create(OwningRegion, ent); e.EID = ent["ENTITY_ID"].AsInt64; entsToSpawn.Add(e); } catch (Exception ex) { Utilities.CheckException(ex); SysConsole.Output("Spawning an entity of type " + etype, ex); } } } } }
public void ApplyPhysicsData(BsonDocument doc) { if (doc.ContainsKey("ph_pos")) { SetPosition(Location.FromDoubleBytes(doc["ph_pos"].AsBinary, 0)); } if (doc.ContainsKey("ph_vel")) { SetVelocity(Location.FromDoubleBytes(doc["ph_vel"].AsBinary, 0)); } if (doc.ContainsKey("ph_avel")) { SetAngularVelocity(Location.FromDoubleBytes(doc["ph_avel"].AsBinary, 0)); } if (doc.ContainsKey("ph_ang_x") && doc.ContainsKey("ph_ang_y") && doc.ContainsKey("ph_ang_z") && doc.ContainsKey("ph_ang_w")) { double ax = (double)doc["ph_ang_x"].AsDouble; double ay = (double)doc["ph_ang_y"].AsDouble; double az = (double)doc["ph_ang_z"].AsDouble; double aw = (double)doc["ph_ang_w"].AsDouble; SetOrientation(new Quaternion(ax, ay, az, aw)); } if (doc.ContainsKey("ph_grav")) { SetGravity(Location.FromDoubleBytes(doc["ph_grav"].AsBinary, 0)); } if (doc.ContainsKey("ph_bounce")) { SetBounciness((double)doc["ph_bounce"].AsDouble); } if (doc.ContainsKey("ph_frict")) { SetFriction((double)doc["ph_frict"].AsDouble); } if (doc.ContainsKey("ph_mass")) { SetMass((double)doc["ph_mass"].AsDouble); } if (doc.ContainsKey("ph_cg")) { int cg = doc["ph_cg"].AsInt32; if (cg == 0) { CGroup = CollisionUtil.NonSolid; } else if (cg == 1) { CGroup = CollisionUtil.Solid; } else if (cg == 2) { CGroup = CollisionUtil.Player; } else if (cg == 3) { CGroup = CollisionUtil.Item; } else // cg == 4 { CGroup = CollisionUtil.Water; } } if (doc.ContainsKey("ph_flag")) { int flags = doc["ph_flag"].AsInt32; Visible = (flags & 1) == 1; GenBlockShadow = (flags & 2) == 2; TransmitMe = (flags & 128) == 128; } }