Exemplo n.º 1
0
        /// <summary>
        /// Calls tool use and fires use event from current entity state
        /// </summary>
        public IToolImpact ToolUse(ITool tool)
        {
            var arg = EntityUseEventArgs.FromState(this);

            arg.Tool = tool;


            if (tool != null)
            {
                using (new PerfLimit("Tool use logic " + tool.Name))
                    arg.Impact = tool.Use(this);
            }
            else
            {
                arg.Impact = new ToolImpact {
                    Message = "Null tool"
                };
            }

            OnUse(arg);

            if (ModelInstance != null)
            {
                ModelInstance.TryPlay("Use");
            }

            return(arg.Impact);
        }
Exemplo n.º 2
0
 public EntityUseMessage(EntityUseEventArgs e)
 {
     State           = e.State;
     DynamicEntityId = e.Entity.DynamicId;
     ToolId          = e.Tool == null ? 0 : e.Tool.StaticId;
     UseType         = e.UseType;
     RecipeIndex     = e.RecipeIndex;
 }
Exemplo n.º 3
0
        protected virtual void OnUse(EntityUseEventArgs e)
        {
            var handler = Use;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        //OUT Going Server Data concering current player =================================================================
        //These are player event subscribing
        private void PlayerEntityUse(object sender, EntityUseEventArgs e)
        {
            var useMessage = new EntityUseMessage(e)
            {
                Token = ++_useToken
            };

            _syncManager.RegisterUseMessage(useMessage, e.Impact);
            _server.ServerConnection.Send(useMessage);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Fires entity use event for the craft operation
        /// </summary>
        /// <param name="recipeIndex"></param>
        public IToolImpact CraftUse(int recipeIndex)
        {
            var args = EntityUseEventArgs.FromState(this);

            args.UseType     = UseType.Craft;
            args.RecipeIndex = recipeIndex;
            args.Impact      = Craft(recipeIndex);
            OnUse(args);

            return(args.Impact);
        }
Exemplo n.º 6
0
        public IToolImpact PutUse()
        {
            if (Equipment.RightTool != null)
            {
                var args = EntityUseEventArgs.FromState(this);
                args.Tool    = Equipment.RightTool;
                args.UseType = UseType.Put;
                args.Impact  = Equipment.RightTool.Put(this);

                OnUse(args);

                return(args.Impact);
            }
            return(new ToolImpact {
                Message = "RightTool is null"
            });
        }
Exemplo n.º 7
0
 public void ToolUse()
 {
     GodHand.Use(this);
     OnUse(EntityUseEventArgs.FromState(this));
 }