Exemplo n.º 1
0
 public void OnInteraction( Tool tool )
 {
     if( tool.GetType() == typeof(HandTool) )
     {
         Talk( tool.transform.root.gameObject );
     }
 }
    void ChangeTool( GameObject obj )
    {
        if( null == obj )
        {
            Debug.Log( "Cannot change tool to null object" );
            return;
        }

        if( obj == m_EquippedTool )
        {
            Debug.Log( "Cannot change to tool - this tool is currently equipped" );
            return;
        }

        Tool nextTool = GetToolScript( obj );
        if( null == nextTool )
        {
            Debug.Log( "Cannot locate tool script on object" );
            return;
        }

        m_PreviousTool = m_EquippedTool;
        m_PreviousToolScript = m_EquippedToolScript;
        m_EquippedTool = obj;
        m_EquippedToolScript = nextTool;

        m_EquippedToolScript.Attach();

        if( m_PreviousToolScript )
            m_PreviousToolScript.Detach();
    }
Exemplo n.º 3
0
    //Tool manipulation is a way to prevent the transform handles from appearing
    void OnEnable()
    {
        generatedMesh = target as MeshGen2D;

        lastTool = Tools.current;
        Tools.current = Tool.None;
    }
Exemplo n.º 4
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string name = null;
            GH_Plane tcp = null;
            double weight = 0;
            GH_Mesh mesh = null;
            GH_Point centroid = null;
            List<GH_Plane> planes = new List<GH_Plane>();

            if (!DA.GetData(0, ref name)) { return; }
            if (!DA.GetData(1, ref tcp)) { return; }
            DA.GetDataList(2, planes);
            if (!DA.GetData(3, ref weight)) { return; }
            DA.GetData(4, ref centroid);
            DA.GetData(5, ref mesh);

            var tool = new Tool(tcp.Value, name, weight, centroid?.Value, mesh?.Value);

            if (planes.Count > 0)
            {
                if (planes.Count != 4)
                    this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, " Calibration input must be 4 planes");
                else
                    tool.FourPointCalibration(planes[0].Value, planes[1].Value, planes[2].Value, planes[3].Value);
            }

            DA.SetData(0, new GH_Tool(tool));
            DA.SetData(1, tool.Tcp);
        }
Exemplo n.º 5
0
 public override void OnInteraction(Tool tool)
 {
     if (tool is Hand)
     {
         numpad.OnNumPadButtonPressed(number);
     }
 }
 public PanTool(Level pointer, Tool prevTool, Point startPoint)
     : base(pointer)
 {
     this.pointer = pointer;
     this.prevTool = prevTool;
     this.startPoint = startPoint;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Converts a Semmle log file in CSV format to a SARIF log file.
        /// </summary>
        /// <param name="input">
        /// Input stream from which to read the Semmle log.
        /// </param>
        /// <param name="output">
        /// Output string to which to write the SARIF log.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when one or more required arguments are null.
        /// </exception>
        public override void Convert(Stream input, IResultLogWriter output)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            _toolNotifications = new List<Notification>();

            var results = GetResultsFromStream(input);

            var tool = new Tool
            {
                Name = "Semmle"
            };

            output.Initialize(id: null, correlationId: null);

            output.WriteTool(tool);

            output.OpenResults();
            output.WriteResults(results);
            output.CloseResults();

            if (_toolNotifications.Any())
            {
                output.WriteToolNotifications(_toolNotifications);
            }
        }
Exemplo n.º 8
0
        public string HashPassword(Tool tor, string password)
        {
            var process = new Process
            {
                StartInfo =
                {
                    FileName = tor.ExecutablePath,
                    Arguments = $"--hash-password {password}",
                    RedirectStandardOutput = true,
                    UseShellExecute = false
                }
            };

            var sb = new StringBuilder();
            process.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);

            process.Start();
            process.BeginOutputReadLine();
            process.WaitForExit();

            return sb
                .ToString()
                .Split('\n')
                .Select(l => l.Trim())
                .Last(l => l.Length > 0);
        }
        /// <summary>
        /// Interface implementation that takes a Static Driver Verifier log stream and converts
        ///  its data to a SARIF json stream. Read in Static Driver Verifier data from an input
        ///  stream and write Result objects.
        /// </summary>
        /// <param name="input">Stream of a Static Driver Verifier log</param>
        /// <param name="output">SARIF json stream of the converted Static Driver Verifier log</param>
        public override void Convert(Stream input, IResultLogWriter output)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            Result result = ProcessSdvDefectStream(input);
            var results = new Result[] { result };

            var tool = new Tool
            {
                Name = "StaticDriverVerifier",
            };

            var fileInfoFactory = new FileInfoFactory(null);
            Dictionary<string, FileData> fileDictionary = fileInfoFactory.Create(results);

            output.Initialize(id: null, correlationId: null);

            output.WriteTool(tool);
            if (fileDictionary != null && fileDictionary.Count > 0) { output.WriteFiles(fileDictionary); }

            output.OpenResults();
            output.WriteResults(results);
            output.CloseResults();
        }
Exemplo n.º 10
0
	/// <summary>
	/// Sets the tool to block with a specific block
	/// </summary>
	/// <param name="name">Name of block</param>
	public void SetToolBlock(string name) {
		tool = Tool.Block;
		BlockCursor.SetBlock(new Block[,,] { { { BlockManager.GetBlock(name) } } });
		BlockCursor.offset = Vector3.zero;

		VRCursor.SetBlock(new Block[,,] { { { BlockManager.GetBlock(name) } } });
	}
	void OnEnable() {
		if (paintButTexOn==null) paintButTexOn=AssetDatabase.LoadAssetAtPath("Assets/ReliefPack/Editor/ReliefTerrain/icons/icoPaintOn.png", typeof(Texture)) as Texture;
		if (paintButTexOff==null) paintButTexOff=AssetDatabase.LoadAssetAtPath("Assets/ReliefPack/Editor/ReliefTerrain/icons/icoPaintOff.png", typeof(Texture)) as Texture;
		
		prev_tool=UnityEditor.Tools.current;
		
		GeometryVsTerrainBlend _target=(GeometryVsTerrainBlend)target;
		if (_target.orig_mesh==null) {
			MeshFilter mf=_target.GetComponent(typeof(MeshFilter)) as MeshFilter;
			//if (AssetDatabase.GetAssetPath(mf.sharedMesh)!="") {
				_target.orig_mesh = mf.sharedMesh;	
			//}
		}
		if (!_target.blendedObject) {
			MeshFilter mf=_target.GetComponent(typeof(MeshFilter)) as MeshFilter;
		  	RaycastHit[] hits;
			hits=Physics.RaycastAll(_target.transform.position+_target.transform.up*20, -_target.transform.up, 100);
			int o;
			for(o=0; o<hits.Length; o++) {
				bool  ReliefTerrainBlended=hits[o].collider.gameObject.GetComponent(typeof(ReliefTerrain))!=null;
				bool  VoxelTerrainBlended=hits[o].collider.gameObject.GetComponent(typeof(ReliefTerrainVertexBlendTriplanar))!=null;
				if (ReliefTerrainBlended || VoxelTerrainBlended) {
					_target.VoxelBlendedObject=VoxelTerrainBlended;
					_target.blendedObject=hits[o].collider.gameObject;
					CheckShaderForBlendCapability();
					_target.MakeMeshCopy();
					_target.pmesh=mf.sharedMesh;
					EditorUtility.SetDirty(target);
					SceneView.RepaintAll();
					break;
				}
			}
		}		
	}
Exemplo n.º 12
0
 public override void OnInteraction(Tool tool)
 {
     if (tool is Hand)
     {
         rgbMachine.OnRGBButtonPressed(rgbValue);
     }
 }
