public override FSharpMap <TKey, TValue> Deserialize(ref byte[] bytes, int offset, DirtyTracker tracker, out int byteSize) { // tracker.Dirty(); // immutable var length = BinaryUtil.ReadInt32(ref bytes, offset); if (length == -1) { byteSize = 4; return(null); } ZeroFormatterSerializer.ValidateNewLength(length); var startOffset = offset; offset += 4; int size; var result = new Tuple <TKey, TValue> [length]; for (int i = 0; i < length; i++) { var kvp = kvpFormatter.Deserialize(ref bytes, offset, tracker, out size); result[i] = Tuple.Create(kvp.Key, kvp.Value); offset += size; } byteSize = offset - startOffset; return(MapModule.OfArray(result)); }
public void DestroyEveryMapModule() { for (int i = transform.childCount - 1; i >= 0; i--) { Destroy(transform.GetChild(i).gameObject); } //타일 재활용 for (int i = 0; i < moduleList.Count; i++) { MapModule normalModule = moduleList[i].GetComponent <MapModule>(); if (normalModule != null) { normalModule.PushAllTileToPool(); } } if (moduleList != null) { moduleList.Clear(); } mapModuleGenerator.PullBackGroundTiles(); mapModuleGenerator = null; }
// Start is called before the first frame update protected virtual void Start() { body = gameObject.GetComponent <CharacterBase>(); avoider = gameObject.GetComponentInChildren <MeleeAvoider>(); owc = GameObject.Find("World").GetComponent <MapModule>(); routeProvider = new RouteProvider(); }
public void CheckPersistanceOfExtraData() { string command = "!forceuploaded" + " " + "True" + " " + "Map Not Uploaded"; MessageEventArgs Message = new MessageEventArgs(null); Message.ReceivedMessage = command; Message.Sender = TestUser; FireAdminCommand(Message, module); Message = new MessageEventArgs(null); Message.ReceivedMessage = AddCommand + " " + Mapname + " " + url + " " + notes; Message.Sender = TestUser; FireCommand(Message, module); AssertMaplistSize(0); module = module = new MapModule(new TestUserHandler(), new TestUserHandler(), MakeConfig()); command = "!forceuploaded" + " " + "false" + " " + "Map Not Uploaded"; Message.ReceivedMessage = command; FireAdminCommand(Message, module); Assert.IsFalse(module.mapList.AllowOnlyUploadedMaps); module = module = new MapModule(new TestUserHandler(), new TestUserHandler(), MakeConfig()); RegularSyntax(); AssertMaplistSize(1); }
static void Main(string[] args) { var myObject = new MyObject( 100, SingleCaseUnion.NewSingleCaseUnion(12345), DiscriminatedUnion.NewCase1DU(111, "aaa"), ListModule.OfSeq(new[] { 0, 1, 2, 3, 4, 5 }), MapModule.OfSeq(new[] { Tuple.Create("One", 1), Tuple.Create("Two", 2) }), Tuple.Create("Hello", "F# fans"), FSharpOption <string> .Some("Option1") ); //var converters = new JsonConverter[0]; var converters = new JsonConverter[] { new UnionConverter() }; // Test a single serialize and deserialize var json = JsonConvert.SerializeObject(myObject, converters); var myNewObject = JsonConvert.DeserializeObject <MyObject>(json, converters); Console.WriteLine("Writing {0}", json); //Console.WriteLine("Objects are the same {0}", (myObject == myNewObject)); var count = 10000; Duration(() => SerializeLoad(false, count, myObject, converters), count, "Serialize Default"); Duration(() => DeserializeLoad(false, count, myObject, converters), count, "Deserialize Default"); Duration(() => SerializeLoad(true, count, myObject, converters), count, "Serialize Custom"); Duration(() => DeserializeLoad(true, count, myObject, converters), count, "Deserialize Custom"); }
// Start is called before the first frame update void Start() { mapModule = gameObject.GetComponent <MapModule>(); roadmap = new bool[w, h]; trees = new List <Vector2Int> [w / tileW, h / tileH]; constructs = new List <Tuple <Vector3Int, TilemapLoader> > [w / tileW, h / tileH]; loadConstructs(); for (int i = 0; i < w / tileW; i++) { for (int j = 0; j < h / tileH; j++) { trees[i, j] = new List <Vector2Int>(); } } gc = new GradientCraetor(w, h); gtdm = gc.gtdm; //createRoad(10); createLakes(); //for (int i = 0; i < 20; i++) //{ // createRoad(20); //} smoothenRoad(); createTrees(); //constructs[60 / tileW, 40 / tileH] = new List<Tuple<Vector3Int, TilemapLoader>>(); //constructs[60 / tileW, 40 / tileH].Add(new Tuple<Vector3Int, TilemapLoader>(new Vector3Int(60, 40, 1), loaders["SmallHouse"])); }
public void SerializationTests_FSharp_Collections() { var elements = new List <int>() { 0, 1, 2 }; var mapElements = new List <Tuple <int, string> >() { new Tuple <int, string>(0, "zero"), new Tuple <int, string>(1, "one") }; // F# list RoundtripSerializationTest(ListModule.Empty <int>()); RoundtripSerializationTest(ListModule.OfSeq(elements)); // F# set RoundtripSerializationTest(SetModule.Empty <int>()); RoundtripSerializationTest(SetModule.OfSeq(elements)); // F# map RoundtripSerializationTest(MapModule.OfSeq(new List <Tuple <int, string> >())); RoundtripSerializationTest(MapModule.OfSeq(mapElements)); }
public void Test5_1_Collections() { var m1 = new MegaType( new[] { 0, 1 }, new FSharpMap <string, int>(new List <Tuple <string, int> > { new Tuple <string, int>("key", 10) }), new FSharpSet <int>(new[] { 1 }), new FSharpList <FSharpOption <int> >(new FSharpOption <int>(22), FSharpList <FSharpOption <int> > .Empty), new[] { new[] { 0, 1 } }, new int[, ] { } ); Assert.True(MapModule.ContainsKey("key", m1.Maps)); var newSet = SetModule.Add(2, m1.Sets); //does not mutate set Assert.NotEqual(newSet, m1.Sets); if (OptionModule.IsSome(ListModule.Head(m1.Lists))) { Assert.Equal(22, ListModule.Head(m1.Lists).Value); } //Lists are linked lists, immutable and have structural equality Assert.Equal(m1.Arrays, m1.ArrayofArrays[0]); //Structural equality m1.Arrays[0] = 1; Assert.Equal(m1.Arrays, new[] { 1, 1 }); //Arrays are mutable }
protected virtual void preSetup() { map = GetComponent <MapModule>(); tp = GameObject.Find("TileProvider").GetComponent <TileProvider>(); tilemap = gameObject.transform.Find("Tilemap").GetComponent <Tilemap>(); FGTilemap = gameObject.transform.Find("Foreground").GetComponent <Tilemap>(); FullFGTilemap = gameObject.transform.Find("FullFG").GetComponent <Tilemap>(); }
protected virtual void Start() { body = gameObject.GetComponent <CharacterBase>(); avoider = gameObject.GetComponentInChildren <MeleeAvoider>(); owc = GameObject.Find("World").GetComponent <MapModule>(); routeProvider = new RouteProvider(); target = transform.position + new Vector3(0.1f, 0, 0); }
public override string runcommand(MessageEventArgs Msg, string param) { string[] parameters = param.Split(new char[] { ' ' }, 2); int MapPositionInList = 0; Map deletedMap = new Map(); if (int.TryParse(parameters[0], out MapPositionInList)) { if ((MapPositionInList > MapModule.mapList.GetSize()) | (MapPositionInList <= 0)) { return("That index does not exist! Please use a valid number when deleting maps"); } else { MapPositionInList--; deletedMap = MapModule.mapList.GetMap(MapPositionInList); } } else { deletedMap = MapModule.mapList.GetMapByFilename(parameters[0]); } if (deletedMap == null) { return(string.Format("Map '{0}' was not found.", parameters[0])); } else { if ((deletedMap.IsOwner(Msg.Sender.identifier)) || (userhandler.admincheck(Msg.Sender))) { string Reason = "Deleted by " + Msg.Sender.DisplayName + " (" + Msg.Sender.identifier + "). "; string ExplicitReason = param.Substring(parameters[0].Length, param.Length - parameters[0].Length); if (!string.IsNullOrWhiteSpace(ExplicitReason)) { Reason += "Reason given: " + ExplicitReason; } else { Reason += "No reason given"; } userhandler.SendPrivateMessageProcessEvent(new MessageEventArgs(null) { Destination = new User(deletedMap.Submitter, null), ReplyMessage = string.Format("Your map {0} has been deleted from the map list. {1}", deletedMap.Filename, Reason) }); MapModule.mapList.RemoveMap(deletedMap, Reason); MapModule.savePersistentData(); return(string.Format("Map '{0}' DELETED. Sending: {1}", deletedMap.Filename, Reason)); } else { return(string.Format("You do not have permission to edit map '{0}'.", deletedMap.Filename)); } } }
private MapActions <T> Add(Type type, string typename, string viewaction, Action <T, object> mapAction) { var newTA = new TypeAction(type, mapAction, viewaction); var newTypeMap = MapModule.Add(typename, newTA, this._typeMap); return(new MapActions <T>() { _typeMap = newTypeMap }); }
internal static CouchUrl Create(CouchRepo couchRepo, FSharpList <string> path, FSharpMap <string, string> queryString, FSharpList <CouchFilter> filters) { return(new CouchUrl() { couchRepo = couchRepo, path = path ?? ListModule.Empty <string>(), queryString = queryString ?? MapModule.Empty <string, string>(), filters = filters ?? ListModule.Empty <CouchFilter>() }); }
private bool ArrayContains(MapModule[] array, MapModule x) { foreach (MapModule m in array) { if (m == x) { return(true); } } return(false); }
public override FSharpMap <string, T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { try { return(MapModule.OfSeq(reader.DeserializeMapAsTuples <T>(options))); } catch (Exception ex) { throw new JsonException( $"Error when deserialize FSharpMap<string, {typeof(T).Name}>", ex); } }
private static IEnumerable <KeyValuePair <string, Stream> > GetStreamsFromResourcePath(string embeddedResourcePath) { var fileLocationCriteria = GetFileLocationCriteria(embeddedResourcePath); return(GetAssembliesToSearch(embeddedResourcePath) .SelectMany(assembly => GetStreamsFromAssembly(assembly, fileLocationCriteria)) .AggregateUntil(MapModule.Empty <string, Stream>(), (streamMap, stream) => !streamMap.ContainsKey(stream.Item1) ? streamMap.Add(stream.Item1, stream.Item2) : streamMap, streamMap => fileLocationCriteria.All((criteria => streamMap.Any(pair => criteria(pair.Key)))) || streamMap.Select(pair => MapToMetadataFileType(pair.Key).Value).Contains(MetadataFileType.ConceptualModel.Concat(MetadataFileType.StorageModel).Concat(MetadataFileType.Mapping)) || streamMap.Select(pair => MapToMetadataFileType(pair.Key).Value).Contains(MetadataFileType.Edmx))); }
public override FSharpMap <TKey, TValue> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { try { return(MapModule.OfSeq(reader.DeserializeArray <Tuple <TKey, TValue> >(options))); } catch (Exception ex) { throw new JsonException( $"Error when deserialize FSharpMap<{typeof(TKey).Name},{typeof(TValue).Name}>", ex); } }
public void Compare_AlternateKeyInputShouldBeEqualInMap() { var left = KeyInputSet.NewOneKeyInput(KeyInputUtil.EnterKey); var right = KeyInputSet.NewOneKeyInput(KeyInputUtil.AlternateEnterKey); var map = MapModule.Empty <KeyInputSet, bool>().Add(left, true); var result = MapModule.TryFind(right, map); Assert.True(result.IsSome()); map = MapModule.Empty <KeyInputSet, bool>().Add(right, true); result = MapModule.TryFind(left, map); Assert.True(result.IsSome()); }
public void CheckPersistance() { RegularSyntax(); module = module = new MapModule(new TestUserHandler(), new TestUserHandler(), MakeConfig()); Map TestMap = module.mapList.GetMap(0); Assert.AreEqual(TestMap.Filename, Mapname); Assert.AreEqual(TestMap.DownloadURL, url); Assert.AreEqual(TestMap.Notes, notes); Assert.AreEqual(TestMap.Submitter, identifier); Assert.AreNotEqual(TestMap.Filename, Mapname + 1); //Ensure that its a string check }
public void DeepCopyTests_FSharp_Collections() { // F# list { var original = FSharpList <int> .Empty; var copy = (FSharpList <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } { var original = ListModule.OfSeq(new List <int> { 0, 1, 2 }); var copy = (FSharpList <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } // F# set { var original = new FSharpSet <int>(new List <int>()); var copy = (FSharpSet <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } { var elements = new List <int>() { 0, 1, 2 }; var original = SetModule.OfSeq(elements); var copy = (FSharpSet <int>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } // F# map { var original = new FSharpMap <int, string>(new List <Tuple <int, string> >()); var copy = (FSharpMap <int, string>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } { var elements = new List <Tuple <int, string> >() { new Tuple <int, string>(0, "zero"), new Tuple <int, string>(1, "one") }; var original = MapModule.OfSeq(elements); var copy = (FSharpMap <int, string>) this.fixture.SerializationManager.DeepCopy(original); Assert.Equal(original, copy); } }
public void Map() { FSharpMap <string, int> m1 = MapModule.OfSeq(new List <Tuple <string, int> > { Tuple.Create("one", 1), Tuple.Create("II", 2), Tuple.Create("3", 3) }); string json = JsonConvert.SerializeObject(m1, Formatting.Indented); FSharpMap <string, int> m2 = JsonConvert.DeserializeObject <FSharpMap <string, int> >(json); Assert.AreEqual(m1.Count, m2.Count); Assert.AreEqual(1, m2["one"]); Assert.AreEqual(2, m2["II"]); Assert.AreEqual(3, m2["3"]); }
public override string runcommand(MessageEventArgs Msg, string param) { string[] parameters = param.Split(' '); if (parameters.Length < 2) { return(string.Format("Invalid parameters for !reposition. Syntax: !reposition <new position> <filename>")); } else { int index; try { index = int.Parse(parameters[0]); } catch { return(string.Format("Invalid parameters for !reposition. Syntax: !reposition <new position> <filename>")); } Map editedMap = null; foreach (Map entry in MapModule.mapList) { if (entry.Filename == parameters[1]) { editedMap = entry; } } if (editedMap == null) { return("Map not found"); } // Map editedMap = MapModule.mapList.Find(map => map.filename.Equals(parameters[0])); //OLD Map CODE if (editedMap.Submitter.Equals(Msg.Sender.identifier.ToString()) | (userhandler.admincheck(Msg.Sender))) { MapModule.mapList.RemoveMap(editedMap, "Map Repositioned"); editedMap.Notes += string.Format("Map repositioned to {0} by {1} // ", index, Msg.Sender.identifier.ToString()); MapModule.mapList.InsertMap(index, editedMap); MapModule.savePersistentData(); return(string.Format("Map '{0}' has been repositioned to {1}.", editedMap.Filename, index)); } else { return(string.Format("You cannot edit map '{0}' as you did not submit it.", editedMap.Filename)); } } }
internal void Start(int player, string endpoint, int seed, GameVersion version) { Stop(); GameVersion = version; if (seed < 0) { seed = Guid.NewGuid().GetHashCode() ^ DateTime.UtcNow.GetHashCode(); } Rng = new Random(seed); PlayerNumber = player; Log = new Log(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), $"{Name} {PlayerNumber}.log")); InfoModule = new InfoModule() { BotInternal = this }; MapModule = new MapModule() { BotInternal = this }; PlayersModule = new PlayersModule() { BotInternal = this }; UnitsModule = new UnitsModule() { BotInternal = this }; ResearchModule = new ResearchModule() { BotInternal = this }; MicroModule = new MicroModule() { BotInternal = this }; BotThread = new Thread(() => Run(endpoint)) { IsBackground = true }; BotThread.Start(); }
static bool Prefix(MapModule __instance, ref MapAndEncounters __result) { if (UiManager.Instance.ClickedQuickSkirmish) { Main.Logger.Log($"[MapModuleSelectedMapPatch Prefix] Patching SelectedMap"); if (mapAndEncounter == null) { List <MapAndEncounters> mapAndEncounters = MetadataDatabase.Instance.GetReleasedMapsAndEncountersByContractTypeAndOwnership((int)ContractType.ArenaSkirmish, false); int index = UnityEngine.Random.Range(0, mapAndEncounters.Count); mapAndEncounter = mapAndEncounters[index]; } __result = mapAndEncounter; return(false); } return(true); }
static bool Prefix(MapModule __instance, ref BattleMood __result) { if (UiManager.Instance.ClickedQuickSkirmish) { Main.Logger.Log($"[MapModuleSelectedMoodPatch Prefix] Patching SelectedMood"); if (mood == null) { List <Mood_MDD> moods = MetadataDatabase.Instance.GetMoods(); int index = UnityEngine.Random.Range(0, moods.Count); Mood_MDD moodMdd = moods[index]; mood = new BattleMood { Name = moodMdd.Name, FriendlyName = moodMdd.FriendlyName, Path = "MOOD_PATH_UNSET" }; } __result = mood; return(false); } return(true); }
public JsonResult Attendance(string pattern) { var module = new MapModule(CurrentUser); var items = module.AttendanceSelect(pattern, DateTime.Now.Date.AddDays(-7), DateTime.Now); var data = items.Select(t => new AttendanceGroupModel { id = t.atd.Id, etime = t.atd.ETime, length = t.atd.TimeLength, name = t.officer.Name, stime = t.atd.STime, items = t.tracks.Select(x => new AttendanceItemModel { name = x.station.SiteId, time = x.track.UpTime, lat = x.station.Lat, lon = x.station.Lon }).ToArray() }); return(Json(data, JsonRequestBehavior.AllowGet)); }
public JsonResult Rectangle(double x1, double y1, double x2, double y2) { var module = new MapModule(CurrentUser); var items = module.RectangleSelect(x1, y1, x2, y2); var data = new Models.DispatchModel { groups = items.GroupBy(t => t.ptp).Select(t => new DispatchGroupModel { items = t.Select(x => new GroupItemModel { name = x.officer.Name, orgName = x.org.Name, site = new Pointer { x = x.station.Lon, y = x.station.Lat } }).ToArray(), name = t.Key.Name }).ToArray() }; return(Json(new { code = 0, msg = "Ok", data = data })); }
private List <MapModule> GetValidMapModules(int row, int col) { List <MapModule> valid = new List <MapModule>(); for (int i = 0; i < modules.Length - 1; i++) { MapModule m = modules[i]; if (ArrayContains(northConnections[i], map[row - 1, col]) && ArrayContains(eastConnections[i], map[row, col + 1]) && ArrayContains(southConnections[i], map[row + 1, col]) && ArrayContains(westConnections[i], map[row, col - 1])) { valid.Add(m); } } if (valid.Count == 0) { valid.Add(MapModule.Empty); } return(valid); }
public WipeMaps(ModuleHandler bot, MapModule mapMod) : base(bot, "!wipe", mapMod, "!wipe <reason>") { module = mapMod; }
public void Cleanup() { module.ClearMapListWithMessage("Test Wipe"); module = new MapModule(new TestUserHandler(), new TestUserHandler(), MakeConfig()); Assert.IsTrue(module.mapList.GetSize() == 0); }
public Pathfinder(MapModule map, EntityManager entity) { _map = map; }
public static void LoadModule(MapModule module, MapModuleOptions options) { }