コード例 #1
0
        /// <summary>
        /// Creates a copy of an actor, translated by the given offset.
        /// </summary>
        public static UnrealActor Duplicate(UnrealActor actor, Vector3D translateOffset)
        {
            var result = Duplicate(actor);

            if (!translateOffset.IsZero())
            {
                result.Translate(translateOffset);
            }
            return(result);
        }
コード例 #2
0
 protected UnrealActor(UnrealActor actor) : base(actor)
 {
     properties = new Dictionary <string, string>(actor.properties);
     Class      = actor.Class;
     Name       = actor.Name;
     Location   = actor.Location;
     Rotation   = actor.Rotation;
     // Copy all ownership information as well, despite this object possibly getting changed!
     owners.AddRange(actor.owners);
 }
コード例 #3
0
 /// <summary>
 /// Creates a modifiable deep copy of an actor, retaining the class type.
 /// </summary>
 public static UnrealActor Duplicate(UnrealActor actor)
 {
     if (actor is UnrealBrush)
     {
         return((actor as UnrealBrush).Duplicate());
     }
     else
     {
         return(actor.Duplicate());
     }
 }
コード例 #4
0
        /// <summary>
        /// Generates an extensible T3D representation of an actor instance, so minus the header and footer.
        /// </summary>
        private static string GenerateProperties(UnrealActor actor)
        {
            var builder = new StringBuilder();

            // Add all properties
            foreach (var property in actor.Properties)
            {
                builder.AppendLine("\t" + property.Key + "=" + property.Value);
            }

            return(builder.ToString());
        }
コード例 #5
0
 private void loadInfo()
 {
     levelInfo = Actors.Where(a => a.Class == "LevelInfo").FirstOrDefault();
     if (levelInfo != null)
     {
         title  = levelInfo.GetProperty("Title");
         title  = title?.Substring(1, title.Length - 2);
         author = levelInfo.GetProperty("Author");
         author = author?.Substring(1, author.Length - 2);
         song   = levelInfo.GetProperty("Song");
         song   = song?.Substring(6, song.Length - 7);
     }
 }
コード例 #6
0
        /// <summary>
        /// Generates the T3D representation of an actor instance.
        /// </summary>
        public static string GenerateText(UnrealActor actor)
        {
            var builder = new StringBuilder();

            // Add header
            builder.AppendLine("Begin Actor Class=" + actor.Class + " Name=" + actor.Name);
            // Add all properties
            builder.AppendLine(GenerateProperties(actor));
            // Add footer
            builder.AppendLine("End Actor");

            return(builder.ToString());
        }
コード例 #7
0
 /// <summary>
 /// Instantiates an actor with the correct type.
 /// </summary>
 public static UnrealActor FromText(string text)
 {
     if ((text.StartsWith("Begin Actor Class=Brush ") ||
          text.StartsWith("Begin Actor Class=Mover ")) &&
         text.Contains("Begin Brush "))    // some "Brushes" do not contain geometry, no idea why
     {
         return(UnrealBrush.FromText(text));
     }
     else
     {
         return(UnrealActor.FromText(text));
     }
 }
コード例 #8
0
 public void RemoveActor(UnrealActor actor)
 {
     if (isReadOnly)
     {
         throw new InvalidOperationException("This map cannot be modified because it is read-only");
     }
     else
     {
         if (actor is UnrealBrush)
         {
             brushes.Remove(actor as UnrealBrush);
         }
         actors.Remove(actor);
         actor.RemoveOwner(this);
     }
 }
コード例 #9
0
        public void AddActor(UnrealActor actor)
        {
            if (isReadOnly)
            {
                throw new InvalidOperationException("This map cannot be modified because it is read-only");
            }
            else
            {
                if (actor is UnrealBrush)
                // if (actor.Class == "Brush" || actor.Class == "Mover") // TODO: test
                {
                    if ((actor as UnrealBrush).Polygons.Count() == 0)
                    {
                        // This brush is invalid, so ignore it
                        return;
                    }

                    brushes.Add(actor as UnrealBrush);
                }
                actors.Add(actor);
                actor.AddOwner(this);
            }
        }
コード例 #10
0
 /// <param name="actor">The actor to investigate.</param>
 /// <param name="minDist">The required minimum distance from any edge.</param>
 /// <returns>Whether the given actor is inside this brush.</returns>
 public bool?Encompasses(UnrealActor actor, double minDist = 0.0) => Encompasses(actor.Location, minDist);