public void InserItemAtPosition()
 {
     var list = new SimpleList<int>() { 1, 2, 3, 4 };
     list.Insert(4, 5);
     var list2 = new SimpleList<int>() { 1, 2, 3, 4, 5 };
     CollectionAssert.Equals(list2, list);
 }
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.modlEntryList1 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList2 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList3 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList4 = new ModlEntryList(OnResourceChanged, s);
     this.modlTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference4 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference5 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference6 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference7 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.unknown1 = r.ReadUInt32();
     this.unknown2 = r.ReadByte();
     this.unknown3 = r.ReadUInt32();
     this.catalogGroupID = r.ReadUInt64();
     this.rsltTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.unknownList1 = new SimpleList<uint>(OnResourceChanged);
     ushort count = r.ReadUInt16();
     for (int i = 0; i < count; i++) this.unknownList1.Add(r.ReadUInt32());
     this.unknownList2 = new SimpleList<uint>(OnResourceChanged);
     count = r.ReadUInt16();
     for (int i = 0; i < count; i++) this.unknownList2.Add(r.ReadUInt32());
     count = r.ReadUInt16();
     this.unknownList3 = new SimpleList<uint>(OnResourceChanged);
     for (int i = 0; i < count; i++) this.unknownList3.Add(r.ReadUInt32());
     this.colorList = new SwatchColorList(OnResourceChanged, s);
     this.unknown4 = r.ReadUInt32();
 }
 public void RemoveObjectFromList()
 {
     var list = new SimpleList<int>() { 1, 2, 3, 4, 5, 6, 7, 8 };
     var newList = new SimpleList<int>() { 1, 2, 4, 5, 6, 7, 8 };
     list.Remove(3);
     CollectionAssert.Equals(newList, list);
 }
        public TypeInfo GetTypeInfo(Type type)
        {
            if (!_typeInfos.ContainsKey(type))
            {
                var typeInfo = new TypeInfo
                    {
                        Id = _typeInfos.Count,
                        TypeName = type.AssemblyQualifiedName,
                        IsEnumerable = type.IsImplOf<IEnumerable>()
                    };

                if (!typeInfo.IsEnumerable)
                {
                    var propertyInfos = type.GetProperties();
                    var propertyNames = new SimpleList<string>();
                    foreach (var propertyInfo in propertyInfos)
                    {
                        if (!IsAValidProperty(propertyInfo)) continue;
                        propertyNames.Add(propertyInfo.Name);
                    }
                    typeInfo.PropertyNames = propertyNames;
                }

                _typeInfos.Add(type, typeInfo);
                return typeInfo;
            }
            return _typeInfos[type];
        }
Beispiel #5
0
        /// <summary>
        /// Lists all the possible moves a player can make
        /// </summary>
        /// <returns>The list of move locations</returns>
        public static SimpleList<Move> FindPossibleMoves(int player, params int[] filter)
        {
            int tempX = Battle.X;
            int tempY = Battle.Y;

            int limit = 1;
            if (player == 2)
                limit = Battle.Foe.SkillLimit;
            if (filter.Length > 0)
                limit = filter[0];

            SimpleList<Move> list = new SimpleList<Move>();
            for (int a = 0; a < 100; ++a)
            {
                Battle.X = a % 10;
                Battle.Y = a / 10;

                for (int x = 0; x < limit; ++x)
                {
                    Type type = Type.GetType(actionPrefix + actionNames[x]);
                    if ((Boolean)type.InvokeMember("CanPerform", BindingFlags.InvokeMethod, null, null, null))
                        list.Add(new Move(a, x));
                }
            }

            Battle.X = tempX;
            Battle.Y = tempY;

            return list;
        }
 public void ClearList()
 {
     var list = new SimpleList<int>() { 1, 2, 3 };
     list.Clear();
     int[] clearedList = { 0, 0, 0, 0, 0, 0, 0, 0};
     CollectionAssert.Equals(clearedList, list);
 }
Beispiel #7
0
 public static RecursiveFor Prepare(SimpleList<int> limits)
 {
     RecursiveFor current = null;
     foreach (var limit in limits)
         current = new RecursiveFor(current, limit);
     return current;
 }
Beispiel #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Pathfinder()
 {
     open = new SimpleList<Position>();
     closed = new SimpleList<Position>();
     random = new Random();
     start = new Position();
     target = new Position();
     check = new Position();
 }
Beispiel #9
0
 /// <summary>
 /// Initializes the menu parameters for
 /// the game menu
 /// </summary>
 public GameMenu()
     : base(ConsoleTools.menu)
 {
     choices = new string[] { "PlayerInfo", "Skills", "Quests", "Manual", "Save", "Practice" };
     indicator = Constants.CharValue("menuGameIndicator");
     horizontalCoordinate = 4;
     verticalOffset = 4;
     verticalScale = 2;
     labels = new SimpleList<Label>();
 }
Beispiel #10
0
 public MessagingTests()
 {
     var iocContainer = MockRepository.GenerateMock<IIocContainer>();
     var sendMessageHandlerType = typeof(TestActions.SendMessageHandler);
     iocContainer.Expect(x => x.Resolve(sendMessageHandlerType))
         .Return(new TestActions.SendMessageHandler());
     var messageHandlerTypes = new SimpleList<Type> { sendMessageHandlerType };
     var executionManager = new SimpleExecutionManager();
     var smartOperator = new SmartOperator(iocContainer, executionManager, messageHandlerTypes);
     _messenger = new Messenger<object>(smartOperator);
 }
Beispiel #11
0
 public SimpleList<int> GetIndexes()
 {
     var current = this;
     var indexes = new SimpleList<int>();
     while (current != null)
     {
         indexes.Add(current.Index);
         current = current.Parent;
     }
     indexes.Reverse();
     return indexes;
 }
Beispiel #12
0
        /// <summary>
        /// Create the manager.
        /// </summary>
        /// <param name="hull"></param>
        public ObjectManager(ConvexHullInternal hull)
        {
            this.Dimension = hull.Dimension;
            this.Hull = hull;
            this.FacePool = hull.FacePool;
            this.FacePoolSize = 0;
            this.FacePoolCapacity = hull.FacePool.Length;
            this.FreeFaceIndices = new IndexBuffer();

            this.EmptyBufferStack = new SimpleList<IndexBuffer>();
            this.DeferredFaceStack = new SimpleList<DeferredFace>();
        }
 public ComplexTypeItems GetItems(object complexItem)
 {
     var dictionary = complexItem.CastObj<IDictionary>();
     var keys = new SimpleList<object>();
     var values = new SimpleList<object>();
     foreach (dynamic item in dictionary)
     {
         keys.Add(item.Key);
         values.Add(item.Value);
     }
     return new DictionaryItems { Keys = keys, Values = values };
 }
		public void should_be_able_to_add_items_to_the_list()
		{
			var sut = new SimpleList<ShopItem>();

			var item1 = new ShopItem {Id = 1, Name = "Megaphone", Price = 200m};

			sut.Add(item1);
			sut.Add(item1);
			sut.Add(item1);

			Assert.That(sut.Count(), Is.EqualTo(3));
		}
 public static SimpleList<Type> GetTypes(this AppDomain appDomain, Func<Type, bool> func)
 {
     var simpleList = new SimpleList<Type>();
     var assemblies = appDomain.GetAssemblies();
     foreach (var assembly in assemblies)
     {
         var types = assembly.GetTypes();
         foreach (var type in types)
         {
             if (!func(type)) continue;
             simpleList.Add(type);
         }
     }
     return simpleList;
 }
Beispiel #16
0
        /// <summary>
        /// Uses a template according to the given parameters to generate a room
        /// </summary>
        /// <param name="typeInt">A randomed integer that determines the type</param>
        /// <param name="l">The room length</param>
        /// <param name="w">The room width</param>
        /// <returns>The room layout</returns>
        public static char[,] CreateRoom(int typeInt, int l, int w)
        {
            // Get the list of templates
            SimpleList<string> types = new SimpleList<string>();
            var q = from t in Assembly.GetExecutingAssembly().GetTypes()
                    where t.IsClass && t.Namespace == templateTypes
                    select t;
            q.ToList().ForEach(t => types.Add(t.Name));

            // Choose the template according to the type given
            int moduloType = typeInt % types.Size;

            // Apply the corresponding template
            Type type = Type.GetType(templateTypes + "." + types[moduloType]);
            return (char[,])type.InvokeMember("Create", BindingFlags.InvokeMethod, null, null, new object[] {l, w, typeInt % 2});
        }
Beispiel #17
0
 static void Main(string[] args)
 {
     SimpleList<int> _strings = new SimpleList<int>();
     _strings.Add(1);
     _strings.Add(2);
     _strings.Add(3);
     _strings.Add(4);
     _strings.Add(5);
     var count = _strings.Count;
     var number5 = _strings[4];
     _strings[4] = 6;
     var number6 = _strings[4];
     _strings.Insert(4, 5);
     var number1 = _strings.RemoveAt(0);
     _strings.Clear();
 }
        public ComplexTypeItems GetItems(object complexItem)
        {
            var type = complexItem.GetTypeOfObj();
            var propertyInfos = type.GetProperties();

            var names = new SimpleList<string>();
            var values = new SimpleList<object>();

            foreach (var propertyInfo in propertyInfos)
            {
                if (!IsAValidProperty(propertyInfo)) continue;
                names.Add(propertyInfo.Name);
                values.Add(propertyInfo.GetValue(complexItem));
            }

            return new UserDefinedItems { Names = names, Values = values };
        }
Beispiel #19
0
		public static void Main(string[] args)
		{
			Application.Init();
			var list = new SimpleList();
			var label = new Label("Hello World");

			foreach (var str in new string[] {
				"A very long sentence indeeed",
				"Hello",
				"World",
				"No",
				"Yes"
			}) {
				var b = new Button(str) { Height = 1 };
				b.PressEvent += () => label.Text = str;
				list.Add(b);
			}

			list.Add(label);
			Application.Run(list);
		}