Exemplo n.º 13
0
        public void Init()
        {
            player1Observer = new MockObserver("Player1 Observer");
            fullPlayerObserver = new MockObserver("FullPlayer Observer");
            player1InventoryObserver = new MockObserver("Player 1 Inventory Observer");
            fullPlayerInventoryObserver = new MockObserver("FullPlayer Inventory Observer");

            player1 = new Player ("Player1", Gender.FEMALE, "Eve2", new Vector2 (0, 0));
            player1.AddObserver(player1Observer);

            fullPlayer = new Player ("Ollie", Gender.MALE, "Evan1", Vector2.zero);
            fullPlayer.InitialiseInventory (20);
            fullPlayer.AddObserver(fullPlayerObserver);
            fullPlayer.Inventory.AddObserver(fullPlayerInventoryObserver);

            for (int i = 0; i < 20; i++) {
                InventoryItem item = new InventoryItem();
                item.ItemName = "Item" + i;
                item.ItemId = i;
                item.ItemType = ItemType.RUBBISH;
                item.ItemDescription = string.Empty;
                fullPlayer.AddItem(item);
            }

            tool1 = new MockTool("Tool1");
            tool2 = new MockTool("Tool2");
            tool3 = new MockTool("Tool3");

            fullPlayer.AddTool(tool1);
            fullPlayer.AddTool(tool2);
            fullPlayer.AddTool(tool3);
        }
 /// <summary>
 /// Returns true if this adorner provider supports the tool passed in.
 /// By default this returns true for SelectionTool.
 /// </summary>
 /// <param name="tool">Tool to be checked.</param>
 /// <returns>true if the tool passed in is supported.</returns>
 public override bool IsToolSupported(Tool tool)
 {
     if (tool is SelectionTool || tool is CreationTool)
     {
         return true;
     }
     return false;
 }
Exemplo n.º 15
0
    void OnInteraction( Tool tool )
    {
        Console.Instance.addGameChatMessage( "Saving..." );

        if( tool.GetType() == typeof( HandTool ) )
        {
        }
    }
Exemplo n.º 16
0
		private void ResetToolSelection( Tool tool ) {
			if( tool != Tool.Select )
				ChkArrow.Checked = false;
			if( tool != Tool.Fill )
				ChkFill.Checked = false;
			if( tool != Tool.Unfill )
				ChkBordering.Checked = false;
		}
Exemplo n.º 17
0
        public ToolTab(Tool tool, AnchorStyles anchor, Orientation orientation)
        {
            if(tool == null) throw new ArgumentNullException("tool");

            _tool = tool;
            _anchor = anchor;
            _orientation = orientation;
        }
Exemplo n.º 18
0
 public override void OnInteraction(Tool tool)
 {
     if (tool is ScrewDriver)
     {
         this.Defuse();
         StartCoroutine(RemoveScrew());
     }
 }
    public void CollectMaterial(CollectionMethod method, Tool tool)
    {
        var parameter = new Dictionary<byte, object> {
                             { (byte)CollectMaterialParameterItem.CollectiontMethod, method},
                             { (byte)CollectMaterialParameterItem.ToolID, (tool == null) ? ItemID.No : tool.id}
                        };

        peer.OpCustom((byte)OperationType.CollectMaterial, parameter, true, 0, true);
    }
Exemplo n.º 20
0
 public override void OnInteraction(Tool tool)
 {
     if ( tool is Hand)
     {
         this.Defuse();
         StartCoroutine(MoveLever());
         switchInner.SetLeverState(this.gameObject.name, leverUp);
     }
 }
Exemplo n.º 21
0
 public override void OnInteraction(Tool tool)
 {
     if ( tool is Hammer)
     {
         tool.Use();
         Debug.Log("Safe Hammer hit");
         safeRigidBody.AddExplosionForce(1000f, transform.position, 10f);
     }
 }
Exemplo n.º 22
0
 public override void OnInteraction(Tool tool)
 {
     if (tool is Hand)
     {
         lightState = !lightState;
         StartCoroutine(SwitchOnOff(lightState, switchInterval));
         hint.SendMessage("Solve");
     }
 }
Exemplo n.º 23
0
    public void NewItem(Transform item)
    {
        selectedItem = Instantiate(item);

        selectedItem.parent = target;
        selectedItem.localPosition = Vector3.zero;
        selectedItem.localRotation = Quaternion.identity;

        activeTool = Tool.None;
    }
Exemplo n.º 24
0
	void OnEnable () {
		spline = target as PlaygroundSpline;

		playgroundSettings = PlaygroundSettingsC.GetReference();
		playgroundLanguage = PlaygroundSettingsC.GetLanguage();

		lastActiveTool = Tools.current;

		UpdateUserList();
	}
Exemplo n.º 25
0
 public override void OnInteraction(Tool tool)
 {
     if (tool is Plier)
     {
         this.Defuse();
         tool.Use();
         this.SetCut(true);
         this.CallWireMachineCallback();
     }
 }
Exemplo n.º 26
0
 public void SelectedToolStateChanged(Tool selectedTool, bool isUnsheathed)
 {
     _currentToolTransitions = transitions
         .Where(transition => {
             if(selectedTool == null || !isUnsheathed)
                 return transition.requiredToolId.Length == 0;
             else return transition.requiredToolId == selectedTool.itemNameID;
         })
         .ToList();
 }
Exemplo n.º 27
0
    public void ObtainTool(Tool toolOnWorld)
    {
        Tool playerTool = GetPlayerTool(toolOnWorld);

        tools.Add(playerTool);

        CurrentTool.gameObject.SetActive(false);
        playerTool.gameObject.SetActive(true);

        CurrentToolIndex = tools.Count - 1;
    }
Exemplo n.º 28
0
	// Update is called once per frame
	void Update () {
		Frame frame = controller.Frame ();
		tool = frame.Tools.Frontmost;

		if (tool != Tool.Invalid) {
			Debug.Log ("ADA"+i);
		} else {
			Debug.Log("Nope");
		}
		i++;
	}
Exemplo n.º 29
0
        /// <summary>
        /// инструмент
        /// </summary>
        /// <param name="_tool">инструмент</param>
        /// <param name="_absPath">абсолютный путь до файла с перечнем инструментов</param>
        /// <exception cref="ArgumentNullException"></exception>
        public ToolModel(Tool _tool,string _absPath)
        {
            if (_tool == null || string.IsNullOrEmpty(_absPath))
                throw new ArgumentNullException("Нулевой инструмент в конструкторе ToolModel");

            tool = _tool;
            Id = _tool.id;
            Name = _tool.iname;
            Marking = _tool.obozn;
            AbsOrigPath = System.IO.Path.Combine(_absPath.AsPath(), _tool.ipic);
        }
Exemplo n.º 30
0
        void OnEnable()
        {
            transform = (target as Folder).transform;
            folderColor = serializedObject.FindProperty("_folderColor");
            drawMode = serializedObject.FindProperty("drawMode");
            labelDrawMode = serializedObject.FindProperty("labelDrawMode");
            allowBrokenPath = serializedObject.FindProperty("allowBrokenPath");

            lastTool = Tools.current;
            Tools.current = Tool.None;
        }
Exemplo n.º 31
0
        /// <summary>Get the attachments which are ready and can be applied to the given tile, after applying cooldown.</summary>
        /// <param name="player">The current player.</param>
        /// <param name="tool">The tool selected by the player (if any).</param>
        /// <param name="item">The item selected by the player (if any).</param>
        /// <param name="location">The current location.</param>
        private IEnumerable <IAttachment> GetApplicableAttachmentsAfterCooldown(SFarmer player, Tool tool, Item item, GameLocation location)
        {
            foreach (IAttachment attachment in this.Attachments)
            {
                // run cooldown
                if (attachment.RateLimit > this.TicksPerAction)
                {
                    int cooldown = this.AttachmentCooldowns[attachment];
                    if (cooldown > this.TicksPerAction)
                    {
                        this.AttachmentCooldowns[attachment] -= this.TicksPerAction;
                        continue;
                    }
                }

                // yield attachment
                if (attachment.IsEnabled(player, tool, item, location))
                {
                    yield return(attachment);
                }
            }
        }
Exemplo n.º 32
0
 public override bool combine(Tool other)
 {
     return(false);
 }
