Beispiel #1
0
 public EntityData Clone()
 {
     var ed = new EntityData { Name = Name, Flags = Flags };
     ed.Properties.AddRange(Properties.Select(x => x.Clone()));
     ed.Outputs.AddRange(Outputs.Select(x => x.Clone()));
     return ed;
 }
Beispiel #2
0
 private TreeNode GetEntityNode(EntityData data)
 {
     var node = new TreeNode("Entity: " + data.Name);
     var pnode = node.Nodes.Add("Properties: " + data.Properties.Count);
     foreach (var p in data.Properties)
     {
         pnode.Nodes.Add(p.Key + " = " + p.Value);
     }
     if (data.Outputs.Count > 0)
     {
         var onode = node.Nodes.Add("Outputs: " + data.Outputs);
         foreach (var o in data.Outputs)
         {
             onode.Nodes.Add(o.Name + " > " + o.Target);
         }
     }
     var fnode = node.Nodes.Add("Flags: " + data.Flags);
     return node;
 }
Beispiel #3
0
 public Entity(long id)
     : base(id)
 {
     Origin = new Coordinate(0, 0, 0);
     EntityData = new EntityData();
 }
Beispiel #4
0
 private static void WriteEntityData(BinaryWriter bw, EntityData data)
 {
     bw.WriteCString(data.Name);
     bw.Write(new byte[4]); // Unused
     bw.Write(data.Flags);
     bw.Write(data.Properties.Count);
     foreach (var property in data.Properties)
     {
         WriteProperty(bw, property);
     }
     bw.Write(new byte[12]); // Unused
 }
Beispiel #5
0
        private static EntityData ReadEntityData(BinaryReader br)
        {
            var data = new EntityData
                {
                    Name = br.ReadCString()
                };

            br.ReadBytes(4); // Unused bytes

            data.Flags = br.ReadInt32();

            var numProperties = br.ReadInt32();
            for (var i = 0; i < numProperties; i++)
            {
                var prop = ReadProperty(br);
                data.SetPropertyValue(prop.Key, prop.Value);
            }

            br.ReadBytes(12); // More unused bytes

            return data;
        }
Beispiel #6
0
 public World(long id)
     : base(id)
 {
     Paths = new List<Path>();
     EntityData = new EntityData {Name = "worldspawn"};
 }
Beispiel #7
0
 private IEnumerable<TreeNode> GetEntityNodes(EntityData data)
 {
     yield return new TreeNode("Flags: " + data.Flags);
 }
Beispiel #8
0
 private static void WriteEntityData(GenericStructure obj, EntityData data)
 {
     foreach (var property in data.Properties.OrderBy(x => x.Key))
     {
         obj[property.Key] = property.Value;
     }
     obj["spawnflags"] = data.Flags.ToString(CultureInfo.InvariantCulture);
 }
Beispiel #9
0
 private static EntityData ReadEntityData(GenericStructure structure)
 {
     var ret = new EntityData();
     foreach (var key in structure.GetPropertyKeys())
     {
         if (ExcludedKeys.Contains(key.ToLower())) continue;
         ret.SetPropertyValue(key, structure[key]);
     }
     ret.Name = structure["classname"];
     ret.Flags = structure.PropertyInteger("spawnflags");
     return ret;
 }
Beispiel #10
0
 private void SetEntityData(Entity ent, EntityData data, GameData gameData)
 {
     ent.EntityData = data;
     ent.GameData = gameData.Classes.FirstOrDefault(x => String.Equals(x.Name, data.Name, StringComparison.CurrentCultureIgnoreCase) && x.ClassType != ClassType.Base);
 }
Beispiel #11
0
 public void AddEntity(MapObject obj, EntityData newData)
 {
     _objects.Add(new EntityReference {ID = obj.ID, Before = obj.GetEntityData().Clone(), After = newData});
 }
Beispiel #12
0
 private void SetEntityData(World world, EntityData data)
 {
     world.EntityData = data;
 }
Beispiel #13
0
 private void SetEntityData(Entity ent, EntityData data, GameData gameData)
 {
     ent.EntityData = data;
     ent.GameData = gameData.Classes.FirstOrDefault(x => x.Name.ToLower() == data.Name.ToLower());
 }