public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("ObjectColor"); so.SetColor("Color", Color); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("Grid"); so.Set("SnapToGrid", SnapToGrid); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("VisgroupID"); so.Set("ID", ID); return(so); }
public async Task <Change> Perform(MapDocument document) { var ch = new Change(document); var obj = document.Map.Root.FindByID(_id); var data = obj?.Data.GetOne <EntityData>(); if (data != null) { _beforeState = data.ToSerialisedObject(); foreach (var kv in _valuesToSet) { if (kv.Value == null) { data.Properties.Remove(kv.Key); } else { data.Properties[kv.Key] = kv.Value; } } ch.Update(obj); } return(ch); }
public EntitySprite(SerialisedObject obj) { Name = obj.Get <string>("Name"); Scale = obj.Get <float>("Scale"); Color = obj.GetColor("Color"); Size = new SizeF(obj.Get <float>("Width"), obj.Get <float>("Height")); }
public VmfEditor(SerialisedObject obj) { if (obj == null) { obj = new SerialisedObject("editor"); } Color = obj.GetColor("color"); ParentID = GroupID = obj.Get("groupid", 0); Properties = new Dictionary <string, string>(); VisgroupIDs = new List <int>(); foreach (KeyValuePair <string, string> kv in obj.Properties) { switch (kv.Key.ToLower()) { case "visgroupid": if (int.TryParse(kv.Value, out int id)) { VisgroupIDs.Add(id); } break; case "color": case "groupid": break; default: Properties[kv.Key] = kv.Value; break; } } }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("ActiveTexture"); so.Set("Name", Name); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("Origin"); so.Set("Location", Location); return(so); }
public VmfSide(SerialisedObject obj) { ID = obj.Get("ID", 0L); LightmapScale = obj.Get("lightmapscale", 0); SmoothingGroups = obj.Get("smoothing_groups", ""); if (ParseDoubleArray(obj.Get("plane", ""), new[] { ' ', '(', ')' }, 9, out double[] pl))
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("HideFaceMask"); so.Set("Hidden", Hidden); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("SelectionOptions"); so.Set("IgnoreGrouping", IgnoreGrouping); return(so); }
private void SaveCameras(Map map, List <SerialisedObject> list) { var cams = map.Data.OfType <Camera>().ToList(); if (!cams.Any()) { return; } var so = new SerialisedObject("cameras"); for (var i = 0; i < cams.Count; i++) { var camera = cams[i]; if (camera.IsActive) { so.Set("activecamera", i); } var vgo = new SerialisedObject("camera"); vgo.Set("position", $"[{FormatVector3(camera.EyePosition)}]"); vgo.Set("look", $"[{FormatVector3(camera.LookPosition)}]"); so.Children.Add(vgo); } list.Add(so); }
private void SerialiseWorldspawnChildren(Worldspawn worldspawn, SerialisedObject worldObj, Dictionary <MapObject, int> idMap, int groupId, List <MapObject> list) { foreach (var c in list) { var cid = idMap[c]; switch (c) { case Entity _: // Ignore everything underneath an entity break; case Group g: var sg = new VmfGroup(g, cid); if (groupId != 0) { sg.Editor.GroupID = groupId; } worldObj.Children.Add(sg.ToSerialisedObject()); SerialiseWorldspawnChildren(worldspawn, worldObj, idMap, cid, g.Children); break; case Solid s: var ss = new VmfSolid(s, cid); if (groupId != 0) { ss.Editor.GroupID = groupId; } worldObj.Children.Add(ss.ToSerialisedObject()); break; } } }
public VmfEntity(SerialisedObject obj) : base(obj) { Objects = new List <VmfObject>(); foreach (var so in obj.Children) { var o = Deserialise(so); if (o != null) { Objects.Add(o); } } var ed = new EntityData(); foreach (var kv in obj.Properties) { if (kv.Key == null || ExcludedKeys.Contains(kv.Key.ToLower())) { continue; } ed.Set(kv.Key, kv.Value); } ed.Name = obj.Get("classname", ""); ed.Flags = obj.Get("spawnflags", 0); EntityData = ed; if (obj.Properties.Any(x => x.Key == "origin")) { Origin = obj.Get("origin", Vector3.Zero); } }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject(nameof(EntityDecal)); so.Set(nameof(Name), Name); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("Selection"); so.Set("SelectedObjects", String.Join(",", _selectedObjects.Select(x => Convert.ToString(x.ID, CultureInfo.InvariantCulture)))); return(so); }
private void LoadVisgroups(MapFile map, SerialisedObject so) { var vis = new Visgroup(); LoadVisgroupsRecursive(so, vis); map.Visgroups.AddRange(vis.Children); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("VisgroupHidden"); so.Set("IsHidden", IsHidden); return(so); }
private void LoadVisgroups(Map map, SerialisedObject visgroups) { if (visgroups == null) { return; } foreach (var vg in visgroups.Children.Where(x => x.Name?.ToLower() == "visgroup")) { var v = new Visgroup { Name = vg.Get("name", ""), ID = vg.Get("visgroupid", -1), Colour = vg.GetColor("color"), Visible = true }; if (v.Colour.GetBrightness() < 0.001f) { v.Colour = Colour.GetRandomBrushColour(); } if (v.ID < 0) { continue; } map.Data.Add(v); } }
public CordonBounds(SerialisedObject obj) { Enabled = obj.Get <bool>("Enabled"); var start = obj.Get <Vector3>("Start"); var end = obj.Get <Vector3>("End"); Box = new Box(start, end); }
public Visgroup(SerialisedObject obj) { Objects = new ThreadSafeSet <IMapObject>(); ID = obj.Get <long>("ID"); Name = obj.Get <string>("Name"); Visible = obj.Get <bool>("Visible"); Colour = obj.GetColor("Colour"); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("DisplayFlags"); so.Set("HideNullTextures", HideNullTextures); so.Set("HideDisplacementSolids", HideDisplacementSolids); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("TransformationFlags"); so.Set("TextureLock", TextureLock); so.Set("TextureScaleLock", TextureScaleLock); return(so); }
public VmfSolid(SerialisedObject obj) : base(obj) { Sides = new List <VmfSide>(); foreach (var so in obj.Children.Where(x => x.Name == "side")) { Sides.Add(new VmfSide(so)); } }
public override SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("solid"); so.Set("id", ID); so.Children.AddRange(Sides.Select(x => x.ToSerialisedObject())); so.Children.Add(Editor.ToSerialisedObject()); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("CordonBounds"); so.Set("Enabled", Enabled); so.Set("Start", Box.Start); so.Set("End", Box.End); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("Camera"); so.Set("EyePosition", EyePosition); so.Set("LookPosition", LookPosition); so.Set("IsActive", IsActive); return(so); }
public SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("Path"); so.Set("Name", Name); so.Set("Type", Type); so.Set("Direction", Direction); so.Children.AddRange(Nodes.Select(x => x.ToSerialisedObject())); return(so); }
public LoadedDocument(SerialisedObject pointer) { Metadata = new Dictionary <string, string>(); Loader = pointer.Name; foreach (var pp in pointer.Properties) { Metadata[pp.Key] = pp.Value; } FileName = pointer.Get <string>("FileName"); }
public override SerialisedObject ToSerialisedObject() { var so = new SerialisedObject("group"); so.Set("id", ID); so.Children.Add(Editor.ToSerialisedObject()); return(so); }