Exemplo n.º 1
0
        public void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            if (RootComponent != null)
            {
                RootComponent.UpdateTransformsRecursive();
            }

            Factions.Update(gameTime);


            foreach (GameComponent component in Components.Values)
            {
                if (component.IsActive)
                {
                    component.Update(gameTime, chunks, camera);
                }

                if (component.IsDead)
                {
                    Removals.Add(component);
                    component.IsActive  = false;
                    component.IsDead    = true;
                    component.IsVisible = false;
                }
            }


            HandleAddRemoves();
        }
        public void Update(string newDirectory)
        {
            var filePath = Path.Combine(newDirectory, Name);
            var newLines = new List <string>();

            foreach (var line in File.ReadLines(filePath))
            {
                var newLine = line;
                if (Removals.Any(r => newLine.Contains(r)) &&
                    !RemovalsToSkip.Any(s => newLine.Contains(s)))
                {
                    continue;
                }

                foreach (var replacement in Replacements)
                {
                    if (newLine.Contains(replacement.Key))
                    {
                        newLine = newLine.Replace(replacement.Key, replacement.Value);
                    }
                }

                newLines.Add(newLine);
            }

            File.WriteAllLines(filePath, newLines);
        }
Exemplo n.º 3
0
        private void AddRemove()
        {
            DataLock.WaitOne();
            foreach (InstanceData t in Additions)
            {
                Data.Add(t);
            }

            foreach (InstanceData t in Removals)
            {
                Data.Remove(t);
            }

            Additions.Clear();
            Removals.Clear();
            DataLock.ReleaseMutex();
        }
Exemplo n.º 4
0
        public void HandleAddRemoves()
        {
            AdditionMutex.WaitOne();
            foreach (GameComponent component in Additions)
            {
                AddComponentImmediate(component);
            }

            Additions.Clear();
            AdditionMutex.ReleaseMutex();

            RemovalMutex.WaitOne();
            foreach (GameComponent component in Removals)
            {
                RemoveComponentImmediate(component);
            }

            Removals.Clear();
            RemovalMutex.ReleaseMutex();
        }
Exemplo n.º 5
0
 public void RemoveComponent(GameComponent component)
 {
     RemovalMutex.WaitOne();
     Removals.Add(component);
     RemovalMutex.ReleaseMutex();
 }
Exemplo n.º 6
0
 public void Remove(InstanceData data)
 {
     DataLock.WaitOne();
     Removals.Add(data);
     DataLock.ReleaseMutex();
 }