private bool CustomRead(NbtCompound node, bool ignoreProperty) { if (!node.TryGet <NbtString>(nameof(Name), out var str)) { return(false); } NbtCompound property = null; if (!ignoreProperty) { node.TryGet(nameof(Properties), out property); } Name = str.Value; // TODO: BlockProperty if (property != null) { Properties = NbtBlockProperty.CreateFromNbt(Name, property); } return(true); }
private void button1_Click(object sender, EventArgs e) { StringBuilder output = new System.Text.StringBuilder(); Dictionary <BlockProperty, List <string> > powerupProperty = new Dictionary <BlockProperty, List <string> >(); powerupProperty[BlockProperty.FireFlower] = new List <string>(); powerupProperty[BlockProperty.SuperLeaf] = new List <string>(); powerupProperty[BlockProperty.FrogSuit] = new List <string>(); powerupProperty[BlockProperty.KoopaSuit] = new List <string>(); powerupProperty[BlockProperty.SledgeSuit] = new List <string>(); powerupProperty[BlockProperty.IceFlower] = new List <string>(); powerupProperty[BlockProperty.FireFoxSuit] = new List <string>(); powerupProperty[BlockProperty.BooSuit] = new List <string>(); powerupProperty[BlockProperty.NinjaSuit] = new List <string>(); foreach (LevelInfo info in ProjectController.LevelManager.Levels) { Level level = new Level(); level.Load(info); BlockDefinition definition = ProjectController.BlockManager.GetDefiniton(level.Type); for (int x = 0; x < level.Width; x++) { for (int y = 0; y < level.Height; y++) { BlockProperty bp = definition[level.LevelData[x, y]].BlockProperty; if (powerupProperty.ContainsKey(bp)) { if (!powerupProperty[bp].Contains(info.Name)) { powerupProperty[bp].Add(info.Name); } } } } } foreach (BlockProperty key in powerupProperty.Keys) { output.Append(key.ToString() + "(" + powerupProperty[key].Count + "): "); foreach (string s in powerupProperty[key]) { output.Append(s + ", "); } output.Append("\r\n\r\n\r\n"); } Output.Text = output.ToString(); }
static BlockProperties( ) { ContentManager Content = Game1.Instance.Content; Blocks = new List <BlockProperty>( ) { (Dirt = new BlockProperty( ) { Name = "Dirt", Texture = Content.Load <Texture2D>("textures/dirt") }), (Grass = new BlockProperty( ) { Name = "Grass", Texture = Content.Load <Texture2D>("textures/grass") }), (Wall = new BlockProperty( ) { Name = "Wall", Texture = Content.Load <Texture2D>("textures/wall") }), }; }
/// <inheritdoc /> public override async Task GetAsync() { var values = GetValues(); BlockProperty property = null; await Torch.InvokeAsync(() => { MyAPIGateway.Entities.TryGetEntityById(values.Id, out IMyEntity entity); if (entity is IMyTerminalBlock block) { property = new BlockProperty(block.GetProperty(values.Property), block); } }); if (property != null) { await Request.RespondAsync(property, HttpStatusCode.OK); return; } await Request.RespondAsync("Block or property not found.", HttpStatusCode.NotFound); }
SetValue(BlockProperty, value);
public static string GetString(this BlockProperty bp) { string s1 = ((BlockProperty.MaskHi) & bp).ToString(); string s2 = "No Interaction"; switch (bp & BlockProperty.MaskHi) { case BlockProperty.Background: case BlockProperty.Foreground: case BlockProperty.Water: case BlockProperty.WaterForeground: switch ((int)(bp & BlockProperty.MaskLo)) { case 1: s2 = "Harmful"; break; case 2: s2 = "Deplete Air"; break; case 3: s2 = "Current Left"; break; case 4: s2 = "Current Right"; break; case 5: s2 = "Current Up"; break; case 6: s2 = "Current Down"; break; case 7: s2 = "Treasure"; break; case 8: s2 = "Locked Door"; break; case 9: s2 = "Enemy Activate"; break; case 10: s2 = "Trap Activate"; break; case 15: break; case 11: s2 = "Climbable"; break; case 12: s2 = "Coin"; break; case 13: s2 = "Door"; break; case 14: s2 = "Cherry"; break; } break; case BlockProperty.SolidTop: case BlockProperty.SolidBottom: case BlockProperty.SolidAll: switch ((int)(bp & BlockProperty.MaskLo)) { case 1: s2 = "Harmful"; break; case 2: s2 = "Slick"; break; case 3: s2 = "Conveyor Left"; break; case 4: s2 = "Conveyor Right"; break; case 5: s2 = "Conveyor Up"; break; case 6: s2 = "Conveyor Down"; break; case 7: s2 = "Unstable"; break; case 8: s2 = "Vertical Enterable Pipe Left End"; break; case 9: s2 = "Vertical Enterable Pipe Right End"; break; case 10: s2 = "Horizontal Enterable Pipe Bottom"; break; case 11: s2 = "Climbable"; break; case 12: case 13: case 15: s2 = "Unused"; break; case 14: s2 = "P-Switch"; break; } break; default: s2 = bp.ToString(); break; } return(s1 + ", " + s2); }
public override void InitConnectors() { currentValue = new BlockProperty <object>(this, "CurrentValue"); base.InitConnectors(); }
public override void InitConnectors() { tableName = new BlockProperty <string>(this, "TableName"); base.InitConnectors(); }
public NamespacedBlock(string id, BlockProperty property = null) { Name = id; Properties = property; }
public Block(string block) { this.BlockType = BlockProperties.ByName(block); }
public Block(BlockProperty block) { this.BlockType = block; }
void SetState(BlockProperty state) { blockProperty = state; }
/// <summary> /// Adds a property to the block. /// </summary> /// <param name="name">The name of the property.</param> /// <param name="value">The value of the property.</param> /// <param name="param1">The first parameter of the property, or null.</param> /// <param name="param2">The second parameter of the property, or null.</param> public void AddProperty(String name, String value, String param1, String param2) { switch (name) { case "CanMobsSpawnOn": this.CanMobsSpawnOn = Convert.ToBoolean(value); break; case "CanPickup": this.CanPickup = Convert.ToBoolean(value); if (param1 != null) { this.PickupTarget = this.itemList[param1]; } break; case "CanPlayersSpawnOn": this.CanPlayersSpawnOn = Convert.ToBoolean(value); break; case "Class": this.Class = value; break; case "Collide": this.Collide = value; break; case "Damage": this.Damage = Convert.ToUInt32(value); break; case "Damage_received": this.DamageReceived = Convert.ToUInt32(value); break; case "DowngradeBlock": this.DowngradeBlock = this.blockList[value]; break; case "Extends": this.Extends = this.blockList[value]; break; case "FallDamage": this.FallDamage = Convert.ToBoolean(value); break; case "FuelValue": this.FuelValue = Convert.ToUInt32(value); break; case "LootList": this.LootList = Convert.ToUInt32(value); break; case "Material": this.Material = this.materialList[value]; break; case "MaxDamage": this.MaxDamage = Convert.ToUInt32(value); break; case "PickupTarget": this.PickupTarget = this.itemList[value]; break; case "Weight": this.Weight = Convert.ToUInt32(value); break; default: try { BlockProperty newProperty; if (propertiesWithParam2.Contains(name)) { newProperty = new BlockPropertyDoubleParam() { Param1 = param1, Param2 = param2 }; } else if (propertiesWithParam1.Contains(name)) { newProperty = new BlockPropertySingleParam() { Param1 = param1 }; } else { newProperty = new BlockProperty(); } newProperty.Name = name; newProperty.Value = value; this.properties.Add(name, newProperty); } catch { Debug.WriteLine("WARN: Block " + this.ID + " has duplicate property '" + name + "'. Overriding."); if (propertiesWithParam2.Contains(name)) { (this.properties[name] as BlockPropertyDoubleParam).Param2 = param2; } if (propertiesWithParam1.Contains(name)) { (this.properties[name] as BlockPropertySingleParam).Param1 = param1; } this.properties[name].Value = value; } break; } }