Ejemplo n.º 1
0
        private void GameEvents_UpdateTick(object s, EventArgs e)
        {
            EnforceSerializer();
            if (!Context.IsWorldReady)
            {
                return;
            }
            if ((Game1.player.CurrentItem == null && this.prevItem != null) || (Game1.player.CurrentItem != null && !Game1.player.CurrentItem.Equals(this.prevItem)))
            {
                ItemEvents.FireActiveItemChanged(new EventArgsActiveItemChanged(this.prevItem, Game1.player.CurrentItem));
                this.prevItem = Game1.player.CurrentItem;
            }
            PlayerModifierHelper._UpdateModifiers();
            Vector2 playerPos = new Vector2(Game1.player.getStandingX() / Game1.tileSize, Game1.player.getStandingY() / Game1.tileSize);

            if (LastTouchAction == playerPos)
            {
                return;
            }
            string text = Game1.currentLocation.doesTileHaveProperty((int)playerPos.X, (int)playerPos.Y, "TouchAction", "Back");

            LastTouchAction = playerPos;
            if (text == null)
            {
                return;
            }
            string[] split = (text).Split(' ');
            string[] args  = new string[split.Length - 1];
            Array.Copy(split, 1, args, 0, args.Length);
            this.ActionInfo = new EventArgsActionTriggered(Game1.player, split[0], args, playerPos);
            MoreEvents.FireTouchActionTriggered(this.ActionInfo);
        }
Ejemplo n.º 2
0
        /// <summary>Raised after the game state is updated (≈60 times per second).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
        {
            this.EnforceSerializer();
            if (!Context.IsWorldReady)
            {
                return;
            }
            if (Game1.player.CurrentItem == null && this.PrevItem != null || Game1.player.CurrentItem != null && !Game1.player.CurrentItem.Equals(this.PrevItem))
            {
                ItemEvents.FireActiveItemChanged(new EventArgsActiveItemChanged(this.PrevItem, Game1.player.CurrentItem));
                this.PrevItem = Game1.player.CurrentItem;
            }

            IModHelperExtensions.PlayerModifierHelper.UpdateTick();
            if (Context.IsPlayerFree)
            {
                Vector2 playerPos = new Vector2(Game1.player.getStandingX() / Game1.tileSize, Game1.player.getStandingY() / Game1.tileSize);
                if (EntoaroxFrameworkMod.LastTouchAction != playerPos)
                {
                    string text = Game1.currentLocation.doesTileHaveProperty((int)playerPos.X, (int)playerPos.Y, "TouchAction", "Back");
                    EntoaroxFrameworkMod.LastTouchAction = playerPos;
                    if (text != null)
                    {
                        string[] split = text.Split(' ');
                        string[] args  = new string[split.Length - 1];
                        Array.Copy(split, 1, args, 0, args.Length);
                        this.ActionInfo = new EventArgsActionTriggered(Game1.player, split[0], args, playerPos);
                        MoreEvents.FireTouchActionTriggered(this.ActionInfo);
                    }
                }
            }
        }