internal static BlockDataWorld GetClearedWorld(int width, int height, Foreground.Id borderBlock) { var world = new BlockDataWorld(width, height); WorldUtils.DrawBorder(world, new BlockData <ForegroundBlock>(new ForegroundBlock(borderBlock))); return(world); }
public static ForegroundBlock GetForegroundFromArgs(Foreground.Id block, object[] args) { var foregroundType = GetBlockArgsType(GetForegroundType(block)); switch (foregroundType) { case BlockArgsType.None: { return(new ForegroundBlock(block)); } case BlockArgsType.Number: { switch (args[0]) { case int si: return(new ForegroundBlock(block, si)); case uint i: return(new ForegroundBlock(block, i)); default: throw new ArgumentException("Unsupported numeral type.", nameof(args)); } } case BlockArgsType.String: { var str = Convert.ToString(args[0]); return(new ForegroundBlock(block, str)); } case BlockArgsType.Portal: { var portalRotation = (Morph.Id)Convert.ToUInt32(args[0]); var portalId = Convert.ToUInt32(args[1]); var portalTarget = Convert.ToUInt32(args[2]); return(new ForegroundBlock(block, portalId, portalTarget, portalRotation)); } case BlockArgsType.Label: { var text = Convert.ToString(args[0]); var textcolor = Convert.ToString(args[1]); var wrapWidth = Convert.ToUInt32(args[2]); return(new ForegroundBlock(block, text, textcolor, wrapWidth)); } case BlockArgsType.Sign: { var text = Convert.ToString(args[0]); var color = (Morph.Id)Convert.ToUInt32(args[1]); return(new ForegroundBlock(block, text, color)); } default: throw new ArgumentException("Invalid block.", nameof(block)); } }
public ForegroundBlock(Foreground.Id id, bool enabled) : this(id, enabled ? 1 : 0) { if (this.Type == ForegroundType.ToggleGoal && enabled) { throw new ArgumentException("The given block only supports \"false\" or a number.", nameof(enabled)); } }
public static Type GetGroup(Foreground.Id id) { if (id == 0) { return(typeof(Foreground)); } return(GetGroup((int)id)); }
public static ForegroundBlock GetForegroundFromArgs(Foreground.Id block, object[] args) { var foregroundType = GetBlockArgsType(GetForegroundType(block)); switch (foregroundType) { case BlockArgsType.None: { return(new ForegroundBlock(block)); } case BlockArgsType.Number: { var i = Convert.ToUInt32(args[0]); return(new ForegroundBlock(block, i)); } case BlockArgsType.SignedNumber: { var si = Convert.ToInt32(args[0]); return(new ForegroundBlock(block, si)); } case BlockArgsType.String: { var str = Convert.ToString(args[0]); return(new ForegroundBlock(block, str)); } case BlockArgsType.Portal: { var portalRotation = (Morph.Id)Convert.ToUInt32(args[0]); var portalId = Convert.ToUInt32(args[1]); var portalTarget = Convert.ToUInt32(args[2]); return(new ForegroundBlock(block, portalId, portalTarget, portalRotation)); } case BlockArgsType.Label: { var text = Convert.ToString(args[0]); var textcolor = Convert.ToString(args[1]); return(new ForegroundBlock(block, text, textcolor)); } case BlockArgsType.Sign: { var text = Convert.ToString(args[0]); var color = (Morph.Id)Convert.ToUInt32(args[1]); return(new ForegroundBlock(block, text, color)); } default: throw new NotSupportedException("Invalid block."); } }
public ForegroundBlock GenerateBlock(Foreground.Id id) { try { return(new ForegroundBlock(id)); } catch (ArgumentException ex) { throw new NotSupportedException("There is no Block assosicated with this query.", ex); } }
private void RaiseSignBlock(int x, int y, Foreground.Id block, string text, Morph.Id signColor, Player player) { try { this.RaiseForeground(x, y, new ForegroundBlock(block, text, signColor), player); } catch (Exception ex) { Trace.TraceWarning($"Received invalid sign block: {x}x{y}:{block} by {player.ChatName}\n{ex}"); } }
private void RaiseSignedNumberBlock(int x, int y, Foreground.Id block, int args, Player player) { try { this.RaiseForeground(x, y, new ForegroundBlock(block, args), player); } catch (Exception ex) { Trace.TraceWarning($"Received invalid signed number block: {x}x{y}:{block} by {player.ChatName}\n{ex}"); } }
private ForegroundBlock(Foreground.Id id, BlockArgsType requiredArgsType) { this.Id = id; this._args = null; var argsType = WorldUtils.GetBlockArgsType(this.Type); if (argsType != requiredArgsType) { throw WorldUtils.GetMissingArgsErrorMessage(argsType, nameof(id)); } }
private void RaisePortalBlock(int x, int y, Foreground.Id block, uint portalId, uint portalTarget, Morph.Id portalRotation, Player player) { try { this.RaiseForeground(x, y, new ForegroundBlock(block, portalId, portalTarget, portalRotation), player); } catch (Exception ex) { Trace.TraceWarning($"Received invalid portal block: {x}x{y}:{block} by {player.ChatName}\n{ex}"); } }
private static bool IsBorderPlaceable(Foreground.Id id) { if (id == Foreground.Special.FullyBlack) { return(true); } var block = BlockServices.GetGroup((int)id); return(block == typeof(Foreground.Basic) || block == typeof(Foreground.Beta) || block == typeof(Foreground.Brick)); }
public ForegroundBlock(Foreground.Id id, uint portalId, uint portalTarget, Morph.Id portalRotation) { ForegroundType type = WorldUtils.GetForegroundType(id); if (WorldUtils.GetBlockArgsType(type) != BlockArgsType.Portal) { throw new ArgumentException("The given block is not a portal.", "id"); } this._args = new PortalArgs(portalId, portalTarget, portalRotation); this._type = ForegroundType.Portal; this._id = id; }
public ForegroundBlock(Foreground.Id id, uint args) { ForegroundType type = WorldUtils.GetForegroundType(id); if (WorldUtils.GetBlockArgsType(type) != BlockArgsType.Number) { throw new ArgumentException("Invalid arguments for the specified block.", "id"); } this._args = args; this._type = type; this._id = id; }
public ForegroundBlock(Foreground.Id id, string text, string textColor) { ForegroundType type = WorldUtils.GetForegroundType(id); if (WorldUtils.GetBlockArgsType(type) != BlockArgsType.Label) { throw new ArgumentException("Invalid arguments for the specified block.", "id"); } this._args = new LabelArgs(text, textColor); this._type = type; this._id = id; }
public ForegroundBlock(Foreground.Id id) { ForegroundType type = WorldUtils.GetForegroundType(id); if (WorldUtils.GetBlockArgsType(type) != BlockArgsType.None) { throw new ArgumentException("The given block is missing required arguments.", "id"); } this._args = null; this._type = ForegroundType.Normal; this._id = id; }
public static ForegroundBlock GetForegroundFromDatabase(DatabaseObject obj, Foreground.Id foreground) { var foregroundType = GetForegroundType(foreground); switch (foregroundType) { case ForegroundType.Normal: return(new ForegroundBlock(foreground)); case ForegroundType.Note: return(new ForegroundBlock(foreground, obj.GetUInt("id", 0))); case ForegroundType.Goal: case ForegroundType.Toggle: case ForegroundType.ToggleGoal: case ForegroundType.Team: return(new ForegroundBlock(foreground, obj.GetUInt("goal", 0))); case ForegroundType.Morphable: return(new ForegroundBlock(foreground, obj.GetUInt("rotation", 0))); case ForegroundType.Portal: return(new ForegroundBlock(foreground, obj.GetUInt("id", 0), obj.GetUInt("target", 0), (Morph.Id)obj.GetUInt("rotation", 0))); case ForegroundType.WorldPortal: return(new ForegroundBlock(foreground, obj.GetString("target"))); case ForegroundType.Label: return(new ForegroundBlock(foreground, obj.GetString("text", "no text found"), obj.GetString("text_color", "#FFFFFF"), obj.GetUInt("wrapWidth", 200))); case ForegroundType.Sign: return(new ForegroundBlock(foreground, obj.GetString("text", "No text found."), (Morph.Id)obj.GetUInt("signtype", 0))); default: throw new NotSupportedException("Encountered an unsupported block!"); } }
public ForegroundBlock(Foreground.Id id, uint args) { var type = WorldUtils.GetForegroundType(id); var argsType = WorldUtils.GetBlockArgsType(type); switch (argsType) { case BlockArgsType.Number: this._args = args; break; case BlockArgsType.SignedNumber: this._args = (int)args; break; default: throw WorldUtils.GetMissingArgsErrorMessage(argsType, nameof(id)); } this.Type = type; this.Id = id; }
public ForegroundBlock(Foreground.Id id, int goal) : this(id, (uint)goal) { }
public ForegroundBlock(Foreground.Id id, uint portalId, uint portalTarget, Morph.Id portalRotation) : this(id, BlockArgsType.Portal) { this._args = new PortalArgs(portalId, portalTarget, portalRotation); this.Id = id; }
public ForegroundBlock(Foreground.Id id, string text, Morph.Id signColor) : this(id, BlockArgsType.Sign) { this._args = new SignArgs(text, signColor); this.Id = id; }
public ForegroundBlock(Foreground.Id id, string text, string textColor) : this(id, BlockArgsType.Label) { this._args = new LabelArgs(text, textColor); this.Id = id; }
public ForegroundBlock(Foreground.Id id, string text) : this(id, BlockArgsType.String) { this._args = text; }
public ForegroundBlock(Foreground.Id id) : this(id, BlockArgsType.None) { }
public IBlockQuery <Foreground.Id, BlocksItem> this[Foreground.Id id] => this.Foreground[id];
public static void Set(this IBlockSettable <ForegroundBlock, BackgroundBlock> blocks, Foreground.Id block, int goal) { blocks.Set(new ForegroundBlock(block, goal)); }
public ForegroundBlock(Foreground.Id id, Morph.Id morph) : this(id, (uint)morph) { }
public static void Set(this IBlockSettable <ForegroundBlock, BackgroundBlock> blocks, Foreground.Id block, string text, string textColor, int wrapWidth) { blocks.Set(new ForegroundBlock(block, text, textColor, wrapWidth)); }
public static void Set(this IBlockSettable <ForegroundBlock, BackgroundBlock> blocks, Foreground.Id block, string args) { blocks.Set(new ForegroundBlock(block, args)); }
public ForegroundBlock(Foreground.Id id, int portalId, int portalTarget, Morph.Id portalRotation) : this(id, (uint)portalId, (uint)portalTarget, portalRotation) { }
public ForegroundBlock(Foreground.Id id, bool enabled) : this(id, enabled ? 1 : 0) { }