UltimateZoneBuilder/Source/Core/GZBuilder/Data/ThingCopyData.cs
MaxED 0369c969d1 According to dotnetperls.com, "new Dictionary<string, [anything]>(StringComparer.Ordinal)" works 17% faster than "new Dictionary<string, [anything]>()", so let's stick that everywhere and see what happens :)
Draw Curve Mode: added settings panel.
Sectors mode: added "Make Door" button to the toolbar.
Swapped Side panel and Info panel z-order. 
Interface: split toolbar into 3 separate toolbars. All toolbar buttons are now viewable at 1024x768.
Interface: grouped stuff in "Modes" menu a bit better.
Interface: added "Draw [stuff]" buttons to modes toolbar.
Interface: reorganized main menu. Hope it makes more sense now.
API: added General.Interface.AddModesButton() and General.Interface.AddModesMenu(), which can be used to add buttons to specific group in "Modes" toolbar and menu items to specific group in "Modes" menu, so actions, which behave like an editing mode, but are not part of one can be added there.
2014-02-26 14:11:06 +00:00

55 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.GZBuilder.Data {
public sealed class ThingCopyData {
// Properties
private readonly int type;
private readonly Vector3D pos;
private readonly int angledoom; // Angle as entered / stored in file
private readonly Dictionary<string, bool> flags;
private readonly int tag;
private readonly int action;
private readonly int[] args;
private readonly UniFields fields;
public Vector3D Position { get { return pos; } }
public ThingCopyData(Thing t) {
type = t.Type;
angledoom = t.AngleDoom;
pos = t.Position;
flags = new Dictionary<string, bool>(t.Flags);
tag = t.Tag;
action = t.Action;
args = (int[])t.Args.Clone();
fields = new UniFields(t, t.Fields);
}
public void ApplyTo(Thing t) {
t.Type = type;
t.Rotate(angledoom);
t.Move(pos);
foreach(KeyValuePair<string, bool> group in flags)
t.SetFlag(group.Key, group.Value);
t.Tag = tag;
t.Action = action;
for(int i = 0; i < args.Length; i++)
t.Args[i] = args[i];
foreach (KeyValuePair<string, UniValue> group in fields) {
if (t.Fields.ContainsKey(group.Key))
t.Fields[group.Key] = group.Value;
else
t.Fields.Add(group.Key, group.Value);
}
t.UpdateConfiguration();
}
}
}