public static void Give(string[] Args) { if (!Net.Work.IsNetworkServer()) { Console.ThrowPrint("Must be the host player to give items"); return; } if (ArgCountMismatch(Args, 3)) { return; } string PlayerName = Args[0]; string TypeString = Args[1]; string CountString = Args[2]; Player TargetPlayer = null; foreach (KeyValuePair <int, string> CurrentNick in Net.Nicknames) { if (CurrentNick.Value == PlayerName) { TargetPlayer = Net.Players[CurrentNick.Key].Plr.ValueOr((Player)null); } } if (TargetPlayer is null) { Console.ThrowPrint($"No player named '{PlayerName}'"); return; } Items.ID Id = Items.ID.ERROR; foreach (Items.ID CurrentId in System.Enum.GetValues(typeof(Items.ID))) { if (CurrentId.ToString() == TypeString) { Id = CurrentId; break; } } if (Id == Items.ID.ERROR) { Console.ThrowPrint($"No item type by the name '{TypeString}'"); return; } if (int.TryParse(CountString, out int GiveCount) && GiveCount > 0) { TargetPlayer.ItemGive(new Items.Instance(Id) { Count = GiveCount }); } else { Console.ThrowPrint($"Invalid item count '{CountString}'"); return; } }
protected virtual void RotateAnimation() { int dir = sprite_direction; if (velocity != Vector2.Zero) { direction = Math.Atan2((double)velocity.Y, (double)velocity.X); if (direction < 0) { direction += 2 * Math.PI; } if (direction != lastDirection) { lastDirection = direction; dir = (int)((direction + (Math.PI / 8)) / (Math.PI / 4)); if (dir > 7) { dir = 0; } string[] anim = CurrentId.Split('_'); sprite_direction = dir; PlayAnimation(anim[0] + '_' + dir); } } }