/// <summary> /// Check if user selected a Value in <see cref="MetroFrameworkComboBox"/> /// </summary> /// <returns></returns> public bool HasValue() { if (Objects.Count() < 1) { //No Objects return(!string.IsNullOrEmpty(Text)); } return(!string.IsNullOrEmpty(_value) && Objects.Any(x => x.Text == _value)); }
public bool IsPc(int x, int y) { if (!IsInCurrentArea(x, y)) { return(false); } return(Objects.Any(ob => ob != null && ob.x == x && ob.z == -y && ob.Name.StartsWith("PC") && !string.IsNullOrEmpty(ob.Name)) && Npcs.Any(n => n.PositionX == x && n.PositionY == y && n.NpcName.ToLowerInvariant().StartsWith("new") && n.Data.Settings.Sprite == 0)); }
public bool IsPc(int x, int y) { if (!IsInCurrentArea(x, y)) { return(false); } return(Objects.Any(ob => ob.x == x && ob.z == -y && ob.Name.StartsWith("PCComputer")) && OriginalNpcs.Any(n => n.PositionX == x && n.PositionY == y && n.NpcName.ToLowerInvariant().StartsWith("new"))); }
public IContentTypePropertyGroupSetSyntax PropertyGroup(string name) { if (name == null) { _currentPropertyGroupName = null; return(this); } Ensure.That(Objects.Any(o => o.PropertyGroups.Contains(name)), "Property group '{0}' was not found on any content type.", name); _currentPropertyGroupName = name; return(this); }
//MapObjectをID採番して追加 public bool AddObject(MapObject obj, Form position) { //既に何かあったら失敗 if (Objects.Any(x => x.Position == position)) { return(false); } var id = Objects.Any() ? Objects.Max(x => x.UniqueId) + 1 : 0; obj.UniqueId = id; obj.Position = position; Objects.Add(obj); return(true); }
public Tree(int gridX, int gridY) : base(gridX, gridY) { //Currently doesn't allow for a tree to be directly above another tree if (Tile.Map[gridX, gridY].Type != Tile.TileType.Grass || Objects.Any(x => x != this && x.GridX == gridX && (x.GridY == gridY || x.GridY == gridY - 1 || x.GridY == GridY + 1)) || Game.GridPointOccupied(gridX, gridY, false, this)) { return; } Foreground = true; Solid = true; srcRect = Sprites.TreeRects[Game.R.Next(Sprites.TreeRects.Count)]; Objects.Add(this); Game.GameStep += Game_GameStep; }
private void CalculatePositions() { if (Objects.Any()) { Point origin = CalculateOrigin(); foreach (var obj in Objects) { obj.X -= origin.X; obj.Y -= origin.Y; } } BlockedTiles = BlockedTiles.Select(t => t - origin).ToArray(); }
public Food(int gridX, int gridY) : base(gridX, gridY) { if (StandingOn != Tile.TileType.Grass || !WithinBounds(gridX, gridY) || Objects.Any(x => x != this && x.GridX == gridX && x.GridY == gridY)) { return; } color1 = Color.FromArgb(Game.R.Next(256), Game.R.Next(256), Game.R.Next(256)); color2 = Color.FromArgb(Game.R.Next(256), Game.R.Next(256), Game.R.Next(256)); averageColor = GetAverageColor(color1, color2); CreateImage(color1, color2); Solid = false; Objects.Add(this); }
bool WillConvertToStaticClass() { if (Objects.Any(o => { var b = o is Variable || o is Method; return(b); })) { return(true); } if (Parent != null && Parent.ClosureType == ClosureType.Namespace) { return((Parent as Namespace).WillConvertToStaticClass()); } return(false); }
public bool PutFloor(int pos_x, int pos_y) { bool check = false; // Check if the Generator does not leave the level bounds if (Objects.Any(x => x.Position_x == pos_x && x.Position_y == pos_y)) { // Delete the existing element Objects.RemoveAll(x => x.Position_x == pos_x && x.Position_y == pos_y); // Put floor there: Objects.Add(new Floor() { Position_x = pos_x, Position_y = pos_y }); check = true; } return(check); }
/// <summary> /// Disposes object of given type /// </summary> /// <typeparam name="T">Type</typeparam> /// <param name="objectToDispose">Object to dispose</param> internal void Dispose <T>(object objectToDispose) where T : ICachable { if (Objects.Any(x => x.GetType() == typeof(T))) { return; } Objects.ForEach(x => { if (!x.Equals(objectToDispose)) // we compare values instead of references { return; } x.Dispose(); Objects.Remove(x); }); }
public string GetDescription() { List <string> descriptions = new List <string>(); List <string> connectorDescriptors = Connectors.Values .Select(c => $"a ^white:{c.Type}$ to the {c.Direction}") .ToList(); descriptions.Add(string.Join("\n", connectorDescriptors)); if (Objects.Any(o => o is Generator)) { descriptions.Add("a ^green:GENERATOR$"); } if (Objects.Any(o => o is Locker)) { descriptions.Add("a ^green:LOCKER$"); } return($"You see:\n{string.Join("\n", descriptions)}"); }
private void Update() { foreach (var ellipse in Objects) { CalFromOthers(ellipse, 1.0); ellipse.Update(); } while (Objects.Any(x => x.Postion.X < 0)) { var offset = Objects.Select(x => x.Postion.X).Where(x => x < 0).OrderByDescending(x => x).First(); MoveAll(new Vector(offset + 100, 0)); } while (Objects.Any(x => x.Postion.Y < 0)) { var offset = Objects.Select(x => x.Postion.Y).Where(x => x < 0).OrderBy(x => x).First(); MoveAll(new Vector(0, offset + 100)); } }
public Egg(Dorf parent) : base(parent.GridX, parent.GridY) { if (Tile.Map[GridX, GridY].Type != Tile.TileType.Grass || Objects.Any(x => x.GridX == parent.GridX && x.GridY == parent.GridY)) { return; } Stamina = parent.Stamina; Hunger = parent.Hunger; Thirst = parent.Thirst; Generation = parent.Generation + 1; Radiation = parent.Radiation; Strength = parent.Strength; Intelligence = parent.Intelligence; Speed = parent.Speed; imageIndex = 0; Solid = true; StatusUpdate += Game.UpdateStatus; Objects.Add(this); }
public virtual void Update(GameTime gameTime) { if (IsPaused || !IsVisible) { return; } var input = TouchPanel.GetState().Where(tch => tch.State != TouchLocationState.Invalid); if (input.Count() > 0) { HandleInput(input.FirstOrDefault()); } if (Objects.Any(obj => obj.Destroyed)) { Objects.RemoveAll(obj => obj.Destroyed); } foreach (var obj in Objects.ToArray()) { obj.Update(gameTime); } }
/// <inheritdoc /> /// <summary> /// Writes this class as json using <code>generator</code>. /// This method is valid only in an array context or in no context (see <see cref="M:Newtonsoft.Json.JsonTextWriter.WriteStartObject" />. /// Requires the current objects list to be correctly sorted, otherwise the written /// <see cref="T:SavegameToolkit.Types.ObjectReference" /> might be broken. /// </summary> /// <param name="writer"><see cref="T:Newtonsoft.Json.JsonTextWriter" /> to write with</param> /// <param name="writingOptions"></param> public void WriteJson(JsonTextWriter writer, WritingOptions writingOptions) { writer.WriteStartObject(); writer.WriteField("saveVersion", SaveVersion); writer.WriteField("gameTime", GameTime); writer.WriteField("saveCount", SaveCount); if (!writingOptions.Compact && OldNameList != null && OldNameList.Any()) { writer.WriteArrayFieldStart("preservedNames"); foreach (string oldName in OldNameList) { writer.WriteValue(oldName); } writer.WriteEndArray(); } if (!writingOptions.Compact && DataFiles.Any()) { writer.WriteArrayFieldStart("dataFiles"); foreach (string dataFile in DataFiles) { writer.WriteValue(dataFile); } writer.WriteEndArray(); } if (!writingOptions.Compact && EmbeddedData.Any()) { writer.WriteArrayFieldStart("embeddedData"); foreach (EmbeddedData data in EmbeddedData) { data.WriteJson(writer); } writer.WriteEndArray(); } if (DataFilesObjectMap.Any()) { writer.WriteObjectFieldStart("dataFilesObjectMap"); foreach (KeyValuePair <int, List <string[]> > entry in DataFilesObjectMap) { writer.WriteArrayFieldStart(entry.Key.ToString()); foreach (string[] namesList in entry.Value) { writer.WriteStartArray(); foreach (string name in namesList) { writer.WriteValue(name); } writer.WriteEndArray(); } writer.WriteEndArray(); } writer.WriteEndObject(); } if (Objects.Any()) { writer.WriteArrayFieldStart("objects"); foreach (GameObject gameObject in Objects) { gameObject.WriteJson(writer, writingOptions); } writer.WriteEndArray(); } writer.WriteObjectFieldStart("hibernation"); if (!writingOptions.Compact) { writer.WriteField("v8Unknown1", hibernationV8Unknown1); writer.WriteField("v8Unknown2", hibernationV8Unknown2); writer.WriteField("v8Unknown3", hibernationV8Unknown3); writer.WriteField("v8Unknown4", hibernationV8Unknown4); writer.WriteField("unknown1", hibernationUnknown1); writer.WriteField("unknown2", hibernationUnknown2); } if (!writingOptions.Compact && hibernationClasses.Any()) { writer.WriteArrayFieldStart("classes"); foreach (string hibernationClass in hibernationClasses) { writer.WriteValue(hibernationClass); } writer.WriteEndArray(); } if (!writingOptions.Compact && hibernationIndices.Any()) { writer.WriteArrayFieldStart("indices"); foreach (int hibernationIndex in hibernationIndices) { writer.WriteValue(hibernationIndex); } writer.WriteEndArray(); } if (HibernationEntries.Any()) { writer.WriteArrayFieldStart("entries"); foreach (HibernationEntry hibernationEntry in HibernationEntries) { hibernationEntry.WriteJson(writer, writingOptions); } writer.WriteEndArray(); } writer.WriteEndObject(); writer.WriteEndObject(); }
private void RefreshData() { if (!Objects.Any()) { Tabs.TabPages.Clear(); return; } UpdateVisgroups(false); var beforeTabs = Tabs.TabPages.OfType <TabPage>().ToArray(); if (!Tabs.TabPages.Contains(VisgroupTab)) { Tabs.TabPages.Add(VisgroupTab); } if (!Objects.All(x => x is Entity || x is World)) { Tabs.TabPages.Remove(ClassInfoTab); Tabs.TabPages.Remove(InputsTab); Tabs.TabPages.Remove(OutputsTab); Tabs.TabPages.Remove(FlagsTab); return; } if (!Tabs.TabPages.Contains(ClassInfoTab)) { Tabs.TabPages.Insert(0, ClassInfoTab); } if (!Tabs.TabPages.Contains(FlagsTab)) { Tabs.TabPages.Insert(Tabs.TabPages.Count - 1, FlagsTab); } if (Document.Game.Engine == Engine.Goldsource) { // Goldsource Tabs.TabPages.Remove(InputsTab); Tabs.TabPages.Remove(OutputsTab); } else { // Source if (!Tabs.TabPages.Contains(InputsTab)) { Tabs.TabPages.Insert(1, InputsTab); } if (!Tabs.TabPages.Contains(OutputsTab)) { Tabs.TabPages.Insert(2, OutputsTab); } } var afterTabs = Tabs.TabPages.OfType <TabPage>().ToArray(); // If the tabs changed, we want to reset to the first tab if (beforeTabs.Length != afterTabs.Length || beforeTabs.Except(afterTabs).Any()) { Tabs.SelectedIndex = 0; } _populating = true; Class.Items.Clear(); var allowWorldspawn = Objects.Any(x => x is World); Class.Items.AddRange(Document.GameData.Classes .Where(x => x.ClassType != ClassType.Base && (allowWorldspawn || x.Name != "worldspawn")) .Select(x => x.Name).OrderBy(x => x.ToLower()).OfType <object>().ToArray()); if (!Objects.Any()) { return; } var classes = Objects.Where(x => x is Entity || x is World).Select(x => x.GetEntityData().Name.ToLower()).Distinct().ToList(); var cls = classes.Count > 1 ? "" : classes[0]; if (classes.Count > 1) { Class.Text = @"<multiple types> - " + String.Join(", ", classes); SmartEditButton.Checked = SmartEditButton.Enabled = false; } else { var idx = Class.Items.IndexOf(cls); if (idx >= 0) { Class.SelectedIndex = idx; SmartEditButton.Checked = SmartEditButton.Enabled = true; } else { Class.Text = cls; SmartEditButton.Checked = SmartEditButton.Enabled = false; } } _values = TableValue.Create(Document.GameData, cls, Objects.Where(x => x is Entity || x is World).SelectMany(x => x.GetEntityData().Properties).Where(x => x.Key != "spawnflags").ToList()); _prevClass = cls; PopulateFlags(cls, Objects.Where(x => x is Entity || x is World).Select(x => x.GetEntityData().Flags).ToList()); _populating = false; UpdateKeyValues(); }
public bool IsFree(Point point) { return(!Objects.Any(t => t.Point == point && t.Model.DoCollide == true)); }
public bool ItemExists(string item) { return(Objects.Any(a => a.Name == item)); }
/// <summary> /// 全てのマスのうち、部屋かつすでにオブジェクトがない場所を取得 /// </summary> /// <returns></returns> public MapCell GetObjectFreeCell() { return(MapData.Cast <MapCell>() .Where(x => x.Terra == Enums.Terrain.Room && !Objects.Any(y => y.Position == x.Position)) .WaitedSample(x => 1)); }
public bool PointIsFree(Point point, bool strictMode = false) { return(!Objects.Any(o => o.GetOwnNeededSpace().Contains(point)) && !(strictMode && !ground.Contains(point))); }
private void EmptyButtonWindowToRed(AppearanceSettings Button, params AppearanceSettings[] Objects) { Button.Background = Objects.Any(obj => obj.Text == "ChangeToRed") ? Brushes.Red : Brushes.White; }
public bool IsNearby(Point point, string className) { return(Objects.Any(t => t.Point.L1(point) == 1 && t.Model.Class == className)); }
private void HandleRawRead(HttpListenerContext ListenerContext, String NewSessionId, Action <HttpVirtualTransportServerHandleResult[]> OnSuccess, Action OnFailure) { String Data; using (var InputStream = ListenerContext.Request.InputStream.AsReadable()) { Byte[] Bytes; try { Bytes = InputStream.Read((int)(ListenerContext.Request.ContentLength64)); } catch { OnFailure(); return; } Data = ListenerContext.Request.ContentEncoding.GetString(Bytes); } var Query = HttpListenerRequestExtension.GetQuery(ListenerContext.Request); if (Data == "") { if (Query.ContainsKey("data")) { Data = Query["data"]; } } JArray Objects; try { Objects = JToken.Parse(Data) as JArray; } catch { ListenerContext.Response.StatusCode = 400; ListenerContext.Response.Close(); OnFailure(); return; } if (Objects == null || Objects.Any(j => j.Type != JTokenType.Object)) { ListenerContext.Response.StatusCode = 400; ListenerContext.Response.Close(); OnFailure(); return; } var Results = new List <HttpVirtualTransportServerHandleResult>(); foreach (var co in Objects) { HttpVirtualTransportServerHandleResult Result; try { Result = vts.Handle(co as JObject); } catch (Exception ex) { if ((ex is InvalidOperationException) && (ex.Message != "")) { Server.ServerContext.RaiseSessionLog(new SessionLogEntry { Token = Context.SessionTokenString, RemoteEndPoint = RemoteEndPoint, Time = DateTime.UtcNow, Type = "Known", Name = "Exception", Message = ex.Message }); } else { OnCriticalError(ex, new StackTrace(true)); } OnFailure(); return; } if (Result.OnCommand || Result.OnBadCommand || Result.OnBadCommandLine) { Results.Add(Result); } else { OnFailure(); } } var Success = false; WriteContext.Update(c => { if (c != null) { Success = false; return(c); } Success = true; return(new HttpWriteContext { ListenerContext = ListenerContext, NewSessionId = NewSessionId, Query = Query }); }); if (!Success) { OnFailure(); } else { OnSuccess(Results.ToArray()); } }
public bool HasWeightedElementsNonNull() { return(Objects != null && TotalWeight > 0 && (!AllowNull || Objects.Any((o) => o.Object != null && o.Weight > 0))); }