2013-04-11 11:04:16 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-07-16 09:45:21 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Data {
|
2013-09-11 09:47:53 +00:00
|
|
|
|
public sealed class ThingCopyData {
|
|
|
|
|
// Properties
|
|
|
|
|
private int type;
|
|
|
|
|
private Vector3D pos;
|
|
|
|
|
private int angledoom; // Angle as entered / stored in file
|
|
|
|
|
private Dictionary<string, bool> flags;
|
|
|
|
|
private int tag;
|
|
|
|
|
private int action;
|
|
|
|
|
private int[] args;
|
|
|
|
|
private 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); //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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-16 09:45:21 +00:00
|
|
|
|
}
|