Beispiel #20
0
        public void SetItems(object complexItem, ComplexTypeItems complexTypeItems)
        {
            var arrayItems = complexTypeItems.CastObj<ArrayItems>();
            var items = arrayItems.Items;
            var array = complexItem.CastObj<Array>();

            var rankLengths = array.GetIndicies();

            var recursiveFor = RecursiveFor.Prepare(rankLengths);
            var allCombinations = new SimpleList<SimpleList<int>>();
            recursiveFor.Begin(info => allCombinations.Add(info.GetIndexes()));

            if (allCombinations.Count != items.Count)
                throw new Exception(string.Format("Array instance says there should be more than {0} items in this array", items.Count));

            for (var i = 0; i < allCombinations.Count; i++)
            {
                var combination = allCombinations[i];
                var item = items[i];
                array.SetValue(item, combination.ToArray());
            }
        }
        internal override Automaton <IMonadicPredicate <BDD, T> > GetAutomatonX(SimpleList <Variable> variables, ICartesianAlgebraBDD <T> alg, bool singletonSetSemantics)
        {
            var pos = GetVarIndex(var, variables);

            return(BasicAutomata.MkSingleton <T>(pos, alg));
        }
Beispiel #22
0
 /// <summary>
 /// Initialises the collection
 /// </summary>
 public GameObjectCollection(TilePos worldSize)
 {
     this._grid = new Grid(worldSize);
     this._interactiveGameItems = new SimpleList <IMovingItem>(100);
 }
Beispiel #23
0
        private void Parse(Stream s)
        {
            s.Position = 0;
            var r = new BinaryReader(s);

            this.version     = r.ReadUInt32();
            this.TGIoffset   = r.ReadUInt32() + 8;
            this.presetCount = r.ReadUInt32();
            if (this.presetCount != 0)
            {
                throw new Exception("Found non-zero one");
            }
            this.name = BigEndianUnicodeString.Read(s);

            this.sortPriority       = r.ReadSingle();
            this.secondarySortIndex = r.ReadUInt16();
            this.propertyID         = r.ReadUInt32();
            this.auralMaterialHash  = r.ReadUInt32();
            this.parmFlags          = (ParmFlag)r.ReadByte();
            this.excludePartFlags   = (ExcludePartFlag)r.ReadUInt64();
            if (this.version >= 36)
            {
                this.excludeModifierRegionFlags = r.ReadUInt64();
            }
            else
            {
                this.excludeModifierRegionFlags = r.ReadUInt32();
            }

            if (this.version >= 37)
            {
                this.flagList = new FlagList(this.OnResourceChanged, s);
            }
            else
            {
                this.flagList = FlagList.CreateWithUInt16Flags(this.OnResourceChanged, s, recommendedApiVersion);
            }

            this.deprecatedPrice    = r.ReadUInt32();
            this.partTitleKey       = r.ReadUInt32();
            this.partDesptionKey    = r.ReadUInt32();
            this.uniqueTextureSpace = r.ReadByte();
            this.bodyType           = (BodyType)r.ReadInt32();
            this.bodySubType        = r.ReadInt32();
            this.ageGender          = (AgeGenderFlags)r.ReadUInt32();
            if (this.version >= 0x20)
            {
                this.reserved1 = r.ReadUInt32();
            }
            if (this.version >= 34)
            {
                this.packID    = r.ReadInt16();
                this.packFlags = (PackFlag)r.ReadByte();
                this.reserved2 = r.ReadBytes(9);
            }
            else
            {
                this.packID  = 0;
                this.unused2 = r.ReadByte();
                if (this.unused2 > 0)
                {
                    this.unused3 = r.ReadByte();
                }
            }

            this.swatchColorCode = new SwatchColorList(this.OnResourceChanged, s);

            this.buffResKey          = r.ReadByte();
            this.varientThumbnailKey = r.ReadByte();
            if (this.version >= 0x1C)
            {
                this.voiceEffectHash = r.ReadUInt64();
            }
            if (this.version >= 0x1E)
            {
                this.usedMaterialCount = r.ReadByte();
                if (this.usedMaterialCount > 0)
                {
                    this.materialSetUpperBodyHash = r.ReadUInt32();
                    this.materialSetLowerBodyHash = r.ReadUInt32();
                    this.materialSetShoesHash     = r.ReadUInt32();
                }
            }
            if (this.version >= 0x1F)
            {
                this.hideForOccultFlags = (OccultTypesDisabled)r.ReadUInt32();
            }
            this.nakedKey  = r.ReadByte();
            this.parentKey = r.ReadByte();
            this.sortLayer = r.ReadInt32();

            // Don't move any of this before the -----
            // TGI block list
            var currentPosition = r.BaseStream.Position;

            r.BaseStream.Position = this.TGIoffset;
            var count4 = r.ReadByte();

            this.tgiList          = new CountedTGIBlockList(this.OnResourceChanged, "IGT", count4, s);
            r.BaseStream.Position = currentPosition;
            this.lodBlockList     = new LODBlockList(null, s, this.tgiList);
            //-------------

            var count = r.ReadByte();

            this.slotKey = new SimpleList <byte>(null);
            for (byte i = 0; i < count; i++)
            {
                this.slotKey.Add(r.ReadByte());
            }

            this.diffuseShadowKey  = r.ReadByte();
            this.shadowKey         = r.ReadByte();
            this.compositionMethod = r.ReadByte();
            this.regionMapKey      = r.ReadByte();
            this.overrides         = new OverrideList(null, s);
            this.normalMapKey      = r.ReadByte();
            this.specularMapKey    = r.ReadByte();
            if (this.version >= 0x1B)
            {
                this.sharedUVMapSpace = r.ReadUInt32();
            }
            if (this.version >= 0x1E)
            {
                this.emissionMapKey = r.ReadByte();
            }
        }
 private void Awake()
 {
     activeList = new SimpleList <FlgBehavior>();
     sleepList  = new SimpleList <FlgBehavior>();
 }
Beispiel #25
0
 internal abstract IEnumerable <Variable> EnumerateFreeVariables(SimpleList <Variable> bound, HashSet <Variable> free);
 internal abstract Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfFreeBits, bool singletonSetSemantics);
Beispiel #27
0
 internal abstract Automaton <IMonadicPredicate <BDD, T> > getAutomaton(SimpleList <Variable> variables, ICartesianAlgebraBDD <T> ca);
Beispiel #28
0
        static CompletionDataList GetPageAttributeValues(AspNetAppProject project, FilePath fromFile, string attribute)
        {
            var list = new CompletionDataList();

            switch (attribute.ToLowerInvariant())
            {
            //
            //boolean, default to false
            //
            case "async":
            case "aspcompat":
            case "explicit":    // useful for VB only. set to true in machine.config
            case "maintainscrollpositiononpostback":
            case "linepragmas": //actually not sure if this defaults true or false
            case "smartnavigation":
            case "strict":      //VB ONLY
            case "trace":
                SimpleList.AddBoolean(list, false);
                break;

            //
            //boolean, default to true
            //
            case "autoeventwireup":
            case "buffer":
            case "enableeventvalidation":
            case "enablesessionstate":
            case "enabletheming":
            case "enableviewstate":
            case "enableviewstatemac":
            case "validaterequest": //enabled in machine.config
            case "debug":
                SimpleList.AddBoolean(list, true);
                break;

            //
            //specialised hard value list completions
            //
            case "codepage":
                list.AddRange(from e in Encoding.GetEncodings() select e.CodePage.ToString());
                list.DefaultCompletionString = Encoding.UTF8.CodePage.ToString();
                break;

            case "compilationmode":
                SimpleList.AddEnum(list, System.Web.UI.CompilationMode.Always);
                break;

            case "culture":
                list.AddRange(from c in CultureInfo.GetCultures(CultureTypes.AllCultures) select c.Name);
                list.DefaultCompletionString = CultureInfo.CurrentCulture.Name;
                break;

            case "lcid":
                //  locale ID, MUTUALLY EXCLUSIVE with Culture
                list.AddRange(from c in CultureInfo.GetCultures(CultureTypes.AllCultures)
                              select c.LCID.ToString());
                list.DefaultCompletionString = CultureInfo.CurrentCulture.LCID.ToString();
                break;

            case "responseencoding":
                list.AddRange(from e in Encoding.GetEncodings() select e.Name);
                list.DefaultCompletionString = Encoding.UTF8.EncodingName;
                break;

            case "tracemode":
                list.Add("SortByTime");
                list.Add("SortByCategory");
                list.DefaultCompletionString = "SortByTime";
                break;

            case "transaction":
                list.Add("Disabled");
                list.Add("NotSupported");
                list.Add("Required");
                list.Add("RequiresNew");
                list.DefaultCompletionString = "Disabled";
                break;

            case "viewstateencryptionmode":
                SimpleList.AddEnum(list, ViewStateEncryptionMode.Auto);
                break;

            case "warninglevel":
                list.AddRange(new string[] { "0", "1", "2", "3", "4" });
                list.DefaultCompletionString = "0";
                break;

            case "masterpagefile":
                return(project != null
                   ? MonoDevelop.Html.PathCompletion.GetPathCompletion(project, "*.master", fromFile,
                                                                       x => "~/" + x.ProjectVirtualPath.ToString().Replace(System.IO.Path.PathSeparator, '/'))
                   : null);

            //
            //we can probably complete these using info from the project, but not yet
            //

            /*
             * case "CodeFile":
             *  //source file to compile for codebehind on server
             * case "ContentType":
             *  //string, HTTP MIME content-type
             * case "CodeFileBaseClass":
             *  // known base class for the partial classes, so code generator knows not
             *  //to redefine fields to ignore members in partial class
             * case "ErrorPage":
             *  // string, URL
             * case "Inherits":
             *  //  IType : Page. defaults to namespace from ClassName
             * case "Language":
             *  //  string, any available .NET language
             * case "Src":
             *  //  string, extra source code for page
             * case "StyleSheetTheme":
             *  //  theme ID, can be overridden by controls
             * case "Theme":
             *  //  theme identifier, overrides controls' themes
             * case "UICulture":
             *  //  string, valid UI culture
             */

            //
            //we're not likely to suggest anything for these:
            //

            /*
             * case "AsyncTimeOut":
             *  // int in seconds, default 45
             * case "ClassName":
             *  //string, .NET name, default namespace ASP
             * case "ClientTarget":
             *  //string, user agent
             * case "CodeBehind":
             *  //valid but IGNORE. VS-only
             * case "CompilerOptions":
             *  //string, list of compiler switches
             * case "Description":
             *  // string, pointless
             * case "TargetSchema":
             *  //  schema to validate page content. IGNORED, so rather pointless
             * case "Title":
             *  //  string for <title>
             */
            default:
                return(null);
            }

            return(list.Count > 0? list : null);
        }
