public static Entity Clone(Entity entity) { Entity clone = null; if (entity is StaticModelEntity) { StaticModelEntity modelentity = entity as StaticModelEntity; clone = new StaticModelEntity(modelentity.GetModel()); } if (entity is WallModelEntity) { WallModelEntity wallentity = entity as WallModelEntity; clone = new WallModelEntity(wallentity.GetModel()); } if (entity is AnimatedModelEntity) { AnimatedModelEntity modelentity = entity as AnimatedModelEntity; clone = new AnimatedModelEntity(modelentity.GetModel()); } if (entity is Billboard) { Billboard billboard = entity as Billboard; clone = new Billboard(billboard.region); } if (clone != null) { CopyFrom(entity, clone); } return(clone); }
public static Entity Clone(Entity entity) { Entity clone = null; if (entity is StaticModelEntity) { StaticModelEntity modelentity = entity as StaticModelEntity; clone = new StaticModelEntity(modelentity.GetModel()); } if (entity is WallModelEntity) { WallModelEntity wallentity = entity as WallModelEntity; clone = new WallModelEntity(wallentity.GetModel()); } if (entity is AnimatedModelEntity) { AnimatedModelEntity modelentity = entity as AnimatedModelEntity; clone = new AnimatedModelEntity(modelentity.GetModel()); } if (entity is Billboard) { Billboard billboard = entity as Billboard; clone = new Billboard(billboard.region); } if (clone != null) CopyFrom(entity, clone); return clone; }
public void Load() { entities.Clear(); XmlLevel xmllevel = XmlHelper.Load(id); List<XmlEntity> xmlentities = xmllevel.entities; for (int i = 0; i < xmlentities.Count; i++) { XmlEntity xmlentity = xmlentities[i]; Entity entity = null; if (xmlentity.type == "static_model") { Model model = (Model)Resources.GetObject(xmlentity.asset); entity = new StaticModelEntity(model); } if (xmlentity.type == "animated_model") { Model model = (Model)Resources.GetObject(xmlentity.asset); entity = new AnimatedModelEntity(model); } if (xmlentity.type == "wall_model") { Model model = (Model)Resources.GetObject(xmlentity.asset); entity = new WallModelEntity(model); } if (xmlentity.type == "billboard") { Texture2D texture = (Texture2D)Resources.GetObject(xmlentity.asset); entity = new Billboard(texture); ((Billboard)entity).color = xmlentity.color; } if (entity == null) continue; entity.position = xmlentity.position; entity.rotation = xmlentity.rotation; entity.size = xmlentity.size; Add(entity); } }
public Entity CreateFromAsset(object asset) { Entity entity = null; if (asset is Model) { Model model = asset as Model; if (model.Tag is SkinningData) entity = new AnimatedModelEntity(model); else entity = new StaticModelEntity(model); } else if (asset is Texture2D) { Texture2D texture = asset as Texture2D; entity = new Billboard(texture); } return entity; }