public int HoverOnSlot() { foreach (CardInventoryGridSlot Gri in Grid) { if (ModHelper.MouseInRectangle(Gri.uiRectangle)) { return(Grid.IndexOf(Gri)); } } return(-1); }
private async void OnMailDelivery(object sender, EventArgs e) { try { await DeliverPostedMail(); } catch (Exception ex) { ModHelper.HandleError(_mod, ex, "delivering mail on schedule"); } }
private void MailDelivered(object sender, EventArgs e) { try { Task.Run(() => DeletePostedRemoteMail()); } catch (Exception ex) { ModHelper.HandleError(_mod, ex, "deleting mail from server"); } }
private async Task DeliverLocalMailToCloud() { _mod.Monitor.Log($"{logPrefix}.delivering local mail to cloud...", LogLevel.Debug); var localMail = GetLocallyComposedMail(); var localFarmers = _farmerService.GetFarmers(); var updatedLocalMail = new List <Mail>(); // Consider: Add an api method that takes a list of MailCreateModels if (localMail.Any()) { _mod.Monitor.Log($"{logPrefix}..uploading {localMail.Count} mail to cloud...", LogLevel.Debug); foreach (var mail in localMail) { if (!localFarmers.Any(x => x.Id == mail.ToFarmerId)) { var createMailModel = new CreateMailModel { ToFarmerId = mail.ToFarmerId, FromFarmerId = mail.FromFarmerId, Text = mail.Text, CreatedDate = mail.CreatedDate }; var urlSegments = new Dictionary <string, string> { { "mailId", mail.Id.ToString() } }; var request = ModHelper.FormStandardRequest("mail/{mailId}", urlSegments, Method.PUT); request.AddJsonBody(createMailModel); var response = await _restClient.ExecuteTaskAsync <bool>(request); if (!string.IsNullOrEmpty(response.ErrorMessage)) { _mod.Monitor.Log($"{logPrefix}{response.ErrorMessage}", LogLevel.Warn); continue; } if (response.Data) { mail.Status = MailStatus.Posted; updatedLocalMail.Add(mail); _mod.Monitor.Log($"{logPrefix}...done", LogLevel.Debug); } } } Repository.Instance.Upsert(updatedLocalMail.AsEnumerable()); } else { _mod.Monitor.Log($"{logPrefix}..no local mail to deliver to cloud", LogLevel.Debug); } _mod.Monitor.Log($"{logPrefix}..done", LogLevel.Debug); }
private bool AddUnknownMusicPackMusicFiles(ref bool mood_entries_not_found) { Debug.Log("[CSLMusic] Fetching unknown music pack music files ..."); bool foundsomething = false; List <String> searchfolders = new List <string>(); searchfolders.AddRange(ModOptions.ModdedMusicSourceFolders); if (Directory.Exists(ConversionManager.ConvertedMusicPackMusicFolder)) { searchfolders.AddRange(Directory.GetDirectories(ConversionManager.ConvertedMusicPackMusicFolder)); } /** * Add *.raw music from mod folders if somebody really wants to upload raw files * and music from converted * */ foreach (String folder in searchfolders) { if (Directory.Exists(folder)) { var modid = Directory.GetParent(folder).Name; Debug.Log("[CSLMusic] Looking for MusicPack songs in " + folder + ", mod-id " + modid); //Does the plugin exist? Is it active PluginManager.PluginInfo info = ModHelper.GetSourceModFromId(modid); if (info == null) { Debug.LogWarning("[CSLMusic] Unknown mod in folder @ " + folder); continue; } if (info.isEnabled) { Debug.Log("[CSLMusic] Adding mod conversion files from " + folder); foundsomething |= AddUnknownMusicFiles(folder, ref mood_entries_not_found); } else { Debug.Log("[CSLMusic] Not adding mod conversion files from " + folder + ": Not enabled"); Debug.Log("-> Directory of this mod is " + info.modPath); } } else { Debug.LogError("ERROR: " + folder + " is not existing!"); } } return(foundsomething); }
public void DoSetup() { Log.DebugDelegate += Output; Log.WarningDelegate += Output; Log.ErrorDelegate += Output; // Tell the engine about our mod assembly so it can load up our code. // It doesn't matter which type as long as it comes from the mod's assembly. var a = Assembly.GetAssembly(typeof(MigrantCoderCharacterCardController)); // replace with your own type ModHelper.AddAssembly("Workshopping", a); // replace with your own namespace }
private void moveUpButton_Click(object sender, EventArgs e) { if (spriteList.SelectedIndex > 0) { var modification = new MoveSpriteListEntry(sprites, spriteList.SelectedIndex, -1); ModHelper.DoModificationWithSelectionTracking(modification, spriteList); undoHistory.Add(modification); int newPosition = spriteList.SelectedIndex - 1; spriteList.SelectedIndices.Clear(); spriteList.SelectedIndex = newPosition; } }
private void MailRead(object sender, MailReadEventArgs e) { var currentFarmerId = _farmerService.CurrentFarmer.Id; var mail = Repository.Instance.FirstOrDefault <Mail>(x => x.Id == e.Id); if (mail != null) { mail.Status = MailStatus.Read; mail.ReadInGameDate = ModHelper.GetGameDayTime(); Repository.Instance.Update(mail); } }
private void originYPosBox_ValueChanged(object sender, EventArgs e) { if (loadingSprite) { return; } var modification = new ModifyOrigin(selectedSprites, y: (int)originYPosBox.Value); ModHelper.DoModificationWithSelectionTracking(modification, spriteList); undoHistory.Add(modification); spriteSheetViewer.Refresh(); }
public override void AI() { // 污染之灵 NPC elemental = Main.npc[(int)projectile.ai[1]]; // 保险 if (elemental == null || elemental.type != NPCType <PollutionElemental>() || elemental.active == false) { projectile.active = false; projectile.Kill(); projectile.netUpdate = true; return; } Player player = Main.player[elemental.target]; projectile.Center = elemental.Center; projectile.ai[0]++; if (projectile.ai[0] == 15 && Main.netMode != NetmodeID.MultiplayerClient) { // 射击 foreach (var rotation in rotates) { Vector2 vec = rotation.ToRotationVector2(); int bullet = Projectile.NewProjectile(projectile.Center, vec * 0.9f, ProjectileType <ContimatedSpike>(), 40, 2f); if (Main.dedServ) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, bullet); } } projectile.active = false; projectile.Kill(); } if (projectile.ai[0] == 1 && Main.netMode != NetmodeID.MultiplayerClient) { // 选取 float startRadius = ModHelper.GetFromToRadians(projectile.Center, player.Center); float endRadius = ModHelper.GetFromToRadians(projectile.Center, player.Center) + MathHelper.TwoPi; for (float rotation = startRadius; rotation < endRadius; rotation += MathHelper.TwoPi / 12f) { rotates.Add(rotation); // 特效 Vector2 vec = rotation.ToRotationVector2(); int proj = Projectile.NewProjectile(projectile.Center, vec, ProjectileType <EffectRay>(), 0, 0f, projectile.owner); Main.projectile[proj].ai[1] = projectile.whoAmI; if (Main.dedServ) { NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, proj); } } } }
private void spriteHeightBox_ValueChanged(object sender, EventArgs e) { if (loadingSprite) { return; } var modification = new ModifyBounds(selectedSprites, height: (int)spriteHeightBox.Value); ModHelper.DoModificationWithSelectionTracking(modification, spriteList); undoHistory.Add(modification); UpdateHighlightMask(); spriteSheetViewer.Refresh(); }
private void originPresetBox_SelectedIndexChanged(object sender, EventArgs e) { if ((OriginPreset)originPresetBox.SelectedIndex == OriginPreset.None) { return; } var modification = new ApplyOriginPreset(selectedSprites, (OriginPreset)originPresetBox.SelectedIndex); ModHelper.DoModificationWithSelectionTracking(modification, spriteList); undoHistory.Add(modification); spriteSheetViewer.Refresh(); }
public void DoSetup() { Log.DebugDelegate += Output; Log.WarningDelegate += Output; Log.ErrorDelegate += Output; var Riverport = Assembly.GetAssembly(typeof(Riverport.Dragontamer.DragontamerTurnTakerController)); ModHelper.AddAssembly("Riverport", Riverport); // Tell the engine about our mod assembly so it can load up our code. // It doesn't matter which type as long as it comes from the mod's assembly. }
private async Task DeleteRemoteMail(Mail mail) { var urlSegments = new Dictionary <string, string> { { "mailId", mail.Id.ToString() } }; var request = ModHelper.FormStandardRequest("mail/{mailId}", urlSegments, Method.DELETE); var response = await _restClient.ExecuteTaskAsync <bool>(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { // all good :) } }
public override void ModSettings() { modSettings.AddButton("resetMopPosition", "RESET MOP POSITION", ResetMopPosition); modSettings.AddSpacer(5); modSettings.AddHeader("LINKS"); modSettings.AddButton("paypal", "HOMEPAGE", () => ModHelper.OpenWebsite("http://athlon.kkmr.pl")); modSettings.AddButton("paypal", "<color=aqua>PAYPAL</color>", () => ModHelper.OpenWebsite("https://www.paypal.com/paypalme/figurakonrad")); modSettings.AddSpacer(5); modSettings.AddHeader("CHANGELOG"); modSettings.AddText(GetChangelog()); }
public override void Draw(SpriteBatch spriteBatch) { Player clientPlayer = Main.LocalPlayer; EntrogicPlayer clientModPlayer = EntrogicPlayer.ModPlayer(clientPlayer); bool Animationing = StartAnimation && AnimationTimer >= 1 ? true : false; uiWidth = 38; uiHeight = 50; float alpha = 0.36f; if (!Animationing && ModHelper.MouseInRectangle(uiRectangle) && inventoryItem.type != ItemID.None && inventoryItem != null) { if (PlayerTurn && clientModPlayer.CardGameLeftCard > 0) { Main.hoverItemName = $"{inventoryItem.Name}\n点击以使用"; alpha = 1f; } } // 没有UI贴图 //spriteBatch.Draw(ModContent.GetTexture("Entrogic/UI/Cards/HelpGrid"), finalUIPosition, uiColor); if (!Animationing && inventoryItem.type != ItemID.None && inventoryItem != null) { Texture2D t = Main.itemTexture[inventoryItem.type]; var frame = Main.itemAnimations[inventoryItem.type] != null ? Main.itemAnimations[inventoryItem.type].GetFrame(Main.itemTexture[inventoryItem.type]) : Main.itemTexture[inventoryItem.type].Frame(1, 1, 0, 0); spriteBatch.Draw(t, finalUIPosition, (Rectangle?)frame, Color.White * alpha); } if (Animationing) { Texture2D t = Main.itemTexture[inventoryItem.type]; var frame = Main.itemAnimations[inventoryItem.type] != null ? Main.itemAnimations[inventoryItem.type].GetFrame(Main.itemTexture[inventoryItem.type]) : Main.itemTexture[inventoryItem.type].Frame(1, 1, 0, 0); Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Main.UIScaleMatrix); // Retrieve reference to shader var whiteBlur = GameShaders.Misc["Entrogic:WhiteBlur"]; // Reset back to default value. whiteBlur.UseOpacity(0f); if (AnimationTimer > 15f) { whiteBlur.UseOpacity(MathHelper.Min((AnimationTimer - 15f) / 8f, 1f)); } whiteBlur.Apply(null); spriteBatch.Draw(t, AnimationPosition + fatherPosition, (Rectangle?)frame, Color.White); // As mentioned above, be sure not to forget this step. Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, null, null, Main.UIScaleMatrix); } }
/// <summary> /// Makes sure that the speed gameplayModifier selected matches up with the game clock and sets the correct one. /// </summary> private static void CheckModInconsistencies() { try { if (AudioEngine.Track != null && !AudioEngine.Track.IsDisposed) { AudioEngine.Track.Rate = ModHelper.GetRateFromMods(Mods); } } catch (Exception e) { // ignored. } }
private void ShowWeeklyRecipes() { if (_thisWeeksRecipes.Count == 0) { ShowNoRecipes(); return; } Monitor.Log($"This weeks recipes are:", LogLevel.Alert); foreach (var item in _thisWeeksRecipes) { Monitor.Log($"{ModHelper.GetMoneyAsString(item.AquisitionConditions.Cost)} - {item.Name}", LogLevel.Info); } }
/// <summary> /// Adds a judgement to the hit error at a given hit time. /// </summary> public void AddJudgement(Judgement j, double hitTime) { CurrentLinePoolIndex++; if (CurrentLinePoolIndex >= PoolSize) { CurrentLinePoolIndex = 0; } LineObjectPool[CurrentLinePoolIndex].Tint = SkinManager.Skin.Keys[MapManager.Selected.Value.Mode].JudgeColors[j]; LineObjectPool[CurrentLinePoolIndex].X = -(float)hitTime / ModHelper.GetRateFromMods(ModManager.Mods); LineObjectPool[CurrentLinePoolIndex].Alpha = 0.5f; }
/// <summary> /// Skips the song to the next object if on a break. /// </summary> private void SkipToNextObject(bool force = false) { if (!EligibleToSkip || IsPaused || IsResumeInProgress) { return; } if (IsMultiplayerGame && !force) { if (RequestedToSkipSong) { return; } OnlineManager.Client?.RequestToSkipSong(); RequestedToSkipSong = true; NotificationManager.Show(NotificationLevel.Info, "Requested to skip song. Waiting for all other players to skip!"); return; } // Get the skip time of the next object. var nextObject = Ruleset.HitObjectManager.NextHitObject.StartTime; var skipTime = nextObject - GameplayAudioTiming.StartDelay * ModHelper.GetRateFromMods(ModManager.Mods); try { // Skip to the time if the audio already played once. If it hasn't, then play it. AudioEngine.Track?.Seek(skipTime); Timing.Time = AudioEngine.Track.Time; } catch (Exception e) { Logger.Error(e, LogType.Runtime); Logger.Warning("Trying to skip with no audio file loaded. Still continuing..", LogType.Runtime); Timing.Time = skipTime; } finally { if (InReplayMode) { var inputManager = (KeysInputManager)Ruleset.InputManager; inputManager.ReplayInputManager.HandleSkip(); } // Stop all playing sound effects and move NextSoundEffectIndex ahead. CustomAudioSampleCache.StopAll(); UpdateNextSoundEffectIndex(); } }
/// <summary> /// Gets the adjacent rate value. /// /// For example, if the current rate is 1.0x, the adjacent value would be either 0.95x or 1.1x, /// depending on the argument. /// </summary> /// <param name="faster">If true, returns the higher rate, otherwise the lower rate.</param> /// <returns></returns> private static float GetNextRate(bool faster) { var current = ModHelper.GetRateFromMods(ModManager.Mods); var adjustment = 0.1f; // ReSharper disable once CompareOfFloatsByEqualityOperator if (current < 1.0f || (current == 1.0f && !faster)) { adjustment = 0.05f; } var next = current + adjustment * (faster ? 1f : -1f); return((float)Math.Round(next, 2)); }
public override void Update(GameTime gameTime, Player attackPlayer, NPC attackNPC) { //if (LifeSpan > 4.96 && LifeSpan <= 5.1f) // Velocity += -ModHelper.GetFromToVector(CardGameUI.ToUIPos(Center), TargetPosition) * 0.4f; //else if (LifeSpan <= 5.1f) Velocity += ModHelper.GetFromToVector(CardGameUI.ToUIPos(Center), TargetPosition) * 0.9f; _rotation = MathHelper.ToRadians(45f) + ModHelper.GetFromToRadians(CardGameUI.ToUIPos(Center), TargetPosition); if (Vector2.Distance(CardGameUI.ToUIPos(Center), TargetPosition) < 20f) { IsRemoved = true; CardFightableNPC fightNPC = (CardFightableNPC)attackNPC.modNPC; fightNPC.CardGameHealth -= 120 / 5; // 总伤害120,,因为一射5个 } base.Update(gameTime, attackPlayer, attackNPC); }
private void spriteSheetViewer_MouseUp(object sender, MouseEventArgs e) { if (movingWithMouse) { movingWithMouse = false; var totalDragX = selectedSprites[0].Bounds.X - preDragBounds[0].X; var totalDragY = selectedSprites[0].Bounds.Y - preDragBounds[0].Y; if (totalDragX != 0 || totalDragY != 0) { var modification = new MoveBounds(selectedSprites, totalDragX, totalDragY, preDragBounds); modification.Undo(); ModHelper.DoModificationWithSelectionTracking(modification, spriteList); undoHistory.Add(modification); } } }
private void SaveEvents_AfterLoad(object sender, EventArgs e) { // render update warning if (_config.CheckForUpdates && !_hasSeenUpdateWarning && _newRelease != null) { try { _hasSeenUpdateWarning = true; ModHelper.ShowInfoMessage($"You can update {ModConstants.ModName} from {_currentVersion} to {_newRelease}."); } catch (Exception ex) { ModHelper.HandleError(_mod, ex, "showing the new version available"); } } }
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float fireCount = Main.rand.NextFloat() * 3 + 4; float spread = Main.rand.NextFloat() * 10 + 25; for (float i = 0; i < fireCount; ++i) { Vector2 speedZ = ModHelper.rotateByDegree(new Vector2(speedX, speedY), (i / fireCount - 0.5f) * spread); // Terraria.Projectile.NewProjectile(position.X, position.Y, speedZ.X, speedZ.Y, 651, 1, 15f, Main.myPlayer); } for (float i = 0; i < 1; ++i) { Terraria.Projectile.NewProjectile(position.X, position.Y, speedX, speedY, 651, 80, 145f, Main.myPlayer); } return(false); }
/// <summary> /// Creates the text that displays the difficulty name of the map. /// </summary> private void CreateDifficultyName() { var text = $"[{Map.DifficultyName}]"; if (Screen.ScoreProcessor.Mods != 0) { text += $" + {ModHelper.GetModsString(Screen.ScoreProcessor.Mods)}"; } DifficultyName = new SpriteText(Fonts.Exo2SemiBold, text, 13) { Parent = this, X = Thumbnail.X + Thumbnail.Width + 10, Y = 25 }; }
public override float SpawnChance(NPCSpawnInfo spawnInfo) { Player player = spawnInfo.player; if ((NPC.CountNPCS(NPCType <Mushman>()) < 1) && Main.dayTime && ModHelper.NoBiomeNormalSpawn(spawnInfo) && player.ZoneOverworldHeight) { if (player.ZoneRain) { return(0.0078f); } else { return(0.005f); } } return(0f); }
/// <summary> /// Loads the track for the currently selected map. /// </summary> public static void LoadCurrentTrack() { Map = MapManager.Selected.Value; if (Track != null && !Track.IsDisposed) { Track.Dispose(); } Track = new AudioTrack(MapManager.CurrentAudioPath) { Volume = ConfigManager.VolumeMusic.Value, Rate = ModHelper.GetRateFromMods(ModManager.Mods), }; Track.ToggleRatePitching(ConfigManager.Pitched.Value); }
public override void HoldItem(Player player) { Item i = ModHelper.GetRandomCard(Main.LocalPlayer, Main.rand); if (Main.mouseItem.type != item.type) { // 将原物品消除 player.inventory[player.selectedItem].active = false; player.inventory[player.selectedItem].TurnToAir(); // 把物品"塞"里面 player.inventory[player.selectedItem] = i; return; } Main.mouseItem.active = false; Main.mouseItem.TurnToAir(); Main.mouseItem = i; }
private void removeSpriteButton_Click(object sender, EventArgs e) { int indexToRemove = spriteList.SelectedIndex; if (indexToRemove == sprites.Count - 1) { spriteList.SelectedIndices.Clear(); spriteList.SelectedIndex = indexToRemove - 1; } if (indexToRemove > -1 && indexToRemove < sprites.Count) { var modification = new RemoveSprite(sprites, indexToRemove); ModHelper.DoModificationWithSelectionTracking(modification, spriteList); undoHistory.Add(modification); } }