Beispiel #1
0
        private void ConsoleCommand(string str, ITMGame game, ITMPlayer player1, ITMPlayer player2, IOutputLog log)
        {
            str = str.ToLower();
            string[] commands = str.Split(' ');

            if (commands.Length > 1)
            {
                switch (commands[1])
                {
                case "help": log.WriteLine(QuickGatherHelp(commands)); break;

                case "toggleveinmine": log.WriteLine(ToggleVeinMining()); break;

                case "togglelumberjack": log.WriteLine(ToggleLumberJack()); break;

                case "toggleharvest": log.WriteLine(ToggleHarvesting()); break;

                case "saveconfig": log.WriteLine(SaveConfigs()); break;

                case "ver": log.WriteLine(GetVersion()); break;

                case "version": log.WriteLine(GetVersion()); break;

                default: log.WriteLine("Unknown Command use 'qg help' for more info"); break;
                }
            }
            else
            {
                log.WriteLine("Unknown Command use 'qg help' for help");
            }
        }
Beispiel #2
0
 public void GiveItems(ITMPlayer player)
 {
     foreach (InventoryItem item in this.GetItems())
     {
         player.AddToInventory(item);
     }
 }
Beispiel #3
0
 public void ConsumeItems(ITMPlayer player)
 {
     foreach (InventoryItem item in this.GetItems())
     {
         player.Inventory.DecrementItem(item.ItemID, item.Count);
     }
 }
        public void Update(ITMPlayer player)
        {
            particleElapsed += Services.ElapsedTime;
            if (particleElapsed > 1)
            {
                //var data = new ParticleData()
                //{
                //    Duration = 8000,
                //    Gravity = 1,
                //    Size = new Vector4(0.2f, 0.2f, 0.2f, 1f),
                //    StartColor = Color.White,
                //    EndColor = Color.White,
                //    VelocityType = ScriptCoordType.Absolute,
                //    Velocity = player.ViewDirection * 10
                //};
                //game.AddParticle(player.EyePosition, ref data);
                particleElapsed = 0;
            }

            if (cam != null)
            {
                var vd = Vector3.Normalize(new Vector3(player.ViewDirection.X, 0, player.ViewDirection.Z));
                cam.Position      = player.EyePosition - vd * 5 + new Vector3(0, 1, 0);
                cam.ViewDirection = vd;
                cam.UpdateMatrices();
            }
        }
        void ITMPlugin.Update(ITMPlayer player)
        {
            if (boat != null)
            {
                boat.Position      = player.Position;
                boat.Position     += player.EyeOffset;
                boat.ViewDirection = player.ViewDirection;
                boat.DrawRotY      = MathHelper.PiOver2;
                boat.DrawOffY      = -3.5f;

                if ((frame % 4) == 0 && player.Velocity.Length() > 0.2f)
                {
                    int i = dustCounter++;
                    if (dustCounter >= dust.Length)
                    {
                        dustCounter = 0;
                    }
                    Vector3 pos = boat.Position + player.ViewDirection * 35f;
                    pos.X           += (float)(game.Random.NextDouble() * 40 - 20);
                    pos.Y           += (float)(game.Random.NextDouble() * 40 - 20);
                    pos.Z           += (float)(game.Random.NextDouble() * 40 - 20);
                    dust[i].Position = pos;
                    game.World.AddParticle(pos, ref particleData);
                }
            }
            ++frame;
        }
        void ITMPlugin.PlayerJoined(ITMPlayer player)
        {
            var b = new Entity();

            if (game.World.EntityManager.AddEntity("entities", "spaceshipcockpit", b) == ErrorCode.Success)
            {
                boat = b;
            }

            particleData = new ParticleData()
            {
                Duration   = 8,
                StartColor = Color.White,
                EndColor   = Color.White,
                Size       = new Vector4(0.1f, 0.1f, 0.1f, 1f),
                WindFactor = 0,
            };

            particleData.Size       = new Vector4(1f, 1f, 1f, 1f);
            particleData.StartColor = particleData.EndColor = Color.Red;

            dust = new Entity[100];
            for (int i = 0; i < dust.Length; ++i)
            {
                var d = new Entity()
                {
                    Scale = (float)(game.Random.NextDouble() * 0.1 + 0.05), Position = new Vector3(1, 1000, 1)
                };
                dust[i]         = d;
                d.ViewDirection = Vector3.Forward;
                game.World.EntityManager.AddEntity("space", "dust", d);
                //game.World.EntityManager.AddEntity("entities", "spaceshipcockpit", d);
            }
        }
