public static void GenerateShrine(User user, int numberOfShrines = 1, int shrineSize = 12) { if (shrineSize < 1 || shrineSize > 20) { ChatManager.DebugAddToChatLog("#Shrine location", "Shrine size must be between 1 and 20", user.Name, 1); return; } for (int i = 0; i < numberOfShrines; ++i) { var location = World.GetRandomLandPos() + (Vector3i.Down * (shrineSize * 2)); location.SpiralOutXZIter(shrineSize).ForEach(x => { var height = Math.Min((shrineSize * 0.5f), (shrineSize * 0.6f) - WorldPosition3i.Distance(x, location)); for (int j = 0; j < height; ++j) { if (!World.GetBlock((Vector3i)x + (Vector3i.Up * j)).Is <Impenetrable>()) { World.DeleteBlock((Vector3i)x + (Vector3i.Up * j)); } if ((int)WorldPosition3i.Distance(x, location) != 0 && !World.GetBlock((Vector3i)x + (Vector3i.Down * j)).Is <Impenetrable>()) { World.SetBlock <WaterBlock>((Vector3i)x + (Vector3i.Down * j)); } } }); WorldObjectUtil.Spawn("EckoStatueObject", null, (Vector3i)location); ChatManager.DebugAddToChatLog("#Shrine location", location.ToString(), user.Name, 1); } }
public static void SpawnBed(User user) { RoomChecker.SpawnBuilding(user, 1, new Vector3i(5, 5, 5), user.Player.Position.Round + Vector3i.Down - new Vector3i(2, 0, 2)); var bed = WorldObjectUtil.SpawnAndClaim <BedComponent>("WoodenFabricBedObject", user, user.Position.Round + Vector3i.Forward); Thread.Sleep(2000); bed.Sleep(user.Player); }
public static string GetCraftingTablesString() { try { var allCraftingTables = WorldObjectUtil.AllObjsWithComponent <CraftingComponent>(); Logger.Debug("Started collecting crafting tables information: " + allCraftingTables.Count()); var tablesToExport = new JsonHistCraftingTables(allCraftingTables); var craftingTablesString = JsonConvert.SerializeObject(tablesToExport); Logger.Debug("Got crafting tables string"); return(craftingTablesString); } catch (Exception e) { Logger.Error($"Got an exception trying to export crafting tables: \n {e}"); return(null); } }
public void Generate(Random seed, Vector3 voxelSize, WorldSettings settings) { for (int i = 0; i < numberOfShrines; ++i) { var location = World.GetRandomLandPos() + (Vector3i.Down * (shrineSize * 2)); location.SpiralOutXZIter(shrineSize).ForEach(x => { var height = Math.Min((shrineSize * 0.5f), (shrineSize * 0.6f) - WorldPosition3i.Distance(x, location)); for (int j = 0; j < height; ++j) { if (!World.GetBlock((Vector3i)x + (Vector3i.Up * j)).Is <Impenetrable>()) { World.DeleteBlock((Vector3i)x + (Vector3i.Up * j)); } if ((int)WorldPosition3i.Distance(x, location) != 0 && !World.GetBlock((Vector3i)x + (Vector3i.Down * j)).Is <Impenetrable>()) { World.SetBlock <WaterBlock>((Vector3i)x + (Vector3i.Down * j)); } } }); WorldObjectUtil.Spawn("EckoStatueObject", null, (Vector3i)location); } }
public static LocString NextFoodBody(User user, int count = 3) { Dictionary <FoodItem, HashSet <LocString> > whereArtFood = new Dictionary <FoodItem, HashSet <LocString> >(); if (user.Carrying != null && user.Carrying.Item is FoodItem) { addItem(whereArtFood, user.Carrying.Item as FoodItem, user.UILink()); } foreach (ItemStack stack in user.Inventory.ToolbarBackpack.Stacks.Where(item => item.Item is FoodItem)) { addItem(whereArtFood, stack.Item as FoodItem, user.UILink()); } IEnumerable <StorageComponent> enumerable = WorldObjectUtil.AllObjsWithComponent <StorageComponent>(); IEnumerable <StorageComponent> accessibleStorage = enumerable.Where(i => i.Parent.Auth.Owners != null && (i.Parent.Auth.Owners.Contains(user) || i.Parent.Auth.UsersWithFullAccess.Contains(user) || i.Parent.Auth.UsersWithConsumerAccess.Contains(user))); foreach (StorageComponent storage in accessibleStorage) { foreach (ItemStack stack in storage.Inventory.Stacks.Where(item => item.Item is FoodItem)) { addItem(whereArtFood, stack.Item as FoodItem, storage.Parent.UILink()); } } IEnumerable <StoreComponent> storesWithFood = Stores .Where(store => store.Enabled != false) .Where(store => store.StoreData.SellOffers .Where(item => item.Stack.Quantity > 0) .Where(item => item.Stack.Item is FoodItem) .Count() > 0); foreach (StoreComponent store in storesWithFood) { IEnumerable <TradeOffer> foodTrades = store.StoreData.SellOffers.Where(item => item.Stack.Quantity > 0).Where(item => item.Stack.Item is FoodItem); foreach (TradeOffer trade in foodTrades) { addItem(whereArtFood, trade.Stack.Item as FoodItem, store.Parent.UILink()); } } IEnumerable <KeyValuePair <FoodItem, float> > possibleBuys = whereArtFood.Keys .ToDictionary(it => it, it => FoodCalculatorComponent.getSkillPointsVariation(user.Player, it as FoodItem)) .Where(it => it.Key.Calories != 0) .OrderByDescending(pair => pair.Value) .Take(count); List <LocString> body = new List <LocString>(); if (possibleBuys.Count() > 0) { foreach (var possibleBuy in possibleBuys) { LocString itemValue = LocStringExtensions.Style( Localizer.DoStr(Math.Round(possibleBuy.Value, 2).ToString()), possibleBuy.Value >= 0 ? Text.Styles.Positive : Text.Styles.Negative ); String locations = String.Join(", ", whereArtFood[possibleBuy.Key]); body.Add(Localizer.Format("{0} will give you {1} points and can be found at: {2}", possibleBuy.Key.UILink(), itemValue, locations)); } } else { body.Add(Localizer.DoStr("Could not find you any food")); } return(Localizer.DoStr(String.Join("\n", body))); }
public void ActionPerformed(GameAction action) { WorldObjectUtil.ActionPerformed(this, action); }
public bool ShouldOverrideAuth(GameAction action) { return(WorldObjectUtil.ShouldOverrideAuth(this, action)); }
public static void SpawnToll(User user) { var otherUser = TestUtils.OtherUser(user); var station = WorldObjectUtil.SpawnAndClaim <TollComponent>("TollObject", otherUser, user.Position.XZi); var door = WorldObjectUtil.SpawnAndClaim("DoorObject", otherUser, user.Position.XZi + Vector2i.Right); }