Beispiel #29
0
        public static bool ArgumentExists(SimpleList <Pair <string, string> > arguments, string parameterName)
        {
            Pair <string, string> arg;

            return(TryGetArgumentByName(arguments, parameterName, out arg));
        }
        protected void Parse(Stream s)
        {
            if (s == null)
            {
                s = this.UnParse();
            }
            s.Position = 0;
            BinaryReader r = new BinaryReader(s);

            this.version = r.ReadUInt16();
            long tablePosition = r.ReadUInt32();

            r.BaseStream.Position = tablePosition;
            ushort entryCount = r.ReadUInt16();

            this.propertyIDList = new List <PropertyID>();
            for (ushort i = 0; i < entryCount; i++)
            {
                uint       type         = r.ReadUInt32();
                PropertyID id           = (PropertyID)type;
                uint       offset       = r.ReadUInt32();
                long       nextPosition = r.BaseStream.Position;
                r.BaseStream.Position = offset;
                int count = 0;
                this.propertyIDList.Add(id);
                switch (id)
                {
                case PropertyID.Name:
                    this.name = this.ReadString(r, this.OnResourceChanged);
                    break;

                case PropertyID.Tuning:
                    count       = r.ReadInt32();
                    this.tuning = Encoding.ASCII.GetString(r.ReadBytes(count));
                    break;

                case PropertyID.TuningID:
                    this.tuningID = r.ReadUInt64();                             // it might be swapped
                    break;

                case PropertyID.Icon:
                    this.icon = this.ReadTGIBlock(r, this.OnResourceChanged);
                    break;

                case PropertyID.Rig:
                    this.rig = this.ReadTGIBlock(r, this.OnResourceChanged);
                    break;

                case PropertyID.Slot:
                    this.slot = this.ReadTGIBlock(r, this.OnResourceChanged);
                    break;

                case PropertyID.Model:
                    this.model = this.ReadTGIBlock(r, this.OnResourceChanged);
                    break;

                case PropertyID.Footprint:
                    this.footprint = this.ReadTGIBlock(r, this.OnResourceChanged);
                    break;

                case PropertyID.Components:
                    int componentCount = r.ReadInt32();
                    this.components = new SimpleList <uint>(this.OnResourceChanged);
                    for (int m = 0; m < componentCount; m++)
                    {
                        this.components.Add(r.ReadUInt32());
                    }
                    break;

                case PropertyID.MaterialVariant:
                    this.materialVariant = this.ReadString(r, this.OnResourceChanged);
                    break;

                case PropertyID.Unknown1:
                    this.unknown1 = r.ReadByte();
                    break;

                case PropertyID.SimoleonPrice:
                    this.simoleonPrice = r.ReadUInt32();
                    break;

                case PropertyID.PositiveEnvironmentScore:
                    this.positiveEnvironmentScore = r.ReadSingle();
                    break;

                case PropertyID.NegativeEnvironmentScore:
                    this.negativeEnvironmentScore = r.ReadSingle();
                    break;

                case PropertyID.ThumbnailGeometryState:
                    this.thumbnailGeometryState = r.ReadUInt32();
                    break;

                case PropertyID.Unknown2:
                    this.Unknown2 = r.ReadBoolean();
                    break;

                case PropertyID.EnvironmentScoreEmotionTags:
                    count = r.ReadInt32();

                    var tags = new ushort[count];
                    for (int m = 0; m < count; m++)
                    {
                        tags[m] = r.ReadUInt16();
                    }

                    var catalogTags = tags.Select(CatalogTagRegistry.FetchTag)
                                      .Select(t => new CatalogTag(CatalogCommon.kRecommendedApiVersion, this.OnResourceChanged, t));

                    this.environmentScoreEmotionTags = new CatalogTagList(this.OnResourceChanged, catalogTags);

                    break;

                case PropertyID.EnvironmentScores:
                    count = r.ReadInt32();
                    this.environmentScores = new float[count];
                    for (int m = 0; m < count; m++)
                    {
                        this.environmentScores[m] = r.ReadSingle();
                    }
                    break;

                case PropertyID.Unknown3:
                    this.unknown3 = r.ReadUInt64();
                    break;

                case PropertyID.IsBaby:
                    this.isBaby = r.ReadBoolean();
                    break;

                case PropertyID.Unknown4:
                    count         = r.ReadInt32();
                    this.unknown4 = new byte[count];
                    for (int m = 0; m < count; m++)
                    {
                        this.unknown4[m] = r.ReadByte();
                    }
                    break;

                default:
                    break;
                }

                r.BaseStream.Position = nextPosition;
            }

            s.Position = 0;
            this.data  = r.ReadBytes((int)s.Length);
        }
Beispiel #31
0
 public SWAG(T[] array)
 {
     this.array = array;
     front = op.Identity;
     back = new SimpleList<T>();
 }
Beispiel #32
0
 internal override Automaton <BDD> getAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits)
 {
     return(BasicAutomata.MkTrue(alg));
 }
Beispiel #33
0
        /// <summary>
        ///     Provide completions for the specified location.
        /// </summary>
        /// <param name="location">
        ///     The <see cref="XmlLocation"/> where completions are requested.
        /// </param>
        /// <param name="projectDocument">
        ///     The <see cref="ProjectDocument"/> that contains the <paramref name="location"/>.
        /// </param>
        /// <param name="triggerCharacters">
        ///     The character(s), if any, that triggered completion.
        /// </param>
        /// <param name="cancellationToken">
        ///     A <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A <see cref="Task{TResult}"/> that resolves either a <see cref="CompletionList"/>s, or <c>null</c> if no completions are provided.
        /// </returns>
        public override async Task <CompletionList> ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            Log.Verbose("Evaluate completions for {XmlLocation:l}", location);

            List <CompletionItem> completions = new List <CompletionItem>();

            using (await projectDocument.Lock.ReaderLockAsync())
            {
                XSAttribute attribute;
                if (!location.CanCompleteAttributeValue(out attribute, onElementWithPath: WellKnownElementPaths.Target) || !SupportedAttributeNames.Contains(attribute.Name))
                {
                    Log.Verbose("Not offering any completions for {XmlLocation:l} (not the value of a supported attribute on a 'Target' element).", location);

                    return(null);
                }

                Range            targetRange        = attribute.ValueRange;
                HashSet <string> excludeTargetNames = new HashSet <string>();

                // Handle potentially composite (i.e. "Value1;Value2;Value3") values, where it's legal to have them.
                if (attribute.Name != "Name" && attribute.Value.IndexOf(';') != -1)
                {
                    int startPosition    = projectDocument.XmlPositions.GetAbsolutePosition(attribute.ValueRange.Start);
                    int relativePosition = location.AbsolutePosition - startPosition;

                    SimpleList     list           = MSBuildExpression.ParseSimpleList(attribute.Value);
                    SimpleListItem itemAtPosition = list.FindItemAt(relativePosition);
                    if (itemAtPosition == null)
                    {
                        return(null);
                    }

                    Log.Verbose("Completions will replace item {ItemValue} spanning [{ItemStartPosition}..{ItemEndPosition}) in MSBuild simple list expression {ListExpression}.",
                                itemAtPosition.Value,
                                itemAtPosition.AbsoluteStart,
                                itemAtPosition.AbsoluteEnd,
                                attribute.Value
                                );

                    targetRange = projectDocument.XmlPositions.GetRange(
                        absoluteStartPosition: startPosition + itemAtPosition.AbsoluteStart,
                        absoluteEndPosition: startPosition + itemAtPosition.AbsoluteEnd
                        );
                }

                completions.AddRange(
                    GetCompletionItems(projectDocument, targetRange, excludeTargetNames)
                    );
            }

            if (completions.Count == 0)
            {
                return(null); // No completions provided.
            }
            Log.Verbose("Offering {CompletionCount} completion(s) for {XmlLocation:l}", completions.Count, location);

            return(new CompletionList(completions,
                                      isIncomplete: false // Consider this list to be exhaustive
                                      ));
        }
        void Parse(Stream s)
        {
            s.Position = 0;
            BinaryReader r = new BinaryReader(s);

            version     = r.ReadUInt32();
            tgiOffset   = r.ReadUInt32() + 8;
            presetCount = r.ReadUInt32();
            if (presetCount != 0)
            {
                throw new Exception("Found non-zero one");
            }
            name = BigEndianUnicodeString.Read(s);

            sortPriority            = r.ReadSingle();
            this.secondarySortIndex = r.ReadUInt16();
            propertyID                      = r.ReadUInt32();
            this.auralMaterialHash          = r.ReadUInt32();
            this.parmFlags                  = (PramFlag)r.ReadByte();
            this.excludePartFlags           = r.ReadUInt64();
            this.excludeModifierRegionFlags = r.ReadUInt32();

            flagList = new FlagList(OnResourceChanged, s);

            this.simlolencePrice    = r.ReadUInt32();
            this.partTitleKey       = r.ReadUInt32();
            this.partDesptionKey    = r.ReadUInt32();
            this.uniqueTextureSpace = r.ReadByte();
            this.bodyType           = r.ReadInt32();
            this.unused1            = r.ReadInt32();
            this.ageGender          = r.ReadUInt32();
            this.unused2            = r.ReadByte();
            this.unused3            = r.ReadByte();

            swatchColorCode = new SwatchColorList(OnResourceChanged, s);

            this.buffResKey          = r.ReadByte();
            this.varientThumbnailKey = r.ReadByte();
            this.nakedKey            = r.ReadByte();
            this.parentKey           = r.ReadByte();
            this.sortLayer           = r.ReadInt32();

            // Don't move any of this before the -----
            // TGI block list
            long currentPosition = r.BaseStream.Position;

            r.BaseStream.Position = tgiOffset;
            byte count4 = r.ReadByte();

            tgiList = new CountedTGIBlockList(OnResourceChanged, "IGT", count4, s);
            r.BaseStream.Position = currentPosition;
            lodBlockList          = new LODBlockList(null, s, tgiList);
            //-------------

            byte count = r.ReadByte();

            this.slotKey = new SimpleList <byte>(null);
            for (byte i = 0; i < count; i++)
            {
                this.slotKey.Add(r.ReadByte());
            }

            this.difussShadowKey   = r.ReadByte();
            this.shadowKey         = r.ReadByte();
            this.compositionMethod = r.ReadByte();
            this.regionMapKey      = r.ReadByte();
            this.overrides         = r.ReadByte();
            this.normalMapKey      = r.ReadByte();
            this.specularMapKey    = r.ReadByte();
            if (this.version >= 0x1b)
            {
                this.unk4B = r.ReadUInt32();
            }
        }
 internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfFreeBits, bool singletonSetSemantics)
 {
     return(ToCore().GetAutomatonBDD(variables, alg, nrOfFreeBits, singletonSetSemantics));
 }
