public void Execute(ISystemContainer systemContainer, Map map, MapGenCommand command, Vector offset) { var coordinate = new MapCoordinate(map.MapKey, offset + command.Vector); List <string> splits; string entityName = GetEntityName(command, out splits); var entity = systemContainer.PrototypeSystem.CreateAt(entityName, coordinate); splits.Remove(splits.First()); var regexParse = new Regex("(.*)\\.(.*)=(.*)"); foreach (var entityParameterUpdate in splits) { var results = regexParse.Match(entityParameterUpdate); var componentName = results.Groups[1].Value; var fieldName = results.Groups[2].Value; var value = results.Groups[3].Value; var component = entity.Get(componentName); ComponentSerializer.BindSingleValue(component, fieldName, value); } }
private void CompleteEntityCommand(IMap map, Vector vector, string command, string parameters) { var entityCommand = new MapGenCommand { MapGenCommandType = command, Parameters = parameters, Vector = vector }; map.AddCommand(entityCommand); }
public void Execute(ISystemContainer systemContainer, Map map, MapGenCommand command, Vector offset) { var coordinate = new MapCoordinate(map.MapKey, offset + command.Vector); List <IEntity> itemList = systemContainer.ItemSystem.GetSpawnableItems(); var itemGenerator = new EnchantedItemGenerator(systemContainer, itemList); var item = itemGenerator.GenerateItem(itemList, 1, systemContainer.Random); systemContainer.PositionSystem.SetPosition(item, new MapCoordinate(map.MapKey, offset + command.Vector)); }
public void Execute(ISystemContainer systemContainer, Map map, MapGenCommand command, Vector offset) { var coordinate = new MapCoordinate(map.MapKey, offset + command.Vector); var splits = command.Parameters.Split(','); var entityName = splits[0]; var stackSize = int.Parse(splits[1]); var entity = systemContainer.PrototypeSystem.CreateAt(entityName, coordinate); entity.Get <Stackable>().StackSize = stackSize; }
public void Execute_WithEntityName_CreatesEntity() { var entityName = "Banana"; var command = new MapGenCommand { MapGenCommandType = MapGenCommandType.Entity, Parameters = entityName, Vector = new Vector(0, 0) }; _executor.Execute(_systemContainer, _map, command, command.Vector); _prototypeSystem.Received().CreateAt(entityName, new MapCoordinate(MAP_KEY, 0, 0)); }
public void Execute(ISystemContainer systemContainer, Map map, MapGenCommand command, Vector offset) { var itemLevel = string.IsNullOrEmpty(command.Parameters) ? 0 : int.Parse(command.Parameters); var coordinate = new MapCoordinate(map.MapKey, offset + command.Vector); var itemList = systemContainer.ItemSystem.GetSpawnableItems(); itemList = itemList.Where(i => !i.Has <Wealth>()).ToList(); var shop = new EnchantedItemShopGenerator().GenerateShop(systemContainer, systemContainer.Random.Between(4, 10), itemLevel, itemList, systemContainer.Random); systemContainer.PositionSystem.SetPosition(shop, coordinate); }
public void Execute_WithEntityNameAndProperty_CreatesEntityAndSetsProperty() { var entityName = "Sign"; var entity = new Entity(0, entityName, new[] { new Dialog() }); _prototypeSystem.CreateAt(entityName, new MapCoordinate(MAP_KEY, 0, 0)).Returns(entity); var command = new MapGenCommand { MapGenCommandType = MapGenCommandType.Entity, Parameters = $"{entityName}|Dialog.Text=I am a sign!", Vector = new Vector(0, 0) }; _executor.Execute(_systemContainer, _map, command, command.Vector); _prototypeSystem.Received().CreateAt(entityName, new MapCoordinate(MAP_KEY, 0, 0)); entity.Get <Dialog>().Text.Should().Be("I am a sign!"); }
public void Execute(ISystemContainer systemContainer, Map map, MapGenCommand command, Vector offset) { // These are just to indicate to the generator where connections should go. }
public static string GetEntityName(MapGenCommand command, out List <string> splits) { splits = command.Parameters.Split('|').ToList(); return(splits[0]); }