public async Task DesyncAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized."); return; } Context.Account.Husk = husk; // TODO: implement resync distance time // implement item selection from backpack. Memorial memorial = Context.Account.Husk.SetMemorial(); Context.Account.Husk = null; Context.Account.Brain.Memorials.Add(memorial); var now = DateTime.UtcNow; Context.Account.Brain.ResyncAt = now.AddSeconds(10); string timer = Format.Counter((Context.Account.Brain.ResyncAt.Value - now).TotalSeconds); await Context.Channel.SendMessageAsync($"You have been desychronized. You will be resynchronized in {timer}."); }
public async Task GetRelationsAsync() { Husk husk = Context.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently de-synchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; var relations = new StringBuilder(); if (Context.Account.Brain.Relations.Count == 0) { await Context.Channel.SendMessageAsync(Context.Account, "You don't seem to know anyone. Get out there and talk to others!"); } else { relations.AppendLine("Relationships:"); relations.AppendJoin("\n", Context.Account.Brain.Relations.Select(x => $"`{x.Key}` [**{AffinityData.GetLevel(x.Value).ToString()}**]")); await Context.Channel.SendMessageAsync(Context.Account, relations.ToString()); } }
public async Task GoToAsync() { Husk husk = Context.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (!Engine.CanMove(Context.Husk, out string notification)) { await Context.Channel.SendMessageAsync("You are currently in transit and cannot perform any actions."); return; } if (!string.IsNullOrWhiteSpace(notification)) { Context.Account.Notifier.Append(notification); } await Context.Channel.SendMessageAsync(Engine.WriteVisibleLocations(Context.Account.Husk, Context.Account.Brain)); }
public async Task IdentifyAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (!Engine.IsNearClosestStructure(Context.Account.Husk, out Structure structure)) { await Context.Channel.SendMessageAsync("You are not near a structure."); return; } if (Engine.TryIdentifyStructure(Context.Account.Husk, Context.Account.Brain, structure)) { await Context.Channel.SendMessageAsync($"You have identified this structure as **{structure.Name}**."); } else { await Context.Channel.SendMessageAsync($"You have already identified **{structure.Name}**"); } }
internal User( ulong id, string username, string discriminator, DateTime createdAt, Notifier notifier, ulong balance, ulong tokenBalance, ulong debt, Dictionary <string, ItemData> items, Dictionary <string, DateTime> cooldowns, Dictionary <string, long> stats, Dictionary <string, MeritData> merits, HuskBrain brain, Husk husk, UserConfig config) : base(id, username, discriminator, createdAt, config) { Username = username; Discriminator = discriminator; Balance = balance; TokenBalance = tokenBalance; Debt = debt; Items = items ?? new Dictionary <string, ItemData>(); Cooldowns = cooldowns ?? new Dictionary <string, DateTime>(); Stats = stats ?? new Dictionary <string, long>(); Merits = merits ?? new Dictionary <string, MeritData>(); Brain = brain ?? new HuskBrain(); Husk = husk; }
public async Task ViewBackpackAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (Context.Husk?.Backpack?.ItemIds?.Count() == 0) { await Context.Channel.SendMessageAsync("You do not have any items in your backpack."); return; } var items = new StringBuilder(); foreach (var item in Context.Husk.Backpack.GetItems()) { items.AppendLine($"> **{item.Name}** (x{Context.Account.Husk.Backpack.ItemIds[item.Id]})"); } await Context.Channel.SendMessageAsync(items.ToString()); }
private IEnumerable <CommandNode> GetAvailableActions(InfoService service, ModuleInfo core, User user) { var actions = new List <CommandNode>(); bool canMove = Engine.CanMove(user.Husk, out string notification); if (!string.IsNullOrWhiteSpace(notification)) { user.Notifier.Append(notification); } Husk husk = user.Husk; bool canAct = Engine.CanAct(ref husk, user.Brain); user.Husk = husk; // This is compiling all of the available actions together foreach (CommandInfo action in core?.Commands) { if (actions.Any(x => x.Name == action.Name)) { continue; } var precondition = action.Preconditions.FirstOrDefault <OnlyWhenAttribute>(); if (precondition != null) { if (!precondition.Judge(user.Brain, user.Stats)) { continue; } } var bind = action.Attributes.FirstOrDefault <BindToRegionAttribute>(); if (bind != null) { if (!canMove || !canAct) { continue; } if (!bind.Judge(user.Husk)) { continue; } } actions.Add(new CommandNode(service.GetCommands(action.Name, core))); } return(actions); }
public async Task GetScheduleAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; await Context.Channel.SendMessageAsync(((Market)(Context.Account.Husk.Location.GetLocation() as Construct)).ShowSchedule()); }
// takes the items, and gives the money. public void ApplySell(Husk husk, HuskBrain brain, ref ulong balance) { foreach ((string key, int value) in ItemIds) { husk.Backpack.ItemIds[key] -= value; if (husk.Backpack.ItemIds[key] == 0) { husk.Backpack.ItemIds.Remove(key); } } balance += Value; }
public async Task ViewStatusAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; await Context.Channel.SendMessageAsync(HuskHandler.ViewStatus(Context.Account, Context.Account.Husk)); }
public async Task ShowNpcsAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; await Context.Channel.SendMessageAsync(Context.Account, Engine.WriteVisibleCharacters(Context.Account.Husk)); }
public async Task LeaveConstructAsync() { Husk husk = Context.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (Engine.TryLeaveLocation(Context.Account.Husk)) { await Context.Channel.SendMessageAsync($"You are now in **{Context.Account.Husk.Location.GetInnerName()}**."); } }
// adds the items, and takes the money. public void ApplyBuy(Husk husk, HuskBrain brain, ref ulong balance, string marketId = null) { foreach ((string key, int value) in ItemIds) { if (!husk.Backpack.ItemIds.TryAdd(key, value)) { husk.Backpack.ItemIds[key] += value; } if (!string.IsNullOrWhiteSpace(marketId)) { brain.Catalogs[marketId].ItemIds[key] -= value; } } balance -= Value; }
internal static string ViewStatus(User user, Husk husk) { bool showTooltips = user.Config?.Tooltips ?? false; var status = new StringBuilder(); status.AppendLine($"> **HP**: **{husk.Status.Health}**/{husk.Attributes.MaxHealth}"); if (showTooltips) { status.AppendLine("> Represents your current health pool. This determines how many hits you can take before being desynchronized.\n"); } status.AppendLine($"> **Speed**: **{husk.Status.Speed}**m/s"); if (showTooltips) { status.AppendLine("> Represents your current travel speed. This determines how much time it takes for you to travel in open areas, such as a **Sector** or **Field**.\n"); } status.AppendLine($"> **Sight**: **{husk.Status.Sight}**mpp"); if (showTooltips) { status.AppendLine("> Represents your current view distance. This determines how many locations are visible from your current position (in meters per pixel).\n"); } status.AppendLine($"> **Reach**: **{husk.Status.Reach}**mpp"); if (showTooltips) { status.AppendLine("> Represents the maximum distance at which you can interact with objects or locations."); } status.AppendLine($"> **Exposure Resistance**: {Format.Counter(TimeSpan.FromMinutes(husk.Status.Exposure).TotalSeconds)}"); if (showTooltips) { status.AppendLine("> Represents a your current resistance to wild exposure. This determines how long you can remain outside of a **Sector** before you start taking damage."); } return(status.ToString()); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.transform.CompareTag("Husk")) { if (type > 0 && collision.GetComponent <Husk>().type > 0 && collision.GetComponent <Husk>().type != type) { enemyTarget = collision.GetComponent <Husk>(); } } else if (collision.transform.CompareTag("Tower")) { if (type != 0) { if (collision.transform == C.c.towers[(type == 1 ? 1 : 0)]) { enemyTower = collision.transform; } } } }
public async Task ShopAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (Engine.CanShopAt(Context.Account.Husk, out Market market)) { ShopHandler shop = new ShopHandler(Context, market, PaletteType.Glass); await HandleShopAsync(shop); } else { await Context.Channel.SendMessageAsync(Context.Account, "An error has occurred when initializing the shop."); } }
public async Task ChatAsync(string id) { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (Engine.CanChatWith(Context.Account.Husk, id, out Character npc)) { // TODO: Handle how dialogue pools are chosen. ChatHandler chat = new ChatHandler(Context, npc, Engine.GetGenericTree()); await HandleChatAsync(chat); } else { await Context.Channel.SendMessageAsync(Context.Account, "Unable to determine specified individual. Please refer to our NPC tracker (`chat`)."); } }
public async Task RecoverAsync() { Husk husk = Context.Account.Husk; if (!Engine.CanAct(ref husk, Context.Brain)) { await Context.Channel.SendMessageAsync("You are currently desynchronized. Unable to establish connection."); return; } Context.Account.Husk = husk; if (!Engine.CanMove(Context.Husk, out string notification)) { await Context.Channel.SendMessageAsync("You are currently in transit and cannot perform any actions."); return; } if (!string.IsNullOrWhiteSpace(notification)) { Context.Account.Notifier.Append(notification); } foreach (Memorial memorial in Context.Brain.Memorials) { if (Engine.CanSeePoint(Context.Husk, memorial.Location.X, memorial.Location.Y)) { Engine.Recover(Context.Husk, Context.Brain, memorial); await Context.Channel.SendMessageAsync("You have recovered your belongings."); return; } } await Context.Channel.SendMessageAsync("You are not near a memorial."); }
public static Entity Create(this EntityType entityType, World world) { Entity entity = null; switch (entityType) { case EntityType.None: return(null); case EntityType.Chicken: entity = new Chicken(world); break; case EntityType.Cow: entity = new Cow(world); break; case EntityType.Pig: entity = new Pig(world); break; case EntityType.Sheep: entity = new Sheep(world); break; case EntityType.Wolf: entity = new Wolf(world); break; case EntityType.Villager: entity = new Villager(world); break; case EntityType.MushroomCow: entity = new Mooshroom(world); break; case EntityType.Squid: entity = new Squid(world); break; case EntityType.Rabbit: entity = new Rabbit(world); break; case EntityType.Bat: entity = new Bat(world); break; case EntityType.IronGolem: entity = new VillagerGolem(world); break; case EntityType.SnowGolem: entity = new Snowman(world); break; case EntityType.Ocelot: entity = new Ocelot(world); break; case EntityType.Zombie: entity = new Zombie(world); break; case EntityType.Creeper: entity = new Creeper(world); break; case EntityType.Skeleton: entity = new Skeleton(world); break; case EntityType.Spider: entity = new Spider(world); break; case EntityType.ZombiePigman: entity = new ZombiePigman(world); break; case EntityType.Slime: entity = new Slime(world); break; case EntityType.Endermite: entity = new Endermite(world); break; case EntityType.Enderman: entity = new Enderman(world); break; case EntityType.Silverfish: entity = new Silverfish(world); break; case EntityType.CaveSpider: entity = new CaveSpider(world); break; case EntityType.Ghast: entity = new Ghast(world); break; case EntityType.MagmaCube: entity = new MagmaCube(world); break; case EntityType.Blaze: entity = new Blaze(world); break; case EntityType.ZombieVillager: entity = new ZombieVillager(world); break; case EntityType.Witch: entity = new Witch(world); break; case EntityType.Stray: entity = new Stray(world); break; case EntityType.Husk: entity = new Husk(world); break; case EntityType.WitherSkeleton: entity = new WitherSkeleton(world); break; case EntityType.Guardian: entity = new Guardian(world); break; case EntityType.ElderGuardian: entity = new ElderGuardian(world); break; case EntityType.Horse: entity = new Horse(world); break; case EntityType.ZombieHorse: entity = new ZombieHorse(world); break; case EntityType.PolarBear: entity = new PolarBear(world); break; case EntityType.Shulker: entity = new Shulker(world); break; case EntityType.EnderDragon: entity = new EnderDragon(world); break; case EntityType.SkeletonHorse: entity = new SkeletonHorse(world); break; case EntityType.Wither: entity = new Wither(world); break; case EntityType.Evoker: entity = new EvocationIllager(world); break; case EntityType.Vindicator: entity = new VindicationIllager(world); break; case EntityType.Vex: entity = new Vex(world); break; case EntityType.FallingBlock: entity = new EntityFallingBlock(world, null); break; case EntityType.ArmorStand: entity = new EntityArmorStand(world, null); break; case EntityType.Arrow: entity = new ArrowEntity(world, null); break; case EntityType.Item: entity = new ItemEntity(world, null); break; case EntityType.Mooshroom: entity = new Mooshroom(world); break; case EntityType.Snowball: entity = new SnowballEntity(world, null); break; case EntityType.ThrownEgg: entity = new EggEntity(world, null); break; case EntityType.Salmon: entity = new Salmon(world); break; case EntityType.Donkey: entity = new Donkey(world); break; case EntityType.Llama: entity = new Llama(world); break; case EntityType.Mule: entity = new Mule(world); break; case EntityType.Fox: entity = new Fox(world); break; case EntityType.Parrot: entity = new Parrot(world); break; case EntityType.Phantom: entity = new Phantom(world); break; case EntityType.Bee: entity = new Bee(world); break; case EntityType.LlamaSpit: entity = new LlamaSpit(world); break; //case EntityType.Human: //entity = new PlayerMob("test", world, ); // break; default: return(null); } return(entity); }
public void CommandSpawnMob(MiNET.Player player, string entityName, string mobName = "", string mobScale = "") { if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin)) { player.SendMessage("§c§l(!)§r §cYou do not have permission for this command."); return; } entityName = entityName.ToLower(); entityName = entityName.Substring(0, 1).ToUpper() + entityName.Substring(1); if (!Enum.TryParse(entityName, out EntityType entityType)) { player.SendMessage($"§c§l(!) §r§cUnknown EntityType '{entityName}'"); return; } Level level = player.Level; Mob mob = null; switch (entityType) { case EntityType.Chicken: mob = new Chicken(level); break; case EntityType.Cow: mob = new Cow(level); break; case EntityType.Pig: mob = new Pig(level); break; case EntityType.Sheep: mob = new Sheep(level); break; case EntityType.Wolf: mob = new Wolf(level) { Owner = player }; break; case EntityType.Villager: mob = new Villager(level); break; case EntityType.MushroomCow: mob = new MushroomCow(level); break; case EntityType.Squid: mob = new Squid(level); break; case EntityType.Rabbit: mob = new Rabbit(level); break; case EntityType.Bat: mob = new Bat(level); break; case EntityType.IronGolem: mob = new IronGolem(level); break; case EntityType.SnowGolem: mob = new SnowGolem(level); break; case EntityType.Ocelot: mob = new Ocelot(level); break; case EntityType.Zombie: mob = new Zombie(level); break; case EntityType.Creeper: mob = new Creeper(level); break; case EntityType.Skeleton: mob = new Skeleton(level); break; case EntityType.Spider: mob = new Spider(level); break; case EntityType.ZombiePigman: mob = new ZombiePigman(level); break; case EntityType.Slime: mob = new MiNET.Entities.Hostile.Slime(level); break; case EntityType.Enderman: mob = new Enderman(level); break; case EntityType.Silverfish: mob = new Silverfish(level); break; case EntityType.CaveSpider: mob = new CaveSpider(level); break; case EntityType.Ghast: mob = new Ghast(level); break; case EntityType.MagmaCube: mob = new MagmaCube(level); break; case EntityType.Blaze: mob = new Blaze(level); break; case EntityType.ZombieVillager: mob = new ZombieVillager(level); break; case EntityType.Witch: mob = new Witch(level); break; case EntityType.Stray: mob = new Stray(level); break; case EntityType.Husk: mob = new Husk(level); break; case EntityType.WitherSkeleton: mob = new WitherSkeleton(level); break; case EntityType.Guardian: mob = new Guardian(level); break; case EntityType.ElderGuardian: mob = new ElderGuardian(level); break; case EntityType.Horse: mob = new Horse(level); break; case EntityType.PolarBear: mob = new PolarBear(level); break; case EntityType.Shulker: mob = new Shulker(level); break; case EntityType.Dragon: mob = new Dragon(level); break; case EntityType.SkeletonHorse: mob = new SkeletonHorse(level); break; case EntityType.Wither: mob = new Wither(level); break; case EntityType.Evoker: mob = new Evoker(level); break; case EntityType.Vindicator: mob = new Vindicator(level); break; case EntityType.Vex: mob = new Vex(level); break; case EntityType.Npc: mob = new PlayerMob("test", level); break; } if (!String.IsNullOrEmpty(mobName)) { mob.NameTag = mobName.Replace("&", "§"); mob.HideNameTag = false; mob.IsAlwaysShowName = true; } if (!String.IsNullOrEmpty(mobScale)) { try { mob.Scale = Double.Parse(mobScale); } catch (Exception e) { Console.WriteLine(e); throw; } } mob.KnownPosition = (PlayerLocation)player.KnownPosition.Clone(); mob.SpawnEntity(); player.SendMessage($"§e§l(!) §r§eSpawned new {entityType}"); }
public void Summon(Player player, EntityTypeEnum entityType, bool noAi = true, BlockPos spawnPos = null) { EntityType petType; try { petType = (EntityType)Enum.Parse(typeof(EntityType), entityType.Value, true); } catch (ArgumentException e) { return; } if (!Enum.IsDefined(typeof(EntityType), petType)) { player.SendMessage("No entity found"); return; } var coordinates = player.KnownPosition; if (spawnPos != null) { if (spawnPos.XRelative) { coordinates.X += spawnPos.X; } else { coordinates.X = spawnPos.X; } if (spawnPos.YRelative) { coordinates.Y += spawnPos.Y; } else { coordinates.Y = spawnPos.Y; } if (spawnPos.ZRelative) { coordinates.Z += spawnPos.Z; } else { coordinates.Z = spawnPos.Z; } } var world = player.Level; Mob mob = null; Entity entity = null; EntityType type = (EntityType)(int)petType; switch (type) { case EntityType.Chicken: mob = new Chicken(world); break; case EntityType.Cow: mob = new Cow(world); break; case EntityType.Pig: mob = new Pig(world); break; case EntityType.Sheep: mob = new Sheep(world); break; case EntityType.Wolf: mob = new Wolf(world) { Owner = player }; break; case EntityType.Villager: mob = new Villager(world); break; case EntityType.MushroomCow: mob = new MushroomCow(world); break; case EntityType.Squid: mob = new Squid(world); break; case EntityType.Rabbit: mob = new Rabbit(world); break; case EntityType.Bat: mob = new Bat(world); break; case EntityType.IronGolem: mob = new IronGolem(world); break; case EntityType.SnowGolem: mob = new SnowGolem(world); break; case EntityType.Ocelot: mob = new Ocelot(world); break; case EntityType.Zombie: mob = new Zombie(world); break; case EntityType.Creeper: mob = new Creeper(world); break; case EntityType.Skeleton: mob = new Skeleton(world); break; case EntityType.Spider: mob = new Spider(world); break; case EntityType.ZombiePigman: mob = new ZombiePigman(world); break; case EntityType.Slime: mob = new Slime(world); break; case EntityType.Enderman: mob = new Enderman(world); break; case EntityType.Silverfish: mob = new Silverfish(world); break; case EntityType.CaveSpider: mob = new CaveSpider(world); break; case EntityType.Ghast: mob = new Ghast(world); break; case EntityType.MagmaCube: mob = new MagmaCube(world); break; case EntityType.Blaze: mob = new Blaze(world); break; case EntityType.ZombieVillager: mob = new ZombieVillager(world); break; case EntityType.Witch: mob = new Witch(world); break; case EntityType.Stray: mob = new Stray(world); break; case EntityType.Husk: mob = new Husk(world); break; case EntityType.WitherSkeleton: mob = new WitherSkeleton(world); break; case EntityType.Guardian: mob = new Guardian(world); break; case EntityType.ElderGuardian: mob = new ElderGuardian(world); break; case EntityType.Horse: var random = new Random(); mob = new Horse(world, random.NextDouble() < 0.10, random); break; case EntityType.PolarBear: mob = new PolarBear(world); break; case EntityType.Shulker: mob = new Shulker(world); break; case EntityType.Dragon: mob = new Dragon(world); break; case EntityType.SkeletonHorse: mob = new SkeletonHorse(world); break; case EntityType.Wither: mob = new Wither(world); break; case EntityType.Evoker: mob = new Evoker(world); break; case EntityType.Vindicator: mob = new Vindicator(world); break; case EntityType.Vex: mob = new Vex(world); break; case EntityType.Npc: if (Config.GetProperty("EnableEdu", false)) { mob = new Npc(world); } else { mob = new PlayerMob("test", world); } break; case EntityType.Boat: entity = new Boat(world); break; } if (mob != null) { mob.NoAi = noAi; var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f; mob.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw); mob.SpawnEntity(); } else if (entity != null) { entity.NoAi = noAi; var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f; entity.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw); entity.SpawnEntity(); } }
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { Log.WarnFormat("Player {0} trying to spawn Mob #{1}.", player.Username, Metadata); var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face); Mob mob = null; EntityType type = (EntityType)Metadata; switch (type) { case EntityType.Chicken: mob = new Chicken(world); break; case EntityType.Cow: mob = new Cow(world); break; case EntityType.Pig: mob = new Pig(world); break; case EntityType.Sheep: mob = new Sheep(world); break; case EntityType.Wolf: mob = new Wolf(world) { Owner = player }; break; case EntityType.Villager: mob = new Villager(world); break; case EntityType.MushroomCow: mob = new MushroomCow(world); break; case EntityType.Squid: mob = new Squid(world); break; case EntityType.Rabbit: mob = new Rabbit(world); break; case EntityType.Bat: mob = new Bat(world); break; case EntityType.IronGolem: mob = new IronGolem(world); break; case EntityType.SnowGolem: mob = new SnowGolem(world); break; case EntityType.Ocelot: mob = new Ocelot(world); break; case EntityType.Zombie: mob = new Zombie(world); break; case EntityType.Creeper: mob = new Creeper(world); break; case EntityType.Skeleton: mob = new Skeleton(world); break; case EntityType.Spider: mob = new Spider(world); break; case EntityType.ZombiePigman: mob = new ZombiePigman(world); break; case EntityType.Slime: mob = new Slime(world); break; case EntityType.Enderman: mob = new Enderman(world); break; case EntityType.Silverfish: mob = new Silverfish(world); break; case EntityType.CaveSpider: mob = new CaveSpider(world); break; case EntityType.Ghast: mob = new Ghast(world); break; case EntityType.MagmaCube: mob = new MagmaCube(world); break; case EntityType.Blaze: mob = new Blaze(world); break; case EntityType.ZombieVillager: mob = new ZombieVillager(world); break; case EntityType.Witch: mob = new Witch(world); break; case EntityType.Stray: mob = new Stray(world); break; case EntityType.Husk: mob = new Husk(world); break; case EntityType.WitherSkeleton: mob = new WitherSkeleton(world); break; case EntityType.Guardian: mob = new Guardian(world); break; case EntityType.ElderGuardian: mob = new ElderGuardian(world); break; case EntityType.Horse: mob = new Horse(world); break; case EntityType.PolarBear: mob = new PolarBear(world); break; case EntityType.Shulker: mob = new Shulker(world); break; case EntityType.Dragon: mob = new Dragon(world); break; case EntityType.SkeletonHorse: mob = new SkeletonHorse(world); break; case EntityType.Wither: mob = new Mob(EntityType.Wither, world); break; case EntityType.Npc: mob = new PlayerMob("test", world); break; } if (mob == null) { return; } mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z); mob.SpawnEntity(); Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata); }
public static Entity Create(this EntityType entityType, Level world) { Entity entity = null; switch (entityType) { case EntityType.None: return(null); case EntityType.Chicken: entity = new Chicken(world); break; case EntityType.Cow: entity = new Cow(world); break; case EntityType.Pig: entity = new Pig(world); break; case EntityType.Sheep: entity = new Sheep(world); break; case EntityType.Wolf: entity = new Wolf(world); break; case EntityType.Villager: entity = new Villager(world); break; case EntityType.MushroomCow: entity = new MushroomCow(world); break; case EntityType.Squid: entity = new Squid(world); break; case EntityType.Rabbit: entity = new Rabbit(world); break; case EntityType.Bat: entity = new Bat(world); break; case EntityType.IronGolem: entity = new IronGolem(world); break; case EntityType.SnowGolem: entity = new SnowGolem(world); break; case EntityType.Ocelot: entity = new Ocelot(world); break; case EntityType.Zombie: entity = new Zombie(world); break; case EntityType.Creeper: entity = new Creeper(world); break; case EntityType.Skeleton: entity = new Skeleton(world); break; case EntityType.Spider: entity = new Spider(world); break; case EntityType.ZombiePigman: entity = new ZombiePigman(world); break; case EntityType.Slime: entity = new Slime(world); break; case EntityType.Enderman: entity = new Enderman(world); break; case EntityType.Silverfish: entity = new Silverfish(world); break; case EntityType.CaveSpider: entity = new CaveSpider(world); break; case EntityType.Ghast: entity = new Ghast(world); break; case EntityType.MagmaCube: entity = new MagmaCube(world); break; case EntityType.Blaze: entity = new Blaze(world); break; case EntityType.ZombieVillager: entity = new ZombieVillager(world); break; case EntityType.Witch: entity = new Witch(world); break; case EntityType.Stray: entity = new Stray(world); break; case EntityType.Husk: entity = new Husk(world); break; case EntityType.WitherSkeleton: entity = new WitherSkeleton(world); break; case EntityType.Guardian: entity = new Guardian(world); break; case EntityType.ElderGuardian: entity = new ElderGuardian(world); break; case EntityType.Horse: var random = new Random(); entity = new Horse(world, random.NextDouble() < 0.10, random); break; case EntityType.PolarBear: entity = new PolarBear(world); break; case EntityType.Shulker: entity = new Shulker(world); break; case EntityType.Dragon: entity = new Dragon(world); break; case EntityType.SkeletonHorse: entity = new SkeletonHorse(world); break; case EntityType.Wither: entity = new Wither(world); break; case EntityType.Evoker: entity = new Evoker(world); break; case EntityType.Vindicator: entity = new Vindicator(world); break; case EntityType.Vex: entity = new Vex(world); break; case EntityType.Npc: entity = new PlayerMob("test", world); break; default: return(null); } return(entity); }
public string GetActions(User user) { StringBuilder panel = new StringBuilder(); // Husk system if (user?.Husk != null) { bool canMove = Engine.CanMove(user.Husk, out string notification); if (!string.IsNullOrWhiteSpace(notification)) { user.Notifier.Append(notification); } Husk husk = user.Husk; bool canAct = Engine.CanAct(ref husk, user.Brain); user.Husk = husk; panel.AppendLine(); panel.AppendLine("**Actions**"); panel.Append("• "); Locator location = user.Husk.Location; // you need to implement movement info. if (user.Husk.Destination != null) { location = user.Husk.Destination; } panel.AppendLine(Engine.WriteLocationInfo(location.Id, user.Husk.Destination != null)); ModuleInfo main = _commands.Modules.FirstOrDefault(x => x.Name == "Actions"); List <CommandNode> actions = new List <CommandNode>(); foreach (CommandInfo action in main?.Commands) { if (actions.Any(x => x.Name == action.Name)) { continue; } // Flag checking OnlyWhenAttribute precondition = action.Preconditions.FirstOrDefault <OnlyWhenAttribute>(); // replace with BindToRegion when ready BindToRegionAttribute check = action.Attributes.FirstOrDefault <BindToRegionAttribute>(); if (precondition != null) { if (!precondition.Judge(user.Brain, user.Stats)) { continue; } } if (check != null) { if (!canMove) { continue; } if (!canAct) { continue; } if (!check.Judge(user.Husk)) { continue; } } actions.Add(new CommandNode(GetCommands(action.Name, main))); } panel.AppendJoin(" • ", actions.Select(delegate(CommandNode x) { string term = $"`{x.Name}`"; if (x.Overloads.Count > 1) { term += $"**+{x.Overloads.Count - 1}**"; } return(term); })); } else { panel.Append("Where are you?"); } return(panel.ToString()); }