Beispiel #36
0
 internal override Automaton <IMonadicPredicate <BDD, T> > getAutomaton(SimpleList <Variable> variables, ICartesianAlgebraBDD <T> ca)
 {
     return(BasicAutomata.MkTrue(ca));
 }
 internal override Automaton <IMonadicPredicate <BDD, T> > GetAutomatonX(SimpleList <Variable> variables, ICartesianAlgebraBDD <T> alg, bool singletonSetSemantics)
 {
     return(ToCore().GetAutomatonX(variables, alg, singletonSetSemantics));
 }
Beispiel #38
0
        /// <summary>
        /// Initialize buffers and lists.
        /// </summary>
        /// <param name="config"></param>
        void InitializeData(ConvexHullComputationConfig config)
        {
            UnprocessedFaces = new FaceList();
            ConvexFaces = new IndexBuffer();

            FacePool = new ConvexFaceInternal[(Dimension + 1) * 10]; // must be initialized before object manager
            AffectedFaceFlags = new bool[(Dimension + 1) * 10];
            ObjectManager = new MIConvexHull.ObjectManager(this);

            Center = new double[Dimension];
            TraverseStack = new IndexBuffer();
            UpdateBuffer = new int[Dimension];
            UpdateIndices = new int[Dimension];
            EmptyBuffer = new IndexBuffer();
            AffectedFaceBuffer = new IndexBuffer();
            ConeFaceBuffer = new SimpleList<DeferredFace>();
            SingularVertices = new HashSet<int>();
            BeyondBuffer = new IndexBuffer();

            ConnectorTable = new ConnectorList[ConnectorTableSize];
            for (int i = 0; i < ConnectorTableSize; i++) ConnectorTable[i] = new ConnectorList();

            VertexMarks = new bool[Vertices.Length];
            InitializePositions(config);

            MathHelper = new MIConvexHull.MathHelper(Dimension, Positions);
        }
        static void Main(string[] args)
        {
            Rectangle rect   = new Rectangle(1, 9);
            Square    square = new Square(9);
            Circle    circle = new Circle(7);

            Console.WriteLine("ArrayList");
            ArrayList AL = new ArrayList();

            AL.Add(circle);
            AL.Add(rect);
            AL.Add(square);

            foreach (var x in AL)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nArrayList - сортировка");
            AL.Sort();
            foreach (var x in AL)
            {
                Console.WriteLine(x);
            }

            Console.WriteLine("\nList<GeometricFigure>");
            List <GeometricFigure> L = new List <GeometricFigure>();

            L.Add(circle);
            L.Add(rect);
            L.Add(square);

            foreach (var x in L)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nList<GeometricFigure> - сортировка");
            L.Sort();
            foreach (var x in AL)
            {
                Console.WriteLine(x);
            }

            Console.WriteLine("\nМатрица");
            Matrix 3D < GeometricFigure > MATRIX = newMatrix 3D < GeometricFigure > (3, 3, 3, null);
            MATRIX[0, 0, 0] = rect;
            MATRIX[1, 1, 1] = square;
            MATRIX[2, 2, 2] = circle;
            Console.WriteLine(MATRIX.ToString());

            Console.WriteLine("\nСписок");
            SimpleList <GeometricFigure> list = new SimpleList <GeometricFigure>();

            list.Add(square);
            list.Add(rect);
            list.Add(circle);
            foreach (var x in list)
            {
                Console.WriteLine(x);
            }
            list.Sort();
            Console.WriteLine("\nСортировкасписка");
            foreach (var x in list)
            {
                Console.WriteLine(x);
            }

            Console.WriteLine("\nСтек");
            SimpleStack <GeometricFigure> stack = new SimpleStack <GeometricFigure>();

            stack.Push(rect);
            stack.Push(square);
            stack.Push(circle);
            while (stack.Count > 0)
            {
                GeometricFigure f = stack.Pop();
                Console.WriteLine(f);
            }

            Console.ReadLine();
        }
        public void Parse(Stream s)
        {
            s.Position = 0;
            BinaryReader r = new BinaryReader(s);

            this.version = r.ReadUInt32();
            uint tgiOffset = r.ReadUInt32() + 8;

            // get TGI list
            long tempPosition = s.Position;

            s.Position = tgiOffset;
            TGIBlock[] _tgilist = new TGIBlock[r.ReadByte()];
            for (int i = 0; i < _tgilist.Length; i++)
            {
                _tgilist[i] = new TGIBlock(1, OnResourceChanged, "IGT", s);
            }
            this.tgiList = new CountedTGIBlockList(OnResourceChanged, _tgilist);
            s.Position   = tempPosition;

            this.unknown1 = r.ReadSingle();
            this.unknown2 = r.ReadSingle();
            this.unknown3 = r.ReadSingle();
            this.unknown4 = r.ReadSingle();
            this.unknown5 = r.ReadSingle();
            this.unknown6 = r.ReadSingle();
            this.unknown7 = r.ReadSingle();
            this.unknown8 = r.ReadSingle();

            this.age               = (AgeGenderFlags)r.ReadUInt32();
            this.gender            = (AgeGenderFlags)r.ReadUInt32();
            this.skinToneReference = r.ReadUInt64();

            byte[] unknown18 = new byte[r.ReadByte()];
            for (int i = 0; i < unknown18.Length; i++)
            {
                unknown18[i] = r.ReadByte();
            }
            this.unknown9 = new ByteIndexList(OnResourceChanged, unknown18, this.tgiList);

            sliderReferences1 = new SliderReferenceList(OnResourceChanged, s, tgiList);
            sliderReferences2 = new SliderReferenceList(OnResourceChanged, s, tgiList);

            this.unknown10 = new DataBlobHandler(RecommendedApiVersion, OnResourceChanged, r.ReadBytes(24));
            this.unknown11 = new UnknownBlockList(OnResourceChanged, s, this.tgiList);

            this.unknownByteList = new SimpleList <byte>(OnResourceChanged);
            int count1 = r.ReadByte();

            for (int i = 0; i < count1; i++)
            {
                this.unknownByteList.Add(r.ReadByte());
            }

            sliderReferences3 = new SliderReferenceList(OnResourceChanged, s, tgiList);
            sliderReferences4 = new SliderReferenceList(OnResourceChanged, s, tgiList);

            this.unknown12         = new DataBlobHandler(RecommendedApiVersion, OnResourceChanged, r.ReadBytes(16));
            this.sliderReferences5 = new SliderReferenceList(OnResourceChanged, s, tgiList);
            this.unknown13         = new DataBlobHandler(recommendedApiVersion, OnResourceChanged, r.ReadBytes(9));
            this.caspReference     = r.ReadUInt64();
            this.dataReferenceList = new SimpleList <ulong>(OnResourceChanged);
            int count2 = r.ReadByte();

            for (int i = 0; i < count2; i++)
            {
                this.dataReferenceList.Add(r.ReadUInt64());
            }
        }
Beispiel #41
0
        protected override Stream UnParse()
        {
            MemoryStream s = new MemoryStream();
            BinaryWriter w = new BinaryWriter(s);

            w.Write(this.version);
            w.Write(0); // tgi offset
            w.Write(presetCount);
            BigEndianUnicodeString.Write(s, name);
            w.Write(sortPriority);
            w.Write(secondarySortIndex);
            w.Write(propertyID);
            w.Write(auralMaterialHash);
            w.Write((byte)parmFlags);
            w.Write((ulong)excludePartFlags);
            w.Write(excludeModifierRegionFlags);
            if (this.flagList == null)
            {
                this.flagList = new FlagList(OnResourceChanged);
            }
            flagList.UnParse(s);
            w.Write(simlolencePrice);
            w.Write(partTitleKey);
            w.Write(partDesptionKey);
            w.Write(uniqueTextureSpace);
            w.Write(bodyType);
            w.Write(unused1);
            w.Write((uint)ageGender);
            w.Write(unused2);
            w.Write(unused3);
            if (this.swatchColorCode == null)
            {
                this.swatchColorCode = new SwatchColorList(OnResourceChanged);
            }
            swatchColorCode.UnParse(s);
            w.Write(buffResKey);
            w.Write(varientThumbnailKey);
            if (this.version >= 0x1C)
            {
                w.Write(voiceEffectHash);
            }
            w.Write(nakedKey);
            w.Write(parentKey);
            w.Write(sortLayer);
            if (this.lodBlockList == null)
            {
                this.lodBlockList = new LODBlockList(OnResourceChanged);
            }
            lodBlockList.UnParse(s);
            if (this.slotKey == null)
            {
                this.slotKey = new SimpleList <byte>(OnResourceChanged);
            }
            w.Write((byte)this.slotKey.Count);
            foreach (var b in this.slotKey)
            {
                w.Write(b);
            }
            w.Write(difussShadowKey);
            w.Write(shadowKey);
            w.Write(compositionMethod);
            w.Write(regionMapKey);
            w.Write(overrides);
            w.Write(normalMapKey);
            w.Write(specularMapKey);
            if (this.version >= 0x1b)
            {
                w.Write(sharedUVMapSpace);
            }

            long tgiPosition = w.BaseStream.Position;

            w.BaseStream.Position = 4;
            w.Write(tgiPosition - 8);
            w.BaseStream.Position = tgiPosition;
            if (this.tgiList == null)
            {
                this.tgiList = new CountedTGIBlockList(OnResourceChanged);
            }
            w.Write((byte)tgiList.Count);
            foreach (var tgi in tgiList)
            {
                tgi.UnParse(s);
            }

            return(s);
        }
