Beispiel #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);
        }
Beispiel #2
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);
        }
Beispiel #3
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"
            });
        }
Beispiel #4
0
 public void ToolUse()
 {
     GodHand.Use(this);
     OnUse(EntityUseEventArgs.FromState(this));
 }