Beispiel #7
0
        void DecreaseHandItemDurability(ITMHand hand, ushort amt)
        {
            ITMPlayer player = hand.Player;

            var item = player.Inventory.Items[player.LeftHand.HandIndex];

            if (hand.HandType == InventoryHand.Right)
            {
                item = player.Inventory.Items[player.RightHand.HandIndex];
            }


            if (amt >= item.Durability)
            {
                //game.AddNotification("Amount " + amt + " >= item.durability " + item.Durability );
                amt = (ushort)(item.Durability - 1);
                //game.AddNotification("setting to " + amt );
            }

            item.Durability -= amt;
            // game.AddNotification("durability " + item.Durability + " amount " + amt);

            if (hand.HandType == InventoryHand.Right)
            {
                player.Inventory.Items[player.RightHand.HandIndex] = item;
            }
            else
            {
                player.Inventory.Items[player.LeftHand.HandIndex] = item;
            }
        }
 public void Update(ITMPlayer player)
 {
     if (consoleWin == null && InputManager.IsKeyReleasedNew(player.PlayerIndex, Microsoft.Xna.Framework.Input.Keys.Home))
     {
         consoleWin        = new DataField("Chat box: ", 10, 10, 400, 300, 0.5f);
         consoleWin.Colors = Colors.DataFieldColors;
         Game.WindowManager.Root.AddChild(consoleWin);
     }
 }
        void ITMPlugin.Update(ITMPlayer player)
        {
            if (shouldPaste)
            {
                player.PasteCurrentClipboard(pastePoint, pasteFacing);
                shouldPaste = false;
            }

            ++frame;
        }
        NewGuiMenu ITMPluginGUI.GetItemCustomSetupScreen(ITMGame game, ITMPlayer player, GlobalPoint3D p, Item itemID)
        {
            switch (itemID)
            {
            case Item.Rasta:
                return(new VehicleSetupScreen(game, player, p));

            default:
                return(null);
            }
        }
Beispiel #11
0
        public int GetMaxSetCount(ITMPlayer player)
        {
            List <int> itemCounts = new List <int>();

            foreach (InventoryItem item in this.GetItems())
            {
                itemCounts.Add((int)Math.Floor((double)player.Inventory.ItemCount(item.ItemID) / item.Count));
            }

            return(itemCounts.Min());
        }
Beispiel #12
0
 public void ConvertToSets(ITMPlayer player, int setCount)
 {
     if (this.GetMaxSetCount(player) >= setCount)
     {
         for (int i = 0; i < setCount; i++)
         {
             ConsumeItems(player);
             GiveSet(player);
         }
     }
 }
Beispiel #13
0
 public SimpleScreen(INewGuiMenuScreen screen, ITMGame game, ITMPlayer player)
     : base(screen, game, player)
 {
     if (data.TextBox == null)
     {
         // one time initialization of static data
         data.TextBox     = "Some Text";
         data.DataField   = "Edit Me";
         data.SliderValue = 0.5f;
     }
 }
Beispiel #14
0
 public void ConvertToItems(ITMPlayer player, int setCount)
 {
     Logger.Log($"Converting {this.GetSetItem()} to items ({player.Inventory.ItemCount(this.GetSetItem())}");
     if (player.Inventory.ItemCount(this.GetSetItem()) >= setCount)
     {
         for (int i = 0; i < setCount; i++)
         {
             ConsumeSet(player);
             GiveItems(player);
         }
     }
 }
Beispiel #15
0
        ushort GetRemainHandDurability(ITMHand hand)
        {
            ITMPlayer player = hand.Player;

            var item = player.Inventory.Items[player.LeftHand.HandIndex];

            if (hand.HandType == InventoryHand.Right)
            {
                item = player.Inventory.Items[player.RightHand.HandIndex];
            }

            return(item.Durability);
        }
Beispiel #16
0
 public bool HandleInput(ITMPlayer player)
 {
     //bool qPressed = InputManager.IsKeyPressed(PlayerIndex.One, Keys.Q);
     if (InputManager.IsKeyPressed(player.PlayerIndex, toggleKey))
     {
         keyDown = true;
     }
     else
     {
         keyDown = false;
     }
     //handle special mod input keys
     return(false);
 }
Beispiel #17
0
        public void Update(ITMPlayer player)
        {
            var blockID = (Block)game.World.Map.GetBlockID(player.SwingTarget);

            if (blockID != lastBlockID)
            {
                lastBlockID = blockID;
                if (blockID == Block.ColorBlack)
                {
                    var menuScreen = game.OpenPauseMenu(player);
                    var screen     = new SimpleScreen(menuScreen, game, player);
                    menuScreen.PushOtherTab(screen);
                }
            }
        }
Beispiel #18
0
        public void Update(ITMPlayer player)
        {
            var playerData = player.Tag as PlayerData;

            if (playerData.LockPickState > LockPickStatus.None)
            {
                switch (playerData.LockPickState)
                {
                case LockPickStatus.Picking:
                    game.AddNotification("Lockpicking..", NotifyRecipient.Local);
                    PlayRandSound();
                    playerData.LockPickTimer.Start(1);
                    ++playerData.LockPickState;
                    break;

                case LockPickStatus.Delay:
                    playerData.LockPickTimer.Update();
                    if (playerData.LockPickTimer.IsComplete)
                    {
                        if (game.Random.Next(8) == 0)
                        {
                            playerData.LockPickState = LockPickStatus.PickBroke;
                        }
                        else
                        {
                            playerData.LockPickState =
                                (++playerData.PickAttemptsCount >= playerData.PickAttemptsRequired)
                                        ? LockPickStatus.Finish : LockPickStatus.Picking;
                        }
                    }
                    break;

                case LockPickStatus.PickBroke:
                    game.AddNotification("Your lockpick has broken!", NotifyRecipient.Local);
                    PlaySound(3);
                    player.Inventory.DecrementItem(Items.Lockpick, 1);
                    playerData.LockPickState = LockPickStatus.None;
                    break;

                case LockPickStatus.Finish:
                    world.SetPower(playerData.LockPickDoorPos, true, player);
                    map.Commit();
                    playerData.LockPickState = LockPickStatus.None;
                    break;
                }
            }
        }
 public bool HandleInput(ITMPlayer player)
 {
     if (InputManager.IsKeyReleasedNew(player.PlayerIndex, Keys.K))
     {
         if (cam == null)
         {
             cam = player.CreateCamera(player);
         }
         else
         {
             player.RemoveCamera(player, cam);
             cam = null;
         }
         return(true);
     }
     return(false);
 }
Beispiel #20
0
        void UpdateSpawnPoints(ITMPlayer player)
        {
            float d1 = 30 * 30;
            float d2 = 1000 * 1000;
            Spawn s;

            for (int i = 0; i < spawnPoints.Count; ++i)
            {
                s = spawnPoints[i];
                if (s.Timer < Services.TotalTime)
                {
                    s.Timer        = Services.TotalTime + 5;
                    spawnPoints[i] = s;
                    float d = Vector3.DistanceSquared(s.Pos, player.EyePosition);
                    if (d >= d1 && d < d2)
                    {
                        SpawnCar(s.Pos, s.Dir);
                    }
                }
            }
        }
        public void Update(ITMPlayer player)
        {
            particleElapsed += Services.ElapsedTime;
            if (particleElapsed > 1)
            {
                //var data = new ParticleData()
                //{
                //    Duration = 8000,
                //    Gravity = 1,
                //    Size = new Vector4(0.2f, 0.2f, 0.2f, 1f),
                //    StartColor = Color.White,
                //    EndColor = Color.White,
                //    VelocityType = ScriptCoordType.Absolute,
                //    Velocity = player.ViewDirection * 10
                //};
                //game.AddParticle(player.EyePosition, ref data);
                particleElapsed = 0;
            }

            if (InputManager.IsKeyReleasedNew(player.PlayerIndex, Keys.K))
            {
                if (cam == null)
                {
                    cam = player.CreateCamera(player);
                }
                else
                {
                    player.RemoveCamera(player, cam);
                    cam = null;
                }
            }

            if (cam != null)
            {
                var vd = Vector3.Normalize(new Vector3(player.ViewDirection.X, 0, player.ViewDirection.Z));
                cam.Position      = player.EyePosition - vd * 5 + new Vector3(0, 1, 0);
                cam.ViewDirection = vd;
                cam.UpdateMatrices();
            }
        }
 public VehicleSetupScreen(ITMGame game, ITMPlayer player, GlobalPoint3D p)
     : base(game, player)
 {
     point = p;
 }
Beispiel #23
0
 public void Draw(ITMPlayer player, ITMPlayer virtualPlayer)
 {
 }
Beispiel #24
0
 public void Update(ITMPlayer player)
 {
 }
Beispiel #25
0
 public bool HandleInput(ITMPlayer player)
 {
     return(false);
 }
Beispiel #26
0
 public void PlayerLeft(ITMPlayer player)
 {
 }
Beispiel #27
0
 public void PlayerJoined(ITMPlayer player)
 {
 }
 void ITMPlugin.PlayerLeft(ITMPlayer player)
 {
 }
 void ITMPlugin.PlayerJoined(ITMPlayer player)
 {
 }
 public void Draw(ITMPlayer player, ITMPlayer virtualPlayer)
 {
     //CoreGlobals.SpriteBatch.Begin();
     //CoreGlobals.SpriteBatch.DrawString(CoreGlobals.GameFont, "Hello", new Vector2(100, 100), Color.White);
     //CoreGlobals.SpriteBatch.End();
 }