public void HoldClickedByPlayer(Thing selectedThing, Crew crewStatus) { //called when the player is holding click on this node. //applies work done by the thing if it matches the required tool if (selectedThing == null) { return; } BlueprintNodeTask currentTask = GetCurrentBlueprintNodeTask(); if (currentTask.nodeMode == NodeModes.work) { if (selectedThing.thingType == currentTask.requiredThingType && currentTask.workFilled < currentTask.workRequired && crewStatus.GetBatteryEnergy() > 0) { float energyUsed = Time.deltaTime * selectedThing.workRate; if (energyUsed > crewStatus.GetBatteryEnergy()) { energyUsed = crewStatus.GetBatteryEnergy(); } currentTask.workFilled += energyUsed; crewStatus.UseEnergyThing(selectedThing, energyUsed); StartToolSound(); } else { StopToolSound(); } UpdateNodeTask(); } }
public void AddRequiredThing(ThingTypes thingType, int requiredQuantity) { //this node will require a quantity of this thing BlueprintNodeTask nodeTask = new BlueprintNodeTask(requiredQuantity, thingType); GetNodeTasks().Add(nodeTask); }
public void AddRequiredTool(ThingTypes toolThingType, float requiredWork) { //this node will require work done with this tool type. BlueprintNodeTask nodeTask = new BlueprintNodeTask(requiredWork, toolThingType); GetNodeTasks().Add(nodeTask); }
private NodeModes GetCurrentNodeMode() { //BlueprintNodes can contain many BlueprintNodeTasks. This returns the current nodeMode, or if they're //all constructed, returns constructed. BlueprintNodeTask nodeTask = GetCurrentBlueprintNodeTask(); if (nodeTask == null) { return(NodeModes.constructed); } return(nodeTask.nodeMode); }
private void SetNodeAppearanceAndSound() { //update the text, appearance, and sound for this node. BlueprintNodeTask nodeTask = GetCurrentBlueprintNodeTask(); NodeModes nodeMode = GetCurrentNodeMode(); //set render and collide on sphere and cone SetThingVisibility(nodeMode == NodeModes.thing); SetWorkVisibility(nodeMode == NodeModes.work); //Debug.Log("SetNodeAppearanceAndSound " + nodeMode+" "+nodeTask.requiredThingType+" "+nodeTask.requiredThingType); if (nodeMode == NodeModes.constructed) { GetTextMesh(0).text = ""; GetTextMesh(1).text = ""; GetTextMesh(2).text = ""; SetNodeMaterial(GetDoneMaterial()); GetBlueprintParent().MakeIfConstructed(); StopToolSound(); } else if (nodeMode == NodeModes.thing) { GetTextMesh(0).text = ThingFactory.thingTemplates[nodeTask.requiredThingType].longName; GetTextMesh(1).text = nodeTask.quantityFilled + " / " + nodeTask.quantityRequired; GetTextMesh(2).text = ""; SetNodeMaterial(GetThingMaterial()); } else if (nodeMode == NodeModes.work) { GetTextMesh(0).text = ThingFactory.thingTemplates[nodeTask.requiredThingType].workVerb; GetTextMesh(1).text = Mathf.FloorToInt(nodeTask.workFilled) + " / " + nodeTask.workRequired; GetTextMesh(2).text = nodeTask.quantityRequired > 0 ? ThingFactory.thingTemplates[nodeTask.requiredThingType].longName : ""; SetNodeMaterial(GetWorkMaterial()); SetupAudioSource(nodeTask.requiredThingType); } }
public void ClickedByPlayer(Crew crewStatus) { //called when the player clicks on this node. //if necessary, takes items from the player inventory, if they have it, and applies it to the thing node. if (GetCurrentBlueprintNodeTask().nodeMode == NodeModes.thing) { BlueprintNodeTask nodeTask = GetCurrentBlueprintNodeTask(); Thing foundThing = crewStatus.FindThingFromInventory(nodeTask.requiredThingType); if (foundThing != null && nodeTask.quantityFilled < nodeTask.quantityRequired && foundThing.quantity > 0) { int quantityUsed = nodeTask.quantityRequired - nodeTask.quantityFilled; if (quantityUsed > foundThing.quantity) { quantityUsed = foundThing.quantity; } nodeTask.quantityFilled += quantityUsed; crewStatus.UseThing(foundThing, quantityUsed); } UpdateNodeTask(); } }