Exemplo n.º 33
0
        public static bool AnimalHouseToolActionExecutor(ref AnimalHouse __instance, ref Tool t, ref int tileX, ref int tileY)
        {
            GameLocation gameLocation = Game1.currentLocation;

            if (t.BaseName != "Watering Can" || ((WateringCan)t).WaterLeft <= 0)
            {
                return(false);
            }

            if (Game1.currentLocation.Name.ToLower().Contains("coop") && !ModData.CoopsWithWateredTrough.Contains(__instance.NameOrUniqueName.ToLower()))
            {
                Type buildingType = typeof(Coop);

                if (__instance.getBuilding().nameOfIndoorsWithoutUnique.ToLower() == "coop")
                {
                    foreach (TroughTile troughTile in ModEntry.Instance.CurrentTroughPlacementProfile.coopTroughTiles)
                    {
                        if (troughTile.TileX != tileX || troughTile.TileY != tileY)
                        {
                            continue;
                        }

                        ModEntry.Instance.SendTroughWateredMessage(buildingType, __instance.NameOrUniqueName.ToLower());

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.coopTroughTiles)
                        {
                            gameLocation.removeTile(tile.TileX, tile.TileY, tile.Layer);
                        }

                        Layer     buildingsLayer = gameLocation.Map.GetLayer("Buildings");
                        Layer     frontLayer     = gameLocation.Map.GetLayer("Front");
                        TileSheet tilesheet      = gameLocation.Map.GetTileSheet("z_waterTroughTilesheet");

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.coopTroughTiles)
                        {
                            if (tile.Layer.Equals("Buildings"))
                            {
                                buildingsLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(buildingsLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                            else if (tile.Layer.Equals("Front"))
                            {
                                frontLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(frontLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                        }

                        ModData.CoopsWithWateredTrough.Add(__instance.NameOrUniqueName.ToLower());
                        ModEntry.Instance.ChangeCoopTexture(__instance.getBuilding(), false);

                        foreach (FarmAnimal animal in __instance.animals.Values)
                        {
                            if (ModEntry.Instance.Config.ShowLoveBubblesOverAnimalsWhenWateredTrough)
                            {
                                animal.doEmote(ModData.LoveEmote);
                            }
                            animal.friendshipTowardFarmer.Value += Math.Abs(ModEntry.Instance.Config.AdditionalFriendshipPointsForWateredTroughWithAnimalsInsideBuilding);
                        }
                    }
                }
                else if (__instance.getBuilding().nameOfIndoorsWithoutUnique.ToLower() == "coop2")
                {
                    foreach (TroughTile troughTile in ModEntry.Instance.CurrentTroughPlacementProfile.coop2TroughTiles)
                    {
                        if (troughTile.TileX != tileX || troughTile.TileY != tileY)
                        {
                            continue;
                        }

                        ModEntry.Instance.SendTroughWateredMessage(buildingType, __instance.NameOrUniqueName.ToLower());

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.coop2TroughTiles)
                        {
                            gameLocation.removeTile(tile.TileX, tile.TileY, tile.Layer);
                        }

                        Layer     buildingsLayer = gameLocation.Map.GetLayer("Buildings");
                        Layer     frontLayer     = gameLocation.Map.GetLayer("Front");
                        TileSheet tilesheet      = gameLocation.Map.GetTileSheet("z_waterTroughTilesheet");

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.coop2TroughTiles)
                        {
                            if (tile.Layer.Equals("Buildings"))
                            {
                                buildingsLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(buildingsLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                            else if (tile.Layer.Equals("Front"))
                            {
                                frontLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(frontLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                        }

                        ModData.CoopsWithWateredTrough.Add(__instance.NameOrUniqueName.ToLower());
                        ModEntry.Instance.ChangeBigCoopTexture(__instance.getBuilding(), false);

                        foreach (FarmAnimal animal in __instance.animals.Values)
                        {
                            if (ModEntry.Instance.Config.ShowLoveBubblesOverAnimalsWhenWateredTrough)
                            {
                                animal.doEmote(ModData.LoveEmote);
                            }
                            animal.friendshipTowardFarmer.Value += Math.Abs(ModEntry.Instance.Config.AdditionalFriendshipPointsForWateredTroughWithAnimalsInsideBuilding);
                        }
                    }
                }
                else if (__instance.getBuilding().nameOfIndoorsWithoutUnique.ToLower() == "coop3")
                {
                    foreach (TroughTile troughTile in ModEntry.Instance.CurrentTroughPlacementProfile.coop3TroughTiles)
                    {
                        if (troughTile.TileX != tileX || troughTile.TileY != tileY)
                        {
                            continue;
                        }

                        ModEntry.Instance.SendTroughWateredMessage(buildingType, __instance.NameOrUniqueName.ToLower());

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.coop3TroughTiles)
                        {
                            gameLocation.removeTile(tile.TileX, tile.TileY, tile.Layer);
                        }

                        Layer     buildingsLayer = gameLocation.Map.GetLayer("Buildings");
                        Layer     frontLayer     = gameLocation.Map.GetLayer("Front");
                        TileSheet tilesheet      = gameLocation.Map.GetTileSheet("z_waterTroughTilesheet");

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.coop3TroughTiles)
                        {
                            if (tile.Layer.Equals("Buildings"))
                            {
                                buildingsLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(buildingsLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                            else if (tile.Layer.Equals("Front"))
                            {
                                frontLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(frontLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                        }

                        ModData.CoopsWithWateredTrough.Add(__instance.NameOrUniqueName.ToLower());

                        foreach (FarmAnimal animal in __instance.animals.Values)
                        {
                            if (ModEntry.Instance.Config.ShowLoveBubblesOverAnimalsWhenWateredTrough)
                            {
                                animal.doEmote(ModData.LoveEmote);
                            }
                            animal.friendshipTowardFarmer.Value += Math.Abs(ModEntry.Instance.Config.AdditionalFriendshipPointsForWateredTroughWithAnimalsInsideBuilding);
                        }
                    }
                }
            }
            else if (Game1.currentLocation.Name.ToLower().Contains("barn") && !ModData.BarnsWithWateredTrough.Contains(__instance.NameOrUniqueName.ToLower()))
            {
                Type buildingType = typeof(Barn);

                if (__instance.getBuilding().nameOfIndoorsWithoutUnique.ToLower() == "barn")
                {
                    foreach (TroughTile troughTile in ModEntry.Instance.CurrentTroughPlacementProfile.barnTroughTiles)
                    {
                        if (troughTile.TileX != tileX || troughTile.TileY != tileY)
                        {
                            continue;
                        }

                        ModEntry.Instance.SendTroughWateredMessage(buildingType, __instance.NameOrUniqueName.ToLower());

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.barnTroughTiles)
                        {
                            gameLocation.removeTile(tile.TileX, tile.TileY, tile.Layer);
                        }

                        Layer     buildingsLayer = gameLocation.Map.GetLayer("Buildings");
                        Layer     frontLayer     = gameLocation.Map.GetLayer("Front");
                        TileSheet tilesheet      = gameLocation.Map.GetTileSheet("z_waterTroughTilesheet");

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.barnTroughTiles)
                        {
                            if (tile.Layer.Equals("Buildings"))
                            {
                                buildingsLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(buildingsLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                            else if (tile.Layer.Equals("Front"))
                            {
                                frontLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(frontLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                        }

                        ModData.BarnsWithWateredTrough.Add(__instance.NameOrUniqueName.ToLower());

                        foreach (FarmAnimal animal in __instance.animals.Values)
                        {
                            if (ModEntry.Instance.Config.ShowLoveBubblesOverAnimalsWhenWateredTrough)
                            {
                                animal.doEmote(ModData.LoveEmote);
                            }
                            animal.friendshipTowardFarmer.Value += Math.Abs(ModEntry.Instance.Config.AdditionalFriendshipPointsForWateredTroughWithAnimalsInsideBuilding);
                        }
                    }
                }
                else if (__instance.getBuilding().nameOfIndoorsWithoutUnique.ToLower() == "barn2")
                {
                    foreach (TroughTile troughTile in ModEntry.Instance.CurrentTroughPlacementProfile.barn2TroughTiles)
                    {
                        if (troughTile.TileX != tileX || troughTile.TileY != tileY)
                        {
                            continue;
                        }

                        ModEntry.Instance.SendTroughWateredMessage(buildingType, __instance.NameOrUniqueName.ToLower());

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.barn2TroughTiles)
                        {
                            gameLocation.removeTile(tile.TileX, tile.TileY, tile.Layer);
                        }

                        Layer     buildingsLayer = gameLocation.Map.GetLayer("Buildings");
                        Layer     frontLayer     = gameLocation.Map.GetLayer("Front");
                        TileSheet tilesheet      = gameLocation.Map.GetTileSheet("z_waterTroughTilesheet");

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.barn2TroughTiles)
                        {
                            if (tile.Layer.Equals("Buildings"))
                            {
                                buildingsLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(buildingsLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                            else if (tile.Layer.Equals("Front"))
                            {
                                frontLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(frontLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                        }

                        ModData.BarnsWithWateredTrough.Add(__instance.NameOrUniqueName.ToLower());

                        foreach (FarmAnimal animal in __instance.animals.Values)
                        {
                            if (ModEntry.Instance.Config.ShowLoveBubblesOverAnimalsWhenWateredTrough)
                            {
                                animal.doEmote(ModData.LoveEmote);
                            }
                            animal.friendshipTowardFarmer.Value += Math.Abs(ModEntry.Instance.Config.AdditionalFriendshipPointsForWateredTroughWithAnimalsInsideBuilding);
                        }
                    }
                }
                else if (__instance.getBuilding().nameOfIndoorsWithoutUnique.ToLower() == "barn3")
                {
                    foreach (TroughTile troughTile in ModEntry.Instance.CurrentTroughPlacementProfile.barn3TroughTiles)
                    {
                        if (troughTile.TileX != tileX || troughTile.TileY != tileY)
                        {
                            continue;
                        }

                        ModEntry.Instance.SendTroughWateredMessage(buildingType, __instance.NameOrUniqueName.ToLower());

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.barn3TroughTiles)
                        {
                            gameLocation.removeTile(tile.TileX, tile.TileY, tile.Layer);
                        }

                        Layer     buildingsLayer = gameLocation.Map.GetLayer("Buildings");
                        Layer     frontLayer     = gameLocation.Map.GetLayer("Front");
                        TileSheet tilesheet      = gameLocation.Map.GetTileSheet("z_waterTroughTilesheet");

                        foreach (TroughTile tile in ModEntry.Instance.CurrentTroughPlacementProfile.barn3TroughTiles)
                        {
                            if (tile.Layer.Equals("Buildings"))
                            {
                                buildingsLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(buildingsLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                            else if (tile.Layer.Equals("Front"))
                            {
                                frontLayer.Tiles[tile.TileX, tile.TileY] = new StaticTile(frontLayer, tilesheet, BlendMode.Alpha, tileIndex: tile.FullTroughTilesheetIndex);
                            }
                        }

                        ModData.BarnsWithWateredTrough.Add(__instance.NameOrUniqueName.ToLower());

                        foreach (FarmAnimal animal in __instance.animals.Values)
                        {
                            if (ModEntry.Instance.Config.ShowLoveBubblesOverAnimalsWhenWateredTrough)
                            {
                                animal.doEmote(ModData.LoveEmote);
                            }
                            animal.friendshipTowardFarmer.Value += Math.Abs(ModEntry.Instance.Config.AdditionalFriendshipPointsForWateredTroughWithAnimalsInsideBuilding);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 34
0
        void ApplyToolToTile()
        {
            // Actually apply the tool to the tile in front of the bot.
            // This is a big pain in the neck that is duplicated in many of the Tool subclasses.
            // Here's how we do it:
            // First, get the tool to apply, and the tile location to apply it.
            if (farmer == null || inventory == null)
            {
                return;
            }
            Tool    tool     = inventory[currentToolIndex] as Tool;
            int     tileX    = (int)position.X / 64 + DxForDirection(farmer.FacingDirection);
            int     tileY    = (int)position.Y / 64 + DyForDirection(farmer.FacingDirection);
            Vector2 tile     = new Vector2(tileX, tileY);
            var     location = currentLocation;

            // If it's not a MeleeWeapon, call the easy method and let SDV handle it.
            if (tool is not MeleeWeapon)
            {
                Game1.toolAnimationDone(farmer);
                return;
            }

            // Otherwise, big pain in the neck time.

            // Apply it to the location itself.
            //Debug.Log($"{name} Performing {tool} action at {tileX},{tileY}");
            location.performToolAction(tool, tileX, tileY);

            // Then, apply it to any terrain feature (grass, weeds, etc.) at this location.
            if (location.terrainFeatures.ContainsKey(tile) && location.terrainFeatures[tile].performToolAction(tool, 0, tile, location))
            {
                //Debug.Log($"Performed tool action on the terrain feature {location.terrainFeatures[tile]}; removing it");
                location.terrainFeatures.Remove(tile);
            }
            if (location.largeTerrainFeatures is not null)
            {
                var tileRect = new Rectangle(tileX * 64, tileY * 64, 64, 64);
                for (int i = location.largeTerrainFeatures.Count - 1; i >= 0; i--)
                {
                    if (location.largeTerrainFeatures[i].getBoundingBox().Intersects(tileRect) && location.largeTerrainFeatures[i].performToolAction(tool, 0, tile, location))
                    {
                        //Debug.Log($"Performed tool action on the LARGE terrain feature {location.terrainFeatures[tile]}; removing it");
                        location.largeTerrainFeatures.RemoveAt(i);
                    }
                }
            }

            // Finally, apply to any object sitting on this tile.
            if (location.Objects.ContainsKey(tile))
            {
                var obj = location.Objects[tile];
                if (obj != null && obj.Type != null && obj.performToolAction(tool, location))
                {
                    if (obj.Type.Equals("Crafting") && (int)obj.Fragility != 2)
                    {
                        var center = farmer.GetBoundingBox().Center;
                        //Debug.Log($"Performed tool action on the object {obj}; adding debris");
                        location.debris.Add(new Debris(obj.bigCraftable.Value ? (-obj.ParentSheetIndex) : obj.ParentSheetIndex,
                                                       farmer.GetToolLocation(), new Vector2(center.X, center.Y)));
                    }
                    //Debug.Log($"Performing {obj} remove action, then removing it from {tile}");
                    obj.performRemoveAction(tile, location);
                    location.Objects.Remove(tile);
                }
            }
        }
Exemplo n.º 35
0
 /// <summary>Apply the tool to the given tile.</summary>
 /// <param name="tile">The tile to modify.</param>
 /// <param name="tileObj">The object on the tile.</param>
 /// <param name="tileFeature">The feature on the tile.</param>
 /// <param name="player">The current player.</param>
 /// <param name="tool">The tool selected by the player (if any).</param>
 /// <param name="item">The item selected by the player (if any).</param>
 /// <param name="location">The current location.</param>
 public abstract bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer player, Tool tool, Item item, GameLocation location);
Exemplo n.º 36
0
        public override bool performToolAction(Tool t, int explosion, Vector2 tileLocation, GameLocation location)
        {
            if ((float)health <= -99f)
            {
                return(false);
            }
            if (t != null && t is MeleeWeapon)
            {
                return(false);
            }
            if ((int)growthStage >= 4)
            {
                if (t != null && t is Axe)
                {
                    location.playSound("axchop");
                    location.debris.Add(new Debris(12, Game1.random.Next((int)t.upgradeLevel * 2, (int)t.upgradeLevel * 4), t.getLastFarmerToUse().GetToolLocation() + new Vector2(16f, 0f), t.getLastFarmerToUse().Position, 0));
                    lastPlayerToHit.Value = t.getLastFarmerToUse().UniqueMultiplayerID;
                    int fruitquality = 0;
                    if ((int)daysUntilMature <= -112)
                    {
                        fruitquality = 1;
                    }
                    if ((int)daysUntilMature <= -224)
                    {
                        fruitquality = 2;
                    }
                    if ((int)daysUntilMature <= -336)
                    {
                        fruitquality = 4;
                    }
                    if ((int)struckByLightningCountdown > 0)
                    {
                        fruitquality = 0;
                    }
                    if (location.terrainFeatures.ContainsKey(tileLocation) && location.terrainFeatures[tileLocation].Equals(this))
                    {
                        for (int i = 0; i < (int)fruitsOnTree; i++)
                        {
                            Vector2 offset = new Vector2(0f, 0f);
                            switch (i)
                            {
                            case 0:
                                offset.X = -64f;
                                break;

                            case 1:
                                offset.X = 64f;
                                offset.Y = -32f;
                                break;

                            case 2:
                                offset.Y = 32f;
                                break;
                            }
                            Debris d2 = new Debris(((int)struckByLightningCountdown > 0) ? 382 : ((int)indexOfFruit), new Vector2(tileLocation.X * 64f + 32f, (tileLocation.Y - 3f) * 64f + 32f) + offset, new Vector2(Game1.player.getStandingX(), Game1.player.getStandingY()))
                            {
                                itemQuality = fruitquality
                            };
                            d2.Chunks[0].xVelocity.Value += (float)Game1.random.Next(-10, 11) / 10f;
                            d2.chunkFinalYLevel           = (int)(tileLocation.Y * 64f + 64f);
                            location.debris.Add(d2);
                        }
                        fruitsOnTree.Value = 0;
                    }
                }
                else if (explosion <= 0)
                {
                    return(false);
                }
                shake(tileLocation, doEvenIfStillShaking: true, location);
                float damage3 = 1f;
                if (explosion > 0)
                {
                    damage3 = explosion;
                }
                else
                {
                    if (t == null)
                    {
                        return(false);
                    }
                    switch ((int)t.upgradeLevel)
                    {
                    case 0:
                        damage3 = 1f;
                        break;

                    case 1:
                        damage3 = 1.25f;
                        break;

                    case 2:
                        damage3 = 1.67f;
                        break;

                    case 3:
                        damage3 = 2.5f;
                        break;

                    case 4:
                        damage3 = 5f;
                        break;

                    default:
                        damage3 = (int)t.upgradeLevel + 1;
                        break;
                    }
                }
                health.Value -= damage3;
                if (t is Axe && t.hasEnchantmentOfType <ShavingEnchantment>() && Game1.random.NextDouble() <= (double)(damage3 / 5f))
                {
                    Debris d = new Debris(388, new Vector2(tileLocation.X * 64f + 32f, (tileLocation.Y - 0.5f) * 64f + 32f), new Vector2(Game1.player.getStandingX(), Game1.player.getStandingY()));
                    d.Chunks[0].xVelocity.Value += (float)Game1.random.Next(-10, 11) / 10f;
                    d.chunkFinalYLevel           = (int)(tileLocation.Y * 64f + 64f);
                    location.debris.Add(d);
                }
                if ((float)health <= 0f)
                {
                    if (!stump)
                    {
                        location.playSound("treecrack");
                        stump.Value   = true;
                        health.Value  = 5f;
                        falling.Value = true;
                        if (t == null || t.getLastFarmerToUse() == null)
                        {
                            shakeLeft.Value = true;
                        }
                        else
                        {
                            shakeLeft.Value = ((float)t.getLastFarmerToUse().getStandingX() > (tileLocation.X + 0.5f) * 64f);
                        }
                    }
                    else
                    {
                        health.Value = -100f;
                        Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(30, 40), resource: false);
                        int whatToDrop = 92;
                        if (Game1.IsMultiplayer)
                        {
                            Game1.recentMultiplayerRandom = new Random((int)tileLocation.X * 2000 + (int)tileLocation.Y);
                            _ = Game1.recentMultiplayerRandom;
                        }
                        else
                        {
                            new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + (int)tileLocation.X * 7 + (int)tileLocation.Y * 11);
                        }
                        if (t == null || t.getLastFarmerToUse() == null)
                        {
                            Game1.createMultipleObjectDebris(92, (int)tileLocation.X, (int)tileLocation.Y, 2, location);
                        }
                        else if (Game1.IsMultiplayer)
                        {
                            Game1.createMultipleObjectDebris(whatToDrop, (int)tileLocation.X, (int)tileLocation.Y, 1, lastPlayerToHit, location);
                            Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.getFarmer(lastPlayerToHit).professions.Contains(12) ? 5 : 4, resource: true);
                        }
                        else
                        {
                            Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, (int)((Game1.getFarmer(lastPlayerToHit).professions.Contains(12) ? 1.25 : 1.0) * 5.0), resource: true);
                            Game1.createMultipleObjectDebris(whatToDrop, (int)tileLocation.X, (int)tileLocation.Y, 1, location);
                        }
                    }
                }
            }
            else if ((int)growthStage >= 3)
            {
                if (t != null && t.BaseName.Contains("Ax"))
                {
                    location.playSound("axchop");
                    location.playSound("leafrustle");
                    location.debris.Add(new Debris(12, Game1.random.Next((int)t.upgradeLevel * 2, (int)t.upgradeLevel * 4), t.getLastFarmerToUse().GetToolLocation() + new Vector2(16f, 0f), new Vector2(t.getLastFarmerToUse().GetBoundingBox().Center.X, t.getLastFarmerToUse().GetBoundingBox().Center.Y), 0));
                }
                else if (explosion <= 0)
                {
                    return(false);
                }
                shake(tileLocation, doEvenIfStillShaking: true, location);
                float  damage       = 1f;
                Random debrisRandom = (!Game1.IsMultiplayer) ? new Random((int)((float)(double)Game1.uniqueIDForThisGame + tileLocation.X * 7f + tileLocation.Y * 11f + (float)(double)Game1.stats.DaysPlayed + (float)health)) : Game1.recentMultiplayerRandom;
                if (explosion > 0)
                {
                    damage = explosion;
                }
                else
                {
                    switch ((int)t.upgradeLevel)
                    {
                    case 0:
                        damage = 2f;
                        break;

                    case 1:
                        damage = 2.5f;
                        break;

                    case 2:
                        damage = 3.34f;
                        break;

                    case 3:
                        damage = 5f;
                        break;

                    case 4:
                        damage = 10f;
                        break;
                    }
                }
                int debris = 0;
                while (t != null && debrisRandom.NextDouble() < (double)damage * 0.08 + (double)((float)t.getLastFarmerToUse().ForagingLevel / 200f))
                {
                    debris++;
                }
                health.Value -= damage;
                if (debris > 0)
                {
                    Game1.createDebris(12, (int)tileLocation.X, (int)tileLocation.Y, debris, location);
                }
                if ((float)health <= 0f)
                {
                    Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(20, 30), resource: false);
                    return(true);
                }
            }
            else if ((int)growthStage >= 1)
            {
                if (explosion > 0)
                {
                    return(true);
                }
                if (t != null && t.BaseName.Contains("Axe"))
                {
                    location.playSound("axchop");
                    Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(10, 20), resource: false);
                }
                if (t is Axe || t is Pickaxe || t is Hoe || t is MeleeWeapon)
                {
                    Game1.createRadialDebris(location, 12, (int)tileLocation.X, (int)tileLocation.Y, Game1.random.Next(10, 20), resource: false);
                    if (t.BaseName.Contains("Axe") && Game1.recentMultiplayerRandom.NextDouble() < (double)((float)t.getLastFarmerToUse().ForagingLevel / 10f))
                    {
                        Game1.createDebris(12, (int)tileLocation.X, (int)tileLocation.Y, 1, location);
                    }
                    Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(17, tileLocation * 64f, Color.White));
                    return(true);
                }
            }
            else
            {
                if (explosion > 0)
                {
                    return(true);
                }
                if (t.BaseName.Contains("Axe") || t.BaseName.Contains("Pick") || t.BaseName.Contains("Hoe"))
                {
                    location.playSound("woodyHit");
                    location.playSound("axchop");
                    Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(17, tileLocation * 64f, Color.White));
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 37
0
 public ToolWriter(Tool tool, StreamWriter streamWriter)
 {
     Tool          = tool;
     _streamWriter = streamWriter;
 }
Exemplo n.º 38
0
 private void RectangleBtn_Click(object sender, EventArgs e)
 {
     activeTool = Tool.Rectangle;
 }
Exemplo n.º 39
0
 public static ModelVisual3D GetDiskOnConeModel(Tool tool, Point3D position, Vector3D direction, Func <string, MeshGeometryVisual3D> visual3DFactory = null)
 {
     return(GetToolModel(tool, position, direction, GetDiskOnConeMesh, visual3DFactory));
 }
Exemplo n.º 40
0
 private void LineBtn_Click(object sender, EventArgs e)
 {
     activeTool = Tool.Line;
 }
Exemplo n.º 41
0
 private void PencilBtn_Click(object sender, EventArgs e)
 {
     activeTool = Tool.Pencil;
 }
Exemplo n.º 42
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //删除
                if (ToolManager.CheckQueryString("ids"))
                {
                    string        error           = string.Empty;
                    List <string> sqls            = new List <string>();
                    string        deliveryNumbers = ToolManager.GetQueryString("ids");
                    string        sql             = string.Format(" delete CertificateOrdersDetail where OrdersNumber in ({0}) ", deliveryNumbers);
                    sqls.Add(sql);
                    sql = string.Format("delete CertificateOrders where OrdersNumber in ({0})", deliveryNumbers);
                    sqls.Add(sql);
                    if (SqlHelper.BatchExecuteSql(sqls, ref error))
                    {
                        Tool.WriteLog(Tool.LogType.Operating, "删除采购单信息" + ToolManager.ReplaceSingleQuotesToBlank(deliveryNumbers), "删除成功");
                        Response.Write("1");
                        Response.End();
                        return;
                    }
                    else
                    {
                        Tool.WriteLog(Tool.LogType.Operating, "删除采购单信息" + ToolManager.ReplaceSingleQuotesToBlank(deliveryNumbers), "删除失败!原因" + error);
                        Response.Write(error);
                        Response.End();
                        return;
                    }
                }
                //查询
                if (ToolManager.CheckQueryString("pageIndex"))
                {
                    GetPageOperation("btnSearch", "AddOrEditCertificateOrdersList.aspx", "CertificateOrdersListDetail.aspx");
                }

                //审核
                if (ToolManager.CheckQueryString("Check"))
                {
                    string numbers = ToolManager.GetQueryString("Check");
                    string temp    = BLL.PurchaseManager.AuditorPurchase(numbers, ToolCode.Tool.GetUser().UserNumber);
                    bool   result  = temp == "1" ? true : false;
                    if (result)
                    {
                        Tool.WriteLog(Tool.LogType.Operating, "审核采购单信息" + ToolManager.ReplaceSingleQuotesToBlank(numbers), "审核成功");
                        Response.Write(temp);
                        Response.End();
                        return;
                    }
                    else
                    {
                        Tool.WriteLog(Tool.LogType.Operating, "审核采购单信息" + ToolManager.ReplaceSingleQuotesToBlank(numbers), "审核失败!原因" + temp);
                        Response.Write(temp);
                        Response.End();
                        return;
                    }
                }
                divAdd.Visible     = ToolCode.Tool.GetUserMenuFunc("L0203", "Add");
                divDelete.Visible  = ToolCode.Tool.GetUserMenuFunc("L0203", "Delete");
                divAuditor.Visible = ToolCode.Tool.GetUserMenuFunc("L0203", "Audit");
                //Bind();
            }
        }
Exemplo n.º 43
0
 private void EllipseBtn_Click(object sender, EventArgs e)
 {
     activeTool = Tool.Ellipse;
 }
Exemplo n.º 44
0
        private static bool ResourceClump_performToolAction_prefix(ref ResourceClump __instance, Tool t, int damage, Vector2 tileLocation, GameLocation location, ref bool __result)
        {
            int indexOfClump = __instance.parentSheetIndex;

            if (indexOfClump - firstIndex < 0)
            {
                return(true);
            }
            CustomResourceClump clump = customClumps.FirstOrDefault(c => c.index == indexOfClump);

            if (clump == null)
            {
                return(true);
            }

            if (t == null)
            {
                return(false);
            }
            SMonitor.Log($"hitting custom clump {indexOfClump} with {t.GetType()} (should be {(tools.ContainsKey(clump.toolType) ? tools[clump.toolType].ToString() + " (not in dictionary!)" : clump.toolType)})");

            if (!tools.ContainsKey(clump.toolType) || t.GetType() != tools[clump.toolType])
            {
                return(false);
            }
            SMonitor.Log($"tooltype is correct");
            if (t.upgradeLevel < clump.toolMinLevel)
            {
                foreach (string sound in clump.failSounds)
                {
                    location.playSound(sound, NetAudio.SoundContext.Default);
                }

                Game1.drawObjectDialogue(string.Format(SHelper.Translation.Get("failed"), t.DisplayName));

                Game1.player.jitterStrength = 1f;
                return(false);
            }

            float power = Math.Max(1f, (float)(t.upgradeLevel + 1) * 0.75f);

            __instance.health.Value -= power;
            Game1.createRadialDebris(Game1.currentLocation, clump.debrisType, (int)tileLocation.X + Game1.random.Next(__instance.width / 2 + 1), (int)tileLocation.Y + Game1.random.Next(__instance.height / 2 + 1), Game1.random.Next(4, 9), false, -1, false, -1);

            if (__instance.health > 0f)
            {
                foreach (string sound in clump.hitSounds)
                {
                    location.playSound(sound, NetAudio.SoundContext.Default);
                }
                if (clump.shake != 0)
                {
                    SHelper.Reflection.GetField <float>(__instance, "shakeTimer").SetValue(clump.shake);
                    __instance.NeedsUpdate = true;
                }
                return(false);
            }

            __result = true;

            foreach (string sound in clump.breakSounds)
            {
                location.playSound(sound, NetAudio.SoundContext.Default);
            }

            Farmer who = t.getLastFarmerToUse();

            int addedItems = who.professions.Contains(18) ? 1 : 0;
            int experience = 0;

            SMonitor.Log($"custom clump has {clump.dropItems.Count} potential items.");
            foreach (DropItem item in clump.dropItems)
            {
                if (Game1.random.NextDouble() < item.dropChance / 100)
                {
                    SMonitor.Log($"dropping item {item.itemIdOrName}");

                    if (!int.TryParse(item.itemIdOrName, out int itemId))
                    {
                        foreach (KeyValuePair <int, string> kvp in Game1.objectInformation)
                        {
                            if (kvp.Value.StartsWith(item.itemIdOrName + "/"))
                            {
                                itemId = kvp.Key;
                                break;
                            }
                        }
                    }
                    int amount = addedItems + Game1.random.Next(item.minAmount, Math.Max(item.minAmount + 1, item.maxAmount + 1)) + ((Game1.random.NextDouble() < (double)((float)who.LuckLevel / 100f)) ? item.luckyAmount : 0);
                    Game1.createMultipleObjectDebris(itemId, (int)tileLocation.X, (int)tileLocation.Y, amount, who.uniqueMultiplayerID, location);
                }
            }
            if (expTypes.ContainsKey(clump.expType))
            {
                experience = clump.exp;
                who.gainExperience(expTypes[clump.expType], experience);
            }
            else
            {
                SMonitor.Log($"Invalid experience type {clump.expType}", LogLevel.Warn);
            }
            return(false);
        }
Exemplo n.º 45
0
        public override bool performToolAction(Tool t, int explosion, Vector2 tileLocation, GameLocation location)
        {
            if (location == null)
            {
                location = Game1.currentLocation;
            }
            if ((int)size == 4)
            {
                return(false);
            }
            if (explosion > 0)
            {
                shake(tileLocation, doEvenIfStillShaking: true);
                return(false);
            }
            if (t != null && t is Axe && isDestroyable(location, tileLocation))
            {
                location.playSound("leafrustle");
                shake(tileLocation, doEvenIfStillShaking: true);
                if ((int)(t as Axe).upgradeLevel >= 1 || (int)size == 3)
                {
                    health -= (((int)size == 3) ? 0.5f : ((float)(int)(t as Axe).upgradeLevel / 5f));
                    if (health <= -1f)
                    {
                        location.playSound("treethud");
                        DelayedAction.playSoundAfterDelay("leafrustle", 100);
                        Color  c      = Color.Green;
                        string season = (((int)overrideSeason == -1) ? Game1.GetSeasonForLocation(location) : Utility.getSeasonNameFromNumber(overrideSeason));
                        switch (season)
                        {
                        case "spring":
                            c = Color.Green;
                            break;

                        case "summer":
                            c = Color.ForestGreen;
                            break;

                        case "fall":
                            c = Color.IndianRed;
                            break;

                        case "winter":
                            c = Color.Cyan;
                            break;
                        }
                        if ((bool)greenhouseBush)
                        {
                            c = Color.Green;
                            if (location != null && location.Name.Equals("Sunroom"))
                            {
                                foreach (NPC character in location.characters)
                                {
                                    character.jump();
                                    character.doEmote(12);
                                }
                            }
                        }
                        for (int i = 0; i <= getEffectiveSize(); i++)
                        {
                            for (int j = 0; j < 12; j++)
                            {
                                Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(355, 1200 + (season.Equals("fall") ? 16 : (season.Equals("winter") ? (-16) : 0)), 16, 16), Utility.getRandomPositionInThisRectangle(getBoundingBox(), Game1.random) - new Vector2(0f, Game1.random.Next(64)), flipped: false, 0.01f, c)
                                {
                                    motion             = new Vector2((float)Game1.random.Next(-10, 11) / 10f, -Game1.random.Next(5, 7)),
                                    acceleration       = new Vector2(0f, (float)Game1.random.Next(13, 17) / 100f),
                                    accelerationChange = new Vector2(0f, -0.001f),
                                    scale                     = 4f,
                                    layerDepth                = (tileLocation.Y + 1f) * 64f / 10000f,
                                    animationLength           = 11,
                                    totalNumberOfLoops        = 99,
                                    interval                  = Game1.random.Next(20, 90),
                                    delayBeforeAnimationStart = (i + 1) * j * 20
                                });
                                if (j % 6 == 0)
                                {
                                    Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(50, Utility.getRandomPositionInThisRectangle(getBoundingBox(), Game1.random) - new Vector2(32f, Game1.random.Next(32, 64)), c));
                                    Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(12, Utility.getRandomPositionInThisRectangle(getBoundingBox(), Game1.random) - new Vector2(32f, Game1.random.Next(32, 64)), Color.White));
                                }
                            }
                        }
                        return(true);
                    }
                    location.playSound("axchop");
                }
            }
            return(false);
        }
Exemplo n.º 46
0
        private void btnRenewal_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> parameters = null;

            Dictionary <string, object> filterStored = null;
            List <string> tableNames = null;
            DataSet       ds         = null;

            try
            {
                CheckControl();
                if (isActionProgress)
                {
                    return;
                }

                Tool.ShowWaiting();
                parameters = new Dictionary <string, string>();
                parameters.Add("SHORTDESC", string.Format("SHORTDESC + N'; Сунгалтын шалтгаан: {0}/ Огноо: {1}({2})'", memoDesc.Text, Tool.ConvertNonTimeDateTime(dateReturn.EditValue), txtRenewal.Text));
                parameters.Add("RETURNDATE", string.Format("N'{0}'", Tool.ConvertDateTime(dateReturn.EditValue)));
                SqlConnector.UpdateByPkId(dbName, "Document", parameters, pkId);

                filterStored = new Dictionary <string, object>();
                filterStored.Add("@PKID", pkId);
                filterStored.Add("@IsFirst", "Y");
                tableNames = new List <string>()
                {
                    "ChildrenDocument"
                };
                ds = SqlConnector.GetStoredProcedure(dbName, "GetChildrenIncome", filterStored, tableNames);
                if (ds.Tables["ChildrenDocument"] == null)
                {
                    goto Finish;
                }
                if (ds.Tables["ChildrenDocument"].Rows == null || ds.Tables["ChildrenDocument"].Rows.Count.Equals(0))
                {
                    goto Finish;
                }

                foreach (DataRow dr in ds.Tables["ChildrenDocument"].Rows)
                {
                    SqlConnector.UpdateByPkId(dbName, "Document", parameters, decimal.Parse(dr["PKID"].ToString()));
                }

Finish:
                Tool.ShowSuccess("Амжилттай сунгалт орууллаа!");
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Dispose();
            }
            catch (MofException ex)
            {
                System.Diagnostics.Debug.WriteLine("Сунгалт хийхэд алдаа гарлаа: " + ex.InnerException.Message);
                Tool.ShowError(ex.Message, ex.InnerException.Message);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Сунгалт хийхэд алдаа гарлаа: " + ex.Message);
                Tool.ShowError("Сунгалт хийхэд алдаа гарлаа!", ex.Message);
            }
            finally { parameters = null; filterStored = null; tableNames = null; ds = null; Tool.CloseWaiting(); }
        }
Exemplo n.º 47
0
 /*********
 ** Public methods
 *********/
 /// <summary>Get whether the tool is currently enabled.</summary>
 /// <param name="player">The current player.</param>
 /// <param name="tool">The tool selected by the player (if any).</param>
 /// <param name="item">The item selected by the player (if any).</param>
 /// <param name="location">The current location.</param>
 public abstract bool IsEnabled(SFarmer player, Tool tool, Item item, GameLocation location);
Exemplo n.º 48
0
        private void Associate(ref Boolean[] flag, ref List <MoChromosome> result, ref List <MoChromosome> Fl)
        {
            if (result.Count == 0)
            {
                //List<MoChromosome> li = Fl.OrderBy(r => r.fitnessValue).ToList();
                for (int i = 0; i < this.numObjectives; i++)
                {
                    double min = 10;
                    int    pos = -1;
                    for (int j = 0; j < Fl.Count; j++)
                    {
                        double tp = Tool.GetAngle(TranObj(Fl[j]), unitVec[i]);
                        if (tp < min)
                        {
                            min = tp;
                            pos = j;
                        }
                    }
                    result.Add(Fl[pos]);
                    flag[pos] = false;
                }

                PairRelation[] li = new PairRelation[Fl.Count];
                for (int i = 0; i < li.Length; i++)
                {
                    li[i] = new PairRelation(i, Fl[i].fitnessValue);
                }

                li = li.OrderBy(r => r.val).ToArray();

                int cnt = 0;
                while (result.Count < 2 * this.numObjectives)
                {
                    if (flag[li[cnt].pos] == false)
                    {
                        result.Add(Fl[li[cnt].pos]);
                        flag[li[cnt].pos] = true;
                    }
                    cnt++;
                }
            }
            for (int i = 0; i < Fl.Count; i++)
            {
                if (flag[i] == true)
                {
                    continue;
                }
                double minA = Double.MaxValue;
                int    pos  = -1;
                for (int j = 0; j < result.Count; j++)
                {
                    double tp = Tool.GetAngle(TranObj(result[j]), TranObj(Fl[i]));
                    if (tp < minA)
                    {
                        minA = tp;
                        pos  = j;
                    }
                }
                Fl[i].angle     = minA;
                Fl[i].subProbNo = pos;
            }
        }
Exemplo n.º 49
0
        /// <summary>
        /// Returns a collection of <see cref="T:Dataweb.NShape.Advanced.MenuItemDef" /> for constructing context menus etc.
        /// </summary>
        public IEnumerable <MenuItemDef> GetMenuItemDefs(Tool clickedTool)
        {
            // menu structure:
            //
            // Create Template...
            // Edit Template...
            // Delete Template
            // -------------------
            // Show Design Editor
            // Show Library manager

            bool     isFeasible;
            string   description;
            Template clickedTemplate = null;

            if (clickedTool is TemplateTool)
            {
                clickedTemplate = ((TemplateTool)clickedTool).Template;
            }

            isFeasible  = true;
            description = "Create a new Template";
            yield return(new DelegateMenuItemDef("Create Template...", null, description, isFeasible, Permission.Templates,
                                                 (action, project) => OnTemplateEditorSelected(new TemplateEditorEventArgs(project))));

            isFeasible  = (clickedTemplate != null);
            description = isFeasible ? string.Format("Edit Template '{0}'", clickedTemplate.Title) :
                          "No template tool selected";
            yield return(new DelegateMenuItemDef("Edit Template...", null, description, isFeasible, Permission.Templates,
                                                 (action, project) => OnTemplateEditorSelected(new TemplateEditorEventArgs(project, clickedTemplate))));

            isFeasible = (clickedTemplate != null);
            if (!isFeasible)
            {
                description = "No template tool selected";
            }
            else
            {
                foreach (Template template in Project.Repository.GetTemplates())
                {
                    if (template.Shape.Template == clickedTemplate)
                    {
                        isFeasible = false;
                        break;
                    }
                }
                if (isFeasible)
                {
                    // Check if template is in use
                    foreach (Diagram diagram in Project.Repository.GetDiagrams())
                    {
                        foreach (Shape shape in diagram.Shapes)
                        {
                            if (shape.Template == clickedTemplate)
                            {
                                isFeasible = false;
                                break;
                            }
                        }
                    }
                }
                if (isFeasible)
                {
                    description = string.Format("Delete Template '{0}'", clickedTemplate.Title);
                }
                else
                {
                    description = string.Format("Template '{0}' is in use.", clickedTemplate.Title);
                }
            }
            yield return(new CommandMenuItemDef("Delete Template...", null, description, isFeasible,
                                                isFeasible ? new DeleteTemplateCommand(clickedTemplate) : null));

            yield return(new SeparatorMenuItemDef());

            isFeasible  = true;
            description = "Edit the current design or create new designs";
            yield return(new DelegateMenuItemDef("Show Design Editor...", Properties.Resources.DesignEditorBtn,
                                                 description, isFeasible, Permission.Designs,
                                                 (action, project) => OnDesignEditorSelected(EventArgs.Empty)));

            isFeasible  = true;
            description = "Load and unload shape and/or model libraries";
            yield return(new DelegateMenuItemDef("Show Library Manager...", Properties.Resources.LibrariesBtn,
                                                 description, isFeasible, Permission.Templates,
                                                 (action, project) => OnLibraryManagerSelected(EventArgs.Empty)));
        }
Exemplo n.º 50
0
 // Select a tool as current tool
 public static void SelectTool(Tool tool)
 {
     currentTool = tool;
     UseCurrentTool();
 }
Exemplo n.º 51
0
        public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, SFarmer who, Tool tool, Item item, GameLocation location)
        {
            if (this.Config.CutDebris && (tileObj?.Name == "Twig" || tileObj?.Name.ToLower().Contains("weed") == true))
            {
                return(this.UseToolOnTile(tool, tile));
            }

            switch (tileFeature)
            {
            case Tree tree:
                if (this.Config.CutTrees)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                break;

            case HoeDirt dirt when dirt.crop != null:
                if (this.Config.CutDeadCrops && dirt.crop.dead)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                if (this.Config.CutLiveCrops && !dirt.crop.dead)
                {
                    return(this.UseToolOnTile(tool, tile));
                }
                break;
            }


            if (this.Config.CutDebris)
            {
                ResourceClump rc = this.ResourceClumpCoveringTile(location, tile);
                if (rc != null && this.ResourceUpgradeNeeded.ContainsKey(rc.parentSheetIndex) && tool.upgradeLevel >= this.ResourceUpgradeNeeded[rc.parentSheetIndex])
                {
                    this.UseToolOnTile(tool, tile);
                }
            }
            return(false);
        }
Exemplo n.º 52
0
 // Deselect current tool.
 public static void DeselectTool()
 {
     currentTool = defaultTool;
     UseCurrentTool();
 }
Exemplo n.º 53
0
 public override bool IsEnabled(SFarmer who, Tool tool, Item item, GameLocation location)
 {
     return(tool is Axe);
 }
Exemplo n.º 54
0
 // Set a tool as default tool.
 public static void SetDefaultTool(Tool tool)
 {
     defaultTool = tool;
     ActiveTool(tool);
 }
Exemplo n.º 55
0
        //sets up the basic structure of either transmute event, since they have some common ground
        private static void HandleEitherTransmuteEvent(string keyPressed)
        {
            // save is loaded
            if (Context.IsWorldReady)
            {
                //per the advice of Ento, abort if the player is in an event
                if (Game1.CurrentEvent != null)
                {
                    return;
                }

                //something may have gone wrong if this is null, maybe there's no save data?
                if (Game1.player != null)
                {
                    //get the player's current item
                    Item heldItem = Game1.player.CurrentItem;

                    //player is holding item
                    if (heldItem != null)
                    {
                        //get the item's ID
                        int heldItemID = heldItem.parentSheetIndex;

                        //alchemy energy can be used to execute a complex tool action if a tool is in hand.
                        if (heldItem is StardewValley.Tool && keyPressed.ToString() == instance.Config.TransmuteKey)
                        {
                            Tool itemTool = heldItem as Tool;

                            bool isScythe      = itemTool is MeleeWeapon && itemTool.Name.ToLower().Contains("scythe");
                            bool isAxe         = itemTool is Axe;
                            bool isPickaxe     = itemTool is Pickaxe;
                            bool isHoe         = itemTool is Hoe;
                            bool isWateringCan = itemTool is WateringCan;

                            bool canDoToolAlchemy = isScythe || isAxe || isPickaxe || isHoe || isWateringCan;

                            if (canDoToolAlchemy)
                            {
                                Alchemy.HandleToolTransmute(itemTool);
                            }
                        }

                        //try to normalize the item [make all items of a different quality one quality and exchange any remainder for gold]
                        if (keyPressed.ToString() == instance.Config.NormalizeKey)
                        {
                            Alchemy.HandleNormalizeEvent(heldItem);
                            return;
                        }

                        //abort any transmutation event for blacklisted items or items that for whatever reason can't exist in world.
                        if (!GetTransmutationFormulas().HasItem(heldItemID) || !heldItem.canBeDropped())
                        {
                            return;
                        }

                        //get the transmutation value, it's based on what it's worth to the player, including profession bonuses. This affects both cost and value.
                        int actualValue = ((StardewValley.Object)heldItem).sellToStorePrice();

                        //try to transmute [copy] the item
                        if (keyPressed.ToString() == instance.Config.TransmuteKey)
                        {
                            var shouldBreakOutOfRepeater = Alchemy.HandleTransmuteEvent(heldItem, actualValue);
                            if (shouldBreakOutOfRepeater && !brokeRepeaterDueToNoEnergy)
                            {
                                brokeRepeaterDueToNoEnergy = true;
                                instance.heldCounter       = 1;
                                instance.updateTickCount   = AUTO_REPEAT_UPDATE_RATE_REFRESH * 2;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 56
0
        public IActionResult Create()
        {
            Tool model = new Tool();

            return(View(model));
        }
Exemplo n.º 57
0
 public override bool OnEscape()
 {
     Tool.SetDefaultMode();
     return(true);
 }
Exemplo n.º 58
0
        public override void HandleMouse(int pxX, int pxY, PictureBox pb)
        {
            if (!m_fOptionbox_Selecting)
            {
                return;
            }

            // Convert pixel (x,y) to tool (x,y).
            int nX = pxX / k_pxToolboxToolSize;
            int nY = pxY / k_pxToolboxToolSize;

            // If outside the Toolbox bounds.
            if (pxX < k_pxToolboxIndent || pxY < k_pxToolboxIndent ||
                nX >= ToolboxColumns || nY >= ToolboxRows)
            {
                // If we have a current option tool, then we need to revert the button state.
                if (m_eCurrentOptionTool != ToolType.Blank)
                {
                    // If button state is unchanged, nothing to revert.
                    if (m_fOriginalOptionToolState == m_toolOptionCurrent.Hilight)
                    {
                        return;
                    }

                    // Revert tool to original state.
                    SetCurrentToolHilight(pb, m_fOriginalOptionToolState);
                }
                return;
            }

            foreach (Tool t in Tools)
            {
                // Find the tool at the mouse position.
                if (nX != t.X || nY != t.Y)
                {
                    continue;
                }

                // Ignore if not visible or not enabled.
                if (!t.Show || !t.Enabled)
                {
                    return;
                }

                // Select the tool (if needed).
                // Only one option can be changed at a time, so record the first
                // option tool that is selected.
                if (m_eCurrentOptionTool == ToolType.Blank)
                {
                    m_toolOptionCurrent        = t;
                    m_eCurrentOptionTool       = t.Type;
                    m_fOriginalOptionToolState = t.Hilight;
                }

                // Mousemoves are now processed in the context of the current option tool.
                // The current option tool was either just selected above, or is left over
                // from the previous mouse event.

                // If same as the currently selected tool and we've already toggled the
                // button state - nothing to do.
                if (t.Type == m_eCurrentOptionTool && m_fOriginalOptionToolState != m_toolOptionCurrent.Hilight)
                {
                    return;
                }
                // Similarly if it's outside the current tool and we haven't toggled the tool state.
                if (t.Type != m_eCurrentOptionTool && m_fOriginalOptionToolState == m_toolOptionCurrent.Hilight)
                {
                    return;
                }

                // Set the button hilighting based on whether or not we're still in the original tool.
                if (t.Type == m_eCurrentOptionTool)
                {
                    SetCurrentToolHilight(pb, !m_fOriginalOptionToolState);
                }
                else
                {
                    SetCurrentToolHilight(pb, m_fOriginalOptionToolState);
                }
                return;
            }

            // No matching tool found - revert tool to original state.
            SetCurrentToolHilight(pb, m_fOriginalOptionToolState);
        }
Exemplo n.º 59
0
 private void Fill2_Click(object sender, EventArgs e)
 {
     activeTool = Tool.Fill2;
 }
 private void OnApply() => Tool.ApplyIntersectionTemplate(EditObject);