Beispiel #42
0
        public async Task <IActionResult> Update([FromBody] UpdateTask dto)
        {
            if (dto == null)
            {
                return(BadRequest());
            }

            try
            {
                dto.UserId = IdentityHelper.GetUserId(User);
            }
            catch (UnauthorizedAccessException)
            {
                return(Unauthorized());
            }

            SimpleTask originalTask = await _taskService.GetAsync(dto.Id);

            await _taskService.UpdateAsync(dto, _updateValidator);

            // Notify
            if (dto.ListId == originalTask.ListId)
            {
                var usersToBeNotified = await _userService.GetToBeNotifiedOfListChangeAsync(dto.ListId, dto.UserId, dto.Id);

                if (usersToBeNotified.Any())
                {
                    var currentUser = await _userService.GetAsync(dto.UserId);

                    SimpleList list = await _listService.GetAsync(dto.ListId);

                    foreach (User user in usersToBeNotified)
                    {
                        CultureInfo.CurrentCulture = new CultureInfo(user.Language, false);
                        var message = _localizer["UpdatedTaskNotification", IdentityHelper.GetUserName(User), originalTask.Name, list.Name];

                        var createNotificationDto = new CreateOrUpdateNotification(user.Id, dto.UserId, list.Id, dto.Id, message);
                        var notificationId        = await _notificationService.CreateOrUpdateAsync(createNotificationDto);

                        var pushNotification = new PushNotification
                        {
                            SenderImageUri = currentUser.ImageUri,
                            UserId         = user.Id,
                            Application    = "To Do Assistant",
                            Message        = message,
                            OpenUrl        = GetNotificationsPageUrl(notificationId)
                        };

                        _senderService.Enqueue(pushNotification);
                    }
                }
            }
            else
            {
                SimpleList oldList = await _listService.GetAsync(originalTask.ListId);

                SimpleList newList = await _listService.GetAsync(dto.ListId);

                var currentUserName = IdentityHelper.GetUserName(User);

                var usersToBeNotifiedOfRemoval = await _userService.GetToBeNotifiedOfListChangeAsync(oldList.Id, dto.UserId, dto.Id);

                if (usersToBeNotifiedOfRemoval.Any())
                {
                    var currentUser = await _userService.GetAsync(dto.UserId);

                    foreach (var user in usersToBeNotifiedOfRemoval)
                    {
                        CultureInfo.CurrentCulture = new CultureInfo(user.Language, false);
                        var message = _localizer["RemovedTaskNotification", currentUserName, originalTask.Name, oldList.Name];

                        var createNotificationDto = new CreateOrUpdateNotification(user.Id, dto.UserId, oldList.Id, null, message);
                        var notificationId        = await _notificationService.CreateOrUpdateAsync(createNotificationDto);

                        var pushNotification = new PushNotification
                        {
                            SenderImageUri = currentUser.ImageUri,
                            UserId         = user.Id,
                            Application    = "To Do Assistant",
                            Message        = message,
                            OpenUrl        = GetNotificationsPageUrl(notificationId)
                        };

                        _senderService.Enqueue(pushNotification);
                    }
                }

                var usersToBeNotifiedOfCreation = await _userService.GetToBeNotifiedOfListChangeAsync(newList.Id, dto.UserId, dto.Id);

                if (usersToBeNotifiedOfCreation.Any())
                {
                    var currentUser = await _userService.GetAsync(dto.UserId);

                    foreach (var user in usersToBeNotifiedOfCreation)
                    {
                        CultureInfo.CurrentCulture = new CultureInfo(user.Language, false);
                        var message = _localizer["CreatedTaskNotification", currentUserName, dto.Name, newList.Name];

                        var createNotificationDto = new CreateOrUpdateNotification(user.Id, dto.UserId, newList.Id, dto.Id, message);
                        var notificationId        = await _notificationService.CreateOrUpdateAsync(createNotificationDto);

                        var pushNotification = new PushNotification
                        {
                            SenderImageUri = currentUser.ImageUri,
                            UserId         = user.Id,
                            Application    = "To Do Assistant",
                            Message        = message,
                            OpenUrl        = GetNotificationsPageUrl(notificationId)
                        };

                        _senderService.Enqueue(pushNotification);
                    }
                }
            }

            // Notify if assigned to another user
            if (dto.AssignedToUserId.HasValue &&
                dto.AssignedToUserId.Value != originalTask.AssignedToUserId &&
                dto.AssignedToUserId.Value != dto.UserId)
            {
                if (await _userService.CheckIfUserCanBeNotifiedOfListChangeAsync(dto.ListId, dto.AssignedToUserId.Value))
                {
                    var assignedUser = await _userService.GetAsync(dto.AssignedToUserId.Value);

                    SimpleList list = await _listService.GetAsync(dto.ListId);

                    CultureInfo.CurrentCulture = new CultureInfo(assignedUser.Language, false);
                    var message = _localizer["AssignedTaskNotification", IdentityHelper.GetUserName(User), originalTask.Name, list.Name];

                    var createNotificationDto = new CreateOrUpdateNotification(assignedUser.Id, dto.UserId, list.Id, dto.Id, message);
                    var notificationId        = await _notificationService.CreateOrUpdateAsync(createNotificationDto);

                    var pushNotification = new PushNotification
                    {
                        UserId      = assignedUser.Id,
                        Application = "To Do Assistant",
                        Message     = message,
                        OpenUrl     = GetNotificationsPageUrl(notificationId)
                    };

                    _senderService.Enqueue(pushNotification);
                }
            }

            return(NoContent());
        }
Beispiel #43
0
 internal override IEnumerable <Variable> EnumerateFreeVariables(SimpleList <Variable> bound, HashSet <Variable> free)
 {
     yield break;
 }
 public MyEnterprisesRecomendationsVM()
 {
     myEnterprisesrecomendations = new SimpleList <Enterprise>();
     myEnterprisesrecomendations.setHead(new Node <Enterprise>());
     myEnterprisesrecomendations.getHead().setData(new Enterprise("email", "EnterpriseRecomendada", "pass"));
 }
Beispiel #45
0
        public void PerformTileWall(clsWallType WallType, sXY_int TileNum, bool Expand)
        {
            sXY_int SectorNum = new sXY_int();
            clsUnit Unit = default(clsUnit);
            sXY_int UnitTile = new sXY_int();
            sXY_int Difference = new sXY_int();
            App.enumTileWalls TileWalls = App.enumTileWalls.None;
            SimpleList<clsUnit> Walls = new SimpleList<clsUnit>();
            SimpleList<clsUnit> Removals = new SimpleList<clsUnit>();
            clsUnitType UnitType = default(clsUnitType);
            clsStructureType StructureType = default(clsStructureType);
            int X = 0;
            int Y = 0;
            sXY_int MinTile = new sXY_int();
            sXY_int MaxTile = new sXY_int();
            clsUnitSectorConnection Connection = default(clsUnitSectorConnection);
            MinTile.X = TileNum.X - 1;
            MinTile.Y = TileNum.Y - 1;
            MaxTile.X = TileNum.X + 1;
            MaxTile.Y = TileNum.Y + 1;
            sXY_int SectorStart = GetSectorNumClamped(GetTileSectorNum(MinTile));
            sXY_int SectorFinish = GetSectorNumClamped(GetTileSectorNum(MaxTile));

            for ( Y = SectorStart.Y; Y <= SectorFinish.Y; Y++ )
            {
                for ( X = SectorStart.X; X <= SectorFinish.X; X++ )
                {
                    SectorNum.X = X;
                    SectorNum.Y = Y;
                    foreach ( clsUnitSectorConnection tempLoopVar_Connection in Sectors[SectorNum.X, SectorNum.Y].Units )
                    {
                        Connection = tempLoopVar_Connection;
                        Unit = Connection.Unit;
                        UnitType = Unit.Type;
                        if ( UnitType.Type == clsUnitType.enumType.PlayerStructure )
                        {
                            StructureType = (clsStructureType)UnitType;
                            if ( StructureType.WallLink.Source == WallType )
                            {
                                UnitTile = GetPosTileNum(Unit.Pos.Horizontal);
                                Difference.X = UnitTile.X - TileNum.X;
                                Difference.Y = UnitTile.Y - TileNum.Y;
                                if ( Difference.Y == 1 )
                                {
                                    if ( Difference.X == 0 )
                                    {
                                        TileWalls = (App.enumTileWalls)(TileWalls | App.enumTileWalls.Bottom);
                                        Walls.Add(Unit);
                                    }
                                }
                                else if ( Difference.Y == 0 )
                                {
                                    if ( Difference.X == 0 )
                                    {
                                        Removals.Add(Unit);
                                    }
                                    else if ( Difference.X == -1 )
                                    {
                                        TileWalls = (App.enumTileWalls)(TileWalls | App.enumTileWalls.Left);
                                        Walls.Add(Unit);
                                    }
                                    else if ( Difference.X == 1 )
                                    {
                                        TileWalls = (App.enumTileWalls)(TileWalls | App.enumTileWalls.Right);
                                        Walls.Add(Unit);
                                    }
                                }
                                else if ( Difference.Y == -1 )
                                {
                                    if ( Difference.X == 0 )
                                    {
                                        TileWalls = (App.enumTileWalls)(TileWalls | App.enumTileWalls.Top);
                                        Walls.Add(Unit);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            foreach ( clsUnit tempLoopVar_Unit in Removals )
            {
                Unit = tempLoopVar_Unit;
                UnitRemoveStoreChange(Unit.MapLink.ArrayPosition);
            }

            clsUnit NewUnit = new clsUnit();
            clsUnitType NewUnitType = WallType.Segments[WallType.TileWalls_Segment[(int)TileWalls]];
            NewUnit.Rotation = WallType.TileWalls_Direction[(int)TileWalls];
            if ( Expand )
            {
                NewUnit.UnitGroup = SelectedUnitGroup.Item;
            }
            else
            {
                if ( Removals.Count == 0 )
                {
                    Debugger.Break();
                    return;
                }
                NewUnit.UnitGroup = Removals[0].UnitGroup;
            }
            NewUnit.Pos = TileAlignedPos(TileNum, new sXY_int(1, 1));
            NewUnit.Type = NewUnitType;
            clsUnitAdd UnitAdd = new clsUnitAdd();
            UnitAdd.Map = this;
            UnitAdd.NewUnit = NewUnit;
            UnitAdd.StoreChange = true;
            UnitAdd.Perform();

            if ( Expand )
            {
                clsUnit Wall = default(clsUnit);
                foreach ( clsUnit tempLoopVar_Wall in Walls )
                {
                    Wall = tempLoopVar_Wall;
                    PerformTileWall(WallType, GetPosTileNum(Wall.Pos.Horizontal), false);
                }
            }
        }
Beispiel #46
0
 internal abstract Automaton <BDD> getAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits);
Beispiel #47
0
        public void UndoPerform()
        {
            clsUndo ThisUndo = default(clsUndo);

            UndoStepCreate("Incomplete Action"); //make another redo step incase something has changed, such as if user presses undo while still dragging a tool

            UndoPosition--;

            ThisUndo = Undos[UndoPosition];

            sXY_int SectorNum = new sXY_int();
            clsShadowSector CurrentSector = default(clsShadowSector);
            clsShadowSector UndoSector = default(clsShadowSector);
            SimpleList<clsShadowSector> NewSectorsForThisUndo = new SimpleList<clsShadowSector>();
            foreach ( clsShadowSector tempLoopVar_UndoSector in ThisUndo.ChangedSectors )
            {
                UndoSector = tempLoopVar_UndoSector;
                SectorNum = UndoSector.Num;
                //store existing state for redo
                CurrentSector = ShadowSectors[SectorNum.X, SectorNum.Y];
                //remove graphics from sector
                Sectors[SectorNum.X, SectorNum.Y].DeleteLists();
                //perform the undo
                Undo_Sector_Rejoin(UndoSector);
                //update the backup
                ShadowSector_Create(SectorNum);
                //add old state to the redo step (that was this undo step)
                NewSectorsForThisUndo.Add(CurrentSector);
                //prepare to update graphics on this sector
                SectorGraphicsChanges.Changed(SectorNum);
            }
            ThisUndo.ChangedSectors = NewSectorsForThisUndo;

            UInt32 ID = 0;
            clsUnitAdd UnitAdd = new clsUnitAdd();
            UnitAdd.Map = this;
            clsUnit Unit = default(clsUnit);
            for ( int A = ThisUndo.UnitChanges.Count - 1; A >= 0; A-- ) //must do in reverse order, otherwise may try to delete units that havent been added yet
            {
                Unit = ThisUndo.UnitChanges[A].Unit;
                if ( ThisUndo.UnitChanges[A].Type == clsUnitChange.enumType.Added )
                {
                    //remove the unit from the map
                    UnitRemove(Unit.MapLink.ArrayPosition);
                }
                else if ( ThisUndo.UnitChanges[A].Type == clsUnitChange.enumType.Deleted )
                {
                    //add the unit back on to the map
                    ID = Unit.ID;
                    UnitAdd.ID = ID;
                    UnitAdd.NewUnit = Unit;
                    UnitAdd.Perform();
                    App.ErrorIDChange(ID, Unit, "Undo_Perform");
                }
                else
                {
                    Debugger.Break();
                }
            }

            clsGatewayChange GatewayChange = default(clsGatewayChange);
            for ( int A = ThisUndo.GatewayChanges.Count - 1; A >= 0; A-- )
            {
                GatewayChange = ThisUndo.GatewayChanges[A];
                switch ( GatewayChange.Type )
                {
                    case clsGatewayChange.enumType.Added:
                        //remove the unit from the map
                        GatewayChange.Gateway.MapLink.Disconnect();
                        break;
                    case clsGatewayChange.enumType.Deleted:
                        //add the unit back on to the map
                        GatewayChange.Gateway.MapLink.Connect(Gateways);
                        break;
                    default:
                        Debugger.Break();
                        break;
                }
            }

            SectorsUpdateGraphics();
            MinimapMakeLater();
            Program.frmMainInstance.SelectedObject_Changed();
        }
Beispiel #48
0
 public UserMenuVM()
 {
     userMenuVM = Client.getInstance().getUser().getMymenu();
 }
 public void ListSupportsKnowsTheLengthOfAnyList()
 {
     var listSupport = new ListSupport();
     var list = new SimpleList<int> { 1, 2, 3, 4, 5, 6, 7 };
     Assert.AreEqual(list.Count, listSupport.GetLength(list));
 }
Beispiel #50
0
        public static SimpleList<string> BytesToLinesRemoveComments(BinaryReader reader)
        {
            char CurrentChar = (char)0;
            bool CurrentCharExists = default(bool);
            bool InLineComment = default(bool);
            bool InCommentBlock = default(bool);
            char PrevChar = (char)0;
            bool PrevCharExists = default(bool);
            string Line = "";
            SimpleList<string> Result = new SimpleList<string>();

            do
            {
                MonoContinueDo:
                PrevChar = CurrentChar;
                PrevCharExists = CurrentCharExists;
                try
                {
                    CurrentChar = reader.ReadChar();
                    CurrentCharExists = true;
                }
                catch ( Exception )
                {
                    CurrentCharExists = false;
                }
                if ( CurrentCharExists )
                {
                    switch ( CurrentChar )
                    {
                        case ControlChars.Cr:
                        case ControlChars.Lf:
                            InLineComment = false;
                            if ( PrevCharExists )
                            {
                                Line += PrevChar.ToString();
                            }
                            CurrentCharExists = false;

                            if ( Line.Length > 0 )
                            {
                                Result.Add(Line);
                                Line = "";
                            }

                            goto MonoContinueDo;
                        case '*':
                            if ( PrevCharExists && PrevChar == '/' )
                            {
                                InCommentBlock = true;
                                CurrentCharExists = false;
                                goto MonoContinueDo;
                            }
                            break;
                        case '/':
                            if ( PrevCharExists )
                            {
                                if ( PrevChar == '/' )
                                {
                                    InLineComment = true;
                                    CurrentCharExists = false;
                                    goto MonoContinueDo;
                                }
                                else if ( PrevChar == '*' )
                                {
                                    InCommentBlock = false;
                                    CurrentCharExists = false;
                                    goto MonoContinueDo;
                                }
                            }
                            break;
                    }
                }
                else
                {
                    InLineComment = false;
                    if ( PrevCharExists )
                    {
                        Line += PrevChar.ToString();
                    }
                    if ( Line.Length > 0 )
                    {
                        Result.Add(Line);
                        Line = "";
                    }

                    break;
                }
                if ( PrevCharExists )
                {
                    if ( !(InCommentBlock || InLineComment) )
                    {
                        Line += PrevChar.ToString();
                    }
                }
            } while ( true );

            return Result;
        }
		protected void Parse(Stream s)
		{
			if (s == null) s = this.UnParse();
			s.Position = 0;
			BinaryReader r = new BinaryReader(s);
			this.version = r.ReadUInt16();
			long tablePosition = r.ReadUInt32();

			r.BaseStream.Position = tablePosition;
			ushort entryCount = r.ReadUInt16();
			this.propertyIDList = new List<PropertyID>();
			for (ushort i = 0; i < entryCount; i++)
			{
				uint type = r.ReadUInt32();
				PropertyID id = (PropertyID)type;
				uint offset = r.ReadUInt32();
				long nextPosition = r.BaseStream.Position;
				r.BaseStream.Position = offset;
				int count = 0;
				this.propertyIDList.Add(id);
				switch (id)
				{
					case PropertyID.Name:
						this.name = this.ReadString(r, this.OnResourceChanged);
						break;
					case PropertyID.Tuning:
						count = r.ReadInt32();
						this.tuning = Encoding.ASCII.GetString(r.ReadBytes(count));
						break;
					case PropertyID.TuningID:
						this.tuningID = r.ReadUInt64(); // it might be swapped
						break;
					case PropertyID.Icon:
						this.icon = this.ReadTGIBlock(r, this.OnResourceChanged);
						break;
					case PropertyID.Rig:
						this.rig = this.ReadTGIBlock(r, this.OnResourceChanged);
						break;
					case PropertyID.Slot:
						this.slot = this.ReadTGIBlock(r, this.OnResourceChanged);
						break;
					case PropertyID.Model:
						this.model = this.ReadTGIBlock(r, this.OnResourceChanged);
						break;
					case PropertyID.Footprint:
						this.footprint = this.ReadTGIBlock(r, this.OnResourceChanged);
						break;
					case PropertyID.Components:
						int componentCount = r.ReadInt32();
						this.components = new SimpleList<uint>(this.OnResourceChanged);
						for (int m = 0; m < componentCount; m++) this.components.Add(r.ReadUInt32());
						break;
					case PropertyID.MaterialVariant:
						this.materialVariant = this.ReadString(r, this.OnResourceChanged);
						break;
					case PropertyID.Unknown1:
						this.unknown1 = r.ReadByte();
						break;
					case PropertyID.SimoleonPrice:
						this.simoleonPrice = r.ReadUInt32();
						break;
					case PropertyID.PositiveEnvironmentScore:
						this.positiveEnvironmentScore = r.ReadSingle();
						break;
					case PropertyID.NegativeEnvironmentScore:
						this.negativeEnvironmentScore = r.ReadSingle();
						break;
					case PropertyID.ThumbnailGeometryState:
						this.thumbnailGeometryState = r.ReadUInt32();
						break;
					case PropertyID.Unknown2:
						this.Unknown2 = r.ReadBoolean();
						break;
					case PropertyID.EnvironmentScoreEmotionTags:
						count = r.ReadInt32();

						var tags = new ushort[count];
						for (int m = 0; m < count; m++)
						{
							tags[m] = r.ReadUInt16();
						}

						var catalogTags = tags.Select(CatalogTagRegistry.FetchTag)
											  .Select(t => new CatalogTag(CatalogCommon.kRecommendedApiVersion, this.OnResourceChanged, t));

						this.environmentScoreEmotionTags = new CatalogTagList(this.OnResourceChanged, catalogTags);

						break;
					case PropertyID.EnvironmentScores:
						count = r.ReadInt32();
						this.environmentScores = new float[count];
						for (int m = 0; m < count; m++) this.environmentScores[m] = r.ReadSingle();
						break;
					case PropertyID.Unknown3:
						this.unknown3 = r.ReadUInt64();
						break;
					case PropertyID.IsBaby:
						this.isBaby = r.ReadBoolean();
						break;
					case PropertyID.Unknown4:
						count = r.ReadInt32();
						this.unknown4 = new byte[count];
						for (int m = 0; m < count; m++) this.unknown4[m] = r.ReadByte();
						break;
					default:
						break;
				}

				r.BaseStream.Position = nextPosition;

			}

			s.Position = 0;
			this.data = r.ReadBytes((int)s.Length);
		}
 public ObjectEnumerator(object rootInstance)
 {
     _allReferences = new Dictionary<object, int>();
     _allInstances = new SimpleList<object>();
     Check(rootInstance);
 }
Beispiel #53
0
        /// <summary>
        /// Finds the list of locations that will be captured if a token was placed at the current location by the given player
        /// </summary>
        /// <param name="player">The player placing the token</param>
        /// <returns>The list of captured token locations</returns>
        private static SimpleList<int> FindCapturedTokens()
        {
            int player = Battle.CurrentTurn;
            SimpleList<int> spots = new SimpleList<int>();

            // Checks in all 8 directions, starting with North
            for (int d = 0; d < 8; ++d)
            {
                int searchX = Battle.X + xChanges[d];
                int searchY = Battle.Y + yChanges[d];

                // Gets the list of possible moves
                SimpleList<int> possibleSpots = new SimpleList<int>();

                // Allow it to search only within the grid's range
                while (searchX >= 0 && searchX < 10 && searchY >= 0 && searchY < 10)
                {
                    int spot = Battle.Field[10 * searchY + searchX];

                    // If it's an enemy piece, remember the location
                    if (spot == 3 - player)
                        possibleSpots.Add(10 * searchY + searchX);

                    // Stop when it's an owned piece
                    else if (possibleSpots.Size > 0 && spot == player)
                    {
                        break;
                    }

                    // Stop and clear the list if it's an empty piece
                    else
                    {
                        possibleSpots.Clear();
                        break;
                    }
                    searchX += xChanges[d];
                    searchY += yChanges[d];
                }

                // If the loop ended because of going out of range, clear the list
                if (searchX < 0 || searchX > 9 || searchY < 0 || searchY > 9)
                    possibleSpots.Clear();

                // Add all the valid spots found that weren't cleared
                foreach (int i in possibleSpots)
                    spots.Add(i);
            }
            return spots;
        }
 internal abstract Automaton <IMonadicPredicate <BDD, T> > GetAutomatonX(SimpleList <Variable> variables, ICartesianAlgebraBDD <T> alg, bool singletonSetSemantics);
 internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits, bool singletonSetSemantics)
 {
     return(BasicAutomata.MkFalse(alg));
 }
 internal override Automaton <IMonadicPredicate <BDD, T> > GetAutomatonX(SimpleList <Variable> variables, ICartesianAlgebraBDD <T> alg, bool singletonSetSemantics)
 {
     return(BasicAutomata.MkFalse <T>(alg));
 }
Beispiel #57
0
        public void RedoPerform()
        {
            clsUndo ThisUndo = default(clsUndo);

            ThisUndo = Undos[UndoPosition];

            sXY_int SectorNum = new sXY_int();
            clsShadowSector CurrentSector = default(clsShadowSector);
            clsShadowSector UndoSector = default(clsShadowSector);
            SimpleList<clsShadowSector> NewSectorsForThisUndo = new SimpleList<clsShadowSector>();
            foreach ( clsShadowSector tempLoopVar_UndoSector in ThisUndo.ChangedSectors )
            {
                UndoSector = tempLoopVar_UndoSector;
                SectorNum = UndoSector.Num;
                //store existing state for undo
                CurrentSector = ShadowSectors[SectorNum.X, SectorNum.Y];
                //remove graphics from sector
                Sectors[SectorNum.X, SectorNum.Y].DeleteLists();
                //perform the redo
                Undo_Sector_Rejoin(UndoSector);
                //update the backup
                ShadowSector_Create(SectorNum);
                //add old state to the undo step (that was this redo step)
                NewSectorsForThisUndo.Add(CurrentSector);
                //prepare to update graphics on this sector
                SectorGraphicsChanges.Changed(SectorNum);
            }
            ThisUndo.ChangedSectors = NewSectorsForThisUndo;

            UInt32 ID = 0;
            clsUnitAdd UnitAdd = new clsUnitAdd();
            UnitAdd.Map = this;
            clsUnit Unit = default(clsUnit);
            for ( int A = 0; A <= ThisUndo.UnitChanges.Count - 1; A++ ) //forward order is important
            {
                Unit = ThisUndo.UnitChanges[A].Unit;
                if ( ThisUndo.UnitChanges[A].Type == clsUnitChange.enumType.Added )
                {
                    //add the unit back on to the map
                    ID = Unit.ID;
                    UnitAdd.ID = ID;
                    UnitAdd.NewUnit = Unit;
                    UnitAdd.Perform();
                    App.ErrorIDChange(ID, Unit, "Redo_Perform");
                }
                else if ( ThisUndo.UnitChanges[A].Type == clsUnitChange.enumType.Deleted )
                {
                    //remove the unit from the map
                    UnitRemove(Unit.MapLink.ArrayPosition);
                }
                else
                {
                    Debugger.Break();
                }
            }

            clsGatewayChange GatewayChange = default(clsGatewayChange);
            for ( int A = 0; A <= ThisUndo.GatewayChanges.Count - 1; A++ ) //forward order is important
            {
                GatewayChange = ThisUndo.GatewayChanges[A];
                switch ( GatewayChange.Type )
                {
                    case clsGatewayChange.enumType.Added:
                        //add the unit back on to the map
                        GatewayChange.Gateway.MapLink.Connect(Gateways);
                        break;
                    case clsGatewayChange.enumType.Deleted:
                        //remove the unit from the map
                        GatewayChange.Gateway.MapLink.Disconnect();
                        break;
                    default:
                        Debugger.Break();
                        break;
                }
            }

            UndoPosition++;

            SectorsUpdateGraphics();
            MinimapMakeLater();
            Program.frmMainInstance.SelectedObject_Changed();
        }
        internal override Automaton <BDD> GetAutomatonBDD(SimpleList <Variable> variables, IBDDAlgebra alg, int nrOfLabelBits, bool singletonSetSemantics)
        {
            var pos = GetVarIndex(var, variables) + nrOfLabelBits;

            return(BasicAutomata.MkSingleton(pos, alg));
        }
Beispiel #59
0
        public void MapInsert(clsMap MapToInsert, sXY_int Offset, sXY_int Area, bool InsertHeights, bool InsertTextures, bool InsertUnits,
            bool DeleteUnits, bool InsertGateways, bool DeleteGateways)
        {
            sXY_int Finish = new sXY_int();
            int X = 0;
            int Y = 0;
            sXY_int SectorStart = new sXY_int();
            sXY_int SectorFinish = new sXY_int();
            sXY_int AreaAdjusted = new sXY_int();
            sXY_int SectorNum = new sXY_int();

            Finish.X = Math.Min(Offset.X + Math.Min(Area.X, MapToInsert.Terrain.TileSize.X), Terrain.TileSize.X);
            Finish.Y = Math.Min(Offset.Y + Math.Min(Area.Y, MapToInsert.Terrain.TileSize.Y), Terrain.TileSize.Y);
            AreaAdjusted.X = Finish.X - Offset.X;
            AreaAdjusted.Y = Finish.Y - Offset.Y;

            GetTileSectorRange(new sXY_int(Offset.X - 1, Offset.Y - 1), Finish, ref SectorStart, ref SectorFinish);
            for ( Y = SectorStart.Y; Y <= SectorFinish.Y; Y++ )
            {
                SectorNum.Y = Y;
                for ( X = SectorStart.X; X <= SectorFinish.X; X++ )
                {
                    SectorNum.X = X;
                    SectorGraphicsChanges.Changed(SectorNum);
                    SectorUnitHeightsChanges.Changed(SectorNum);
                    SectorTerrainUndoChanges.Changed(SectorNum);
                }
            }

            if ( InsertHeights )
            {
                for ( Y = 0; Y <= AreaAdjusted.Y; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X; X++ )
                    {
                        Terrain.Vertices[Offset.X + X, Offset.Y + Y].Height = MapToInsert.Terrain.Vertices[X, Y].Height;
                    }
                }
                for ( Y = 0; Y <= AreaAdjusted.Y - 1; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X - 1; X++ )
                    {
                        Terrain.Tiles[Offset.X + X, Offset.Y + Y].Tri = MapToInsert.Terrain.Tiles[X, Y].Tri;
                    }
                }
            }
            if ( InsertTextures )
            {
                for ( Y = 0; Y <= AreaAdjusted.Y; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X; X++ )
                    {
                        Terrain.Vertices[Offset.X + X, Offset.Y + Y].Terrain = MapToInsert.Terrain.Vertices[X, Y].Terrain;
                    }
                }
                bool TriDirection = default(bool);
                for ( Y = 0; Y <= AreaAdjusted.Y - 1; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X - 1; X++ )
                    {
                        TriDirection = Terrain.Tiles[Offset.X + X, Offset.Y + Y].Tri;
                        Terrain.Tiles[Offset.X + X, Offset.Y + Y].Copy(MapToInsert.Terrain.Tiles[X, Y]);
                        Terrain.Tiles[Offset.X + X, Offset.Y + Y].Tri = TriDirection;
                    }
                }
                for ( Y = 0; Y <= AreaAdjusted.Y; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X - 1; X++ )
                    {
                        Terrain.SideH[Offset.X + X, Offset.Y + Y].Road = MapToInsert.Terrain.SideH[X, Y].Road;
                    }
                }
                for ( Y = 0; Y <= AreaAdjusted.Y - 1; Y++ )
                {
                    for ( X = 0; X <= AreaAdjusted.X; X++ )
                    {
                        Terrain.SideV[Offset.X + X, Offset.Y + Y].Road = MapToInsert.Terrain.SideV[X, Y].Road;
                    }
                }
            }

            sXY_int LastTile = new sXY_int();
            LastTile = Finish;
            LastTile.X--;
            LastTile.Y--;
            if ( DeleteGateways )
            {
                int A = 0;
                A = 0;
                while ( A < Gateways.Count )
                {
                    if ( Gateways[A].PosA.IsInRange(Offset, LastTile) || Gateways[A].PosB.IsInRange(Offset, LastTile) )
                    {
                        GatewayRemoveStoreChange(A);
                    }
                    else
                    {
                        A++;
                    }
                }
            }
            if ( InsertGateways )
            {
                sXY_int GateStart = new sXY_int();
                sXY_int GateFinish = new sXY_int();
                clsGateway Gateway = default(clsGateway);
                foreach ( clsGateway tempLoopVar_Gateway in MapToInsert.Gateways )
                {
                    Gateway = tempLoopVar_Gateway;
                    GateStart.X = Offset.X + Gateway.PosA.X;
                    GateStart.Y = Offset.Y + Gateway.PosA.Y;
                    GateFinish.X = Offset.X + Gateway.PosB.X;
                    GateFinish.Y = Offset.Y + Gateway.PosB.Y;
                    if ( GateStart.IsInRange(Offset, LastTile) || GateFinish.IsInRange(Offset, LastTile) )
                    {
                        GatewayCreateStoreChange(GateStart, GateFinish);
                    }
                }
            }

            if ( DeleteUnits )
            {
                SimpleList<clsUnit> UnitsToDelete = new SimpleList<clsUnit>();
                int UnitToDeleteCount = 0;
                clsUnit Unit = default(clsUnit);
                for ( Y = SectorStart.Y; Y <= SectorFinish.Y; Y++ )
                {
                    for ( X = SectorStart.X; X <= SectorFinish.X; X++ )
                    {
                        clsUnitSectorConnection Connection = default(clsUnitSectorConnection);
                        foreach ( clsUnitSectorConnection tempLoopVar_Connection in Sectors[X, Y].Units )
                        {
                            Connection = tempLoopVar_Connection;
                            Unit = Connection.Unit;
                            if ( App.PosIsWithinTileArea(Unit.Pos.Horizontal, Offset, Finish) )
                            {
                                UnitsToDelete.Add(Unit);
                            }
                        }
                    }
                }
                foreach ( clsUnit tempLoopVar_Unit in UnitsToDelete )
                {
                    Unit = tempLoopVar_Unit;
                    if ( Unit.MapLink.IsConnected ) //units may be in the list multiple times and already be deleted
                    {
                        UnitRemoveStoreChange(Unit.MapLink.ArrayPosition);
                    }
                }
            }
            if ( InsertUnits )
            {
                sXY_int PosDif = new sXY_int();
                clsUnit NewUnit = default(clsUnit);
                clsUnit Unit = default(clsUnit);
                sXY_int ZeroPos = new sXY_int(0, 0);
                clsUnitAdd UnitAdd = new clsUnitAdd();

                UnitAdd.Map = this;
                UnitAdd.StoreChange = true;

                PosDif.X = Offset.X * App.TerrainGridSpacing;
                PosDif.Y = Offset.Y * App.TerrainGridSpacing;
                foreach ( clsUnit tempLoopVar_Unit in MapToInsert.Units )
                {
                    Unit = tempLoopVar_Unit;
                    if ( App.PosIsWithinTileArea(Unit.Pos.Horizontal, ZeroPos, AreaAdjusted) )
                    {
                        NewUnit = new clsUnit(Unit, this);
                        NewUnit.Pos.Horizontal.X += PosDif.X;
                        NewUnit.Pos.Horizontal.Y += PosDif.Y;
                        UnitAdd.NewUnit = NewUnit;
                        UnitAdd.Label = Unit.Label;
                        UnitAdd.Perform();
                    }
                }
            }

            SectorsUpdateGraphics();
            SectorsUpdateUnitHeights();
            MinimapMakeLater();
        }
Beispiel #60
0
        protected override Stream UnParse()
        {
            var s = new MemoryStream();
            var w = new BinaryWriter(s);

            w.Write(this.version);
            w.Write(0); // tgi offset
            w.Write(this.presetCount);
            BigEndianUnicodeString.Write(s, this.name);
            w.Write(this.sortPriority);
            w.Write(this.secondarySortIndex);
            w.Write(this.propertyID);
            w.Write(this.auralMaterialHash);
            w.Write((byte)this.parmFlags);
            w.Write((ulong)this.excludePartFlags);
            if (this.version >= 36)
            {
                w.Write(this.excludeModifierRegionFlags);
            }
            else
            {
                w.Write((uint)this.excludeModifierRegionFlags);
            }

            this.flagList = this.flagList ?? new FlagList(this.OnResourceChanged);
            if (this.version >= 37)
            {
                this.flagList.UnParse(s);
            }
            else
            {
                this.flagList.WriteUInt16Flags(s);
            }
            w.Write(this.deprecatedPrice);
            w.Write(this.partTitleKey);
            w.Write(this.partDesptionKey);
            w.Write(this.uniqueTextureSpace);
            w.Write((uint)this.bodyType);
            w.Write(this.bodySubType);
            w.Write((uint)this.ageGender);
            if (this.version >= 0x20)
            {
                w.Write(this.reserved1);
            }
            if (this.version >= 34)
            {
                w.Write(this.packID);
                w.Write((byte)this.packFlags);
                if (this.reserved2 == null)
                {
                    this.reserved2 = new byte[9];
                }
                w.Write(this.reserved2);
            }
            else
            {
                w.Write(this.unused2);
                if (this.unused2 > 0)
                {
                    w.Write(this.unused3);
                }
            }
            if (this.swatchColorCode == null)
            {
                this.swatchColorCode = new SwatchColorList(this.OnResourceChanged);
            }
            this.swatchColorCode.UnParse(s);
            w.Write(this.buffResKey);
            w.Write(this.varientThumbnailKey);
            if (this.version >= 0x1C)
            {
                w.Write(this.voiceEffectHash);
            }
            if (this.version >= 0x1E)
            {
                w.Write(this.usedMaterialCount);
                if (this.usedMaterialCount > 0)
                {
                    w.Write(this.materialSetUpperBodyHash);
                    w.Write(this.materialSetLowerBodyHash);
                    w.Write(this.materialSetShoesHash);
                }
            }
            if (this.version >= 0x1F)
            {
                w.Write((uint)this.hideForOccultFlags);
            }
            w.Write(this.nakedKey);
            w.Write(this.parentKey);
            w.Write(this.sortLayer);
            if (this.lodBlockList == null)
            {
                this.lodBlockList = new LODBlockList(this.OnResourceChanged);
            }
            this.lodBlockList.UnParse(s);
            if (this.slotKey == null)
            {
                this.slotKey = new SimpleList <byte>(this.OnResourceChanged);
            }
            w.Write((byte)this.slotKey.Count);
            foreach (var b in this.slotKey)
            {
                w.Write(b);
            }
            w.Write(this.diffuseShadowKey);
            w.Write(this.shadowKey);
            w.Write(this.compositionMethod);
            w.Write(this.regionMapKey);
            if (this.overrides == null)
            {
                this.overrides = new OverrideList(this.OnResourceChanged);
            }
            this.overrides.UnParse(s);
            w.Write(this.normalMapKey);
            w.Write(this.specularMapKey);
            if (this.version >= 0x1B)
            {
                w.Write(this.sharedUVMapSpace);
            }
            if (this.version >= 0x1E)
            {
                w.Write(this.emissionMapKey);
            }
            var tgiPosition = w.BaseStream.Position;

            w.BaseStream.Position = 4;
            w.Write(tgiPosition - 8);
            w.BaseStream.Position = tgiPosition;
            if (this.tgiList == null)
            {
                this.tgiList = new CountedTGIBlockList(this.OnResourceChanged);
            }
            w.Write((byte)this.tgiList.Count);
            foreach (var tgi in this.tgiList)
            {
                tgi.UnParse(s);
            }

            return(s);
        }