/// <summary> /// Returns the first <see cref="BuildResource"/> in the series of resources for which '<paramref name="resource"/>' belongs. /// </summary> public static BuildResource GetStart(BuildResource resource) { switch (GetType(resource)) { case BuildResourceType.BasePieces: return(BuildResource.WoodPiece); case BuildResourceType.Supplies: return(BuildResource.CementSupply); case BuildResourceType.Roofing: return(BuildResource.TileRoofing); case BuildResourceType.Flooring: return(BuildResource.BrickFlooring); case BuildResourceType.Panels: return(BuildResource.WoodPanel); case BuildResourceType.Walls: return(BuildResource.WoodWall); case BuildResourceType.Doors: return(BuildResource.WoodDoor); case BuildResourceType.Windows: return(BuildResource.WoodWindow); case BuildResourceType.Stairs: return(BuildResource.WoodStair); case BuildResourceType.Foundations: return(BuildResource.WoodFoundation); } return(BuildResource.None); }
void ProcessResources (VesselResources resources, BuildResourceSet report_resources, BuildResourceSet required_resources = null) { var reslist = resources.resources.Keys.ToList (); foreach (string res in reslist) { double amount = resources.ResourceAmount (res); var recipe = ExRecipeDatabase.ResourceRecipe (res); if (recipe != null) { double density = ExRecipeDatabase.ResourceDensity (res); double mass = amount * density; recipe = recipe.Bake (mass); foreach (var ingredient in recipe.ingredients) { var br = new BuildResource (ingredient); var resset = report_resources; if (required_resources != null) { resset = required_resources; } resset.Add (br); } } else { var br = new BuildResource (res, amount); report_resources.Add (br); } } }
public InternalTarget(BuildSystem buildSystem, BaseBuildingTool tool, Type resourceType, BuildResource resource) : base(2, false, TargetFlags.None) { m_BuildSystem = buildSystem; m_Tool = tool; m_ResourceType = resourceType; m_Resource = resource; }
public void Add (BuildResource res) { if (resources.ContainsKey (res.name)) { resources[res.name].Merge (res); } else { resources[res.name] = res; } }
/// <summary> /// Registers that '<paramref name="resourceType"/>' uses '<paramref name="resource"/>' so that it can later be queried by <see cref="BuildResources.GetFromType"/> /// </summary> public static void RegisterType(Type resourceType, BuildResource resource) { if (m_TypeTable == null) { m_TypeTable = new Hashtable(); } m_TypeTable[resourceType] = resource; }
/// <summary> /// Returns a <see cref="BuildResourceType"/> value indiciating the type of '<paramref name="resource"/>'. /// </summary> public static BuildResourceType GetType(BuildResource resource) { if (resource >= BuildResource.WoodPiece && resource <= BuildResource.BambooPiece) { return(BuildResourceType.BasePieces); } if (resource >= BuildResource.CementSupply && resource <= BuildResource.StainSupply) { return(BuildResourceType.Supplies); } if (resource >= BuildResource.TileRoofing && resource <= BuildResource.SlateRoofing) { return(BuildResourceType.Roofing); } if (resource >= BuildResource.BrickFlooring && resource <= BuildResource.RugFlooring) { return(BuildResourceType.Flooring); } if (resource >= BuildResource.WoodPanel && resource <= BuildResource.BambooPanel) { return(BuildResourceType.Panels); } if (resource >= BuildResource.WoodWall && resource <= BuildResource.BambooWall) { return(BuildResourceType.Walls); } if (resource >= BuildResource.WoodDoor && resource <= BuildResource.BambooDoor) { return(BuildResourceType.Doors); } if (resource >= BuildResource.WoodWindow && resource <= BuildResource.BambooWindow) { return(BuildResourceType.Windows); } if (resource >= BuildResource.WoodStair && resource <= BuildResource.MarbleStair) { return(BuildResourceType.Stairs); } if (resource >= BuildResource.WoodFoundation && resource <= BuildResource.MarbleFoundation) { return(BuildResourceType.Foundations); } return(BuildResourceType.None); }
private bool Resmelt(Mobile from, Item item, BuildResource resource) { try { if (BuildResources.GetType(resource) != BuildResourceType.BasePieces) { return(false); } BuildResourceInfo info = BuildResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(false); } BuildItem buildItem = m_BuildSystem.BuildItems.SearchFor(item.GetType()); if (buildItem == null || buildItem.Ressources.Count == 0) { return(false); } BuildRes buildResource = buildItem.Ressources.GetAt(0); if (buildResource.Amount < 2) { return(false); // Not enough metal to resmelt } Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)Activator.CreateInstance(resourceType); if (item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed)) { ingot.Amount = buildResource.Amount / 2; } else { ingot.Amount = 1; } item.Delete(); from.AddToBackpack(ingot); from.PlaySound(0x2A); from.PlaySound(0x240); return(true); } catch { } return(false); }
/// <summary> /// Returns the index of '<paramref name="resource"/>' in the seriest of resources for which it belongs. /// </summary> public static int GetIndex(BuildResource resource) { BuildResource start = GetStart(resource); if (start == BuildResource.None) { return(0); } return((int)(resource - start)); }
/// <summary> /// Reduces income. /// </summary> public void DecreaseIncome(BuildResource decreseIncome) { for (int i = 0; i < resourceIncome.Length; i++) { if (decreseIncome.resourceType == resourceIncome[i].resourceType) { resourceIncome[i].resourceAmount -= decreseIncome.resourceAmount; break; } } UpdateUI(); }
public BuildResourceInfo(int hue, int number, string name, BuildAttributeInfo attributeInfo, BuildResource resource, params Type[] resourceTypes) { m_Hue = hue; m_Number = number; m_Name = name; m_AttributeInfo = attributeInfo; m_Resource = resource; m_ResourceTypes = resourceTypes; for (int i = 0; i < resourceTypes.Length; ++i) { BuildResources.RegisterType(resourceTypes[i], resource); } }
public void TestCreateResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"sid\": \"ZB00000000000000000000000000000000\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ZS00000000000000000000000000000000\",\"asset_versions\": [{\"sid\": \"ZN00000000000000000000000000000000\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ZS00000000000000000000000000000000\",\"asset_sid\": \"ZH00000000000000000000000000000000\",\"date_created\": \"2018-11-10T20:00:00Z\",\"path\": \"asset-path\",\"visibility\": \"PUBLIC\"}],\"function_versions\": [{\"sid\": \"ZN00000000000000000000000000000001\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ZS00000000000000000000000000000000\",\"function_sid\": \"ZH00000000000000000000000000000001\",\"date_created\": \"2018-11-10T20:00:00Z\",\"path\": \"function-path\",\"visibility\": \"PUBLIC\"}],\"dependencies\": [{\"name\": \"twilio\",\"version\": \"3.6.3\"}],\"status\": \"queued\",\"date_created\": \"2018-11-10T20:00:00Z\",\"date_updated\": \"2018-11-10T20:00:00Z\",\"url\": \"https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds/ZB00000000000000000000000000000000\"}" )); var response = BuildResource.Create("ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void Load (ConfigNode node) { var req = node.GetNode ("Required"); foreach (var r in req.GetNodes ("BuildResrouce")) { var res = new BuildResource (); res.Load (r); required.Add (res); } var opt = node.GetNode ("Optional"); foreach (var r in opt.GetNodes ("BuildResrouce")) { var res = new BuildResource (); res.Load (r); optional.Add (res); } }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"sid\": \"ZB00000000000000000000000000000000\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ZS00000000000000000000000000000000\",\"asset_versions\": [{\"sid\": \"ZN00000000000000000000000000000000\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ZS00000000000000000000000000000000\",\"asset_sid\": \"ZH00000000000000000000000000000000\",\"date_created\": \"2018-11-10T20:00:00Z\",\"path\": \"/asset-path\",\"visibility\": \"PUBLIC\"}],\"function_versions\": [{\"sid\": \"ZN00000000000000000000000000000001\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"ZS00000000000000000000000000000000\",\"function_sid\": \"ZH00000000000000000000000000000001\",\"date_created\": \"2018-11-10T20:00:00Z\",\"path\": \"/function-path\",\"visibility\": \"PUBLIC\"}],\"dependencies\": [{\"name\": \"twilio\",\"version\": \"3.29.2\"},{\"name\": \"@twilio/runtime-handler\",\"version\": \"1.0.1\"}],\"runtime\": \"node10\",\"status\": \"deploying\",\"date_created\": \"2018-11-10T20:00:00Z\",\"date_updated\": \"2018-11-10T20:00:00Z\",\"url\": \"https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds/ZB00000000000000000000000000000000\",\"links\": {\"build_status\": \"https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds/ZB00000000000000000000000000000000/Status\"}}" )); var response = BuildResource.Fetch("ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestDeleteResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.NoContent, "null" )); var response = BuildResource.Delete("ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestReadEmptyResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"builds\": [],\"meta\": {\"first_page_url\": \"https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds?PageSize=50&Page=0\",\"key\": \"builds\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds?PageSize=50&Page=0\"}}" )); var response = BuildResource.Read("ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
/// <summary> /// Adds given amount of resource, use other method to subtract /// </summary> /// <param name="resource"> resource, that should be added </param> /// <param name="modifier"> multiplier added on resource amount, can be negative</param> /// <returns> Return false if negative amount is given </returns> public bool AddResource(BuildResource resource, float modifier) { if (resource.resourceAmount < 0) { return(false); } for (int i = 0; i < resources.Length; i++) { if (resources[i].resourceType == resource.resourceType) { resources[i].resourceAmount += (Mathf.RoundToInt(resource.resourceAmount * modifier)); UpdateUI(); return(true); } } throw new NotImplementedException("resource " + resource.resourceType + " not found"); }
/// <summary> /// Whether resource is enough to buy something. /// </summary> /// <param name="moneyCost"></param> /// <returns> Whether enought resources are avaible </returns> public bool CanBuyByCost(BuildResource resourceCost) { for (int i = 0; i < resources.Length; i++) { if (resources[i].resourceType == resourceCost.resourceType) { if (resources[i].resourceAmount >= resourceCost.resourceAmount) { return(true); } else { return(false); } } } throw new NotImplementedException("resource " + resourceCost.resourceType + " not found"); }
public void Load(ConfigNode node) { var req = node.GetNode("Required"); foreach (var r in req.GetNodes("BuildResrouce")) { var res = new BuildResource(); res.Load(r); required.Add(res); } var opt = node.GetNode("Optional"); foreach (var r in opt.GetNodes("BuildResrouce")) { var res = new BuildResource(); res.Load(r); optional.Add(res); } }
/// <summary> /// Subtracts given amount of resource, wont subtract if no resources are avaible and return false /// </summary> /// <param name="resource"> resource, that should be subtracted </param> /// <returns> Whether enought resources are avaible </returns> public bool SubtractResource(BuildResource resource) { for (int i = 0; i < resources.Length; i++) { if (resources[i].resourceType == resource.resourceType) { if (resources[i].resourceAmount >= +resource.resourceAmount) { resources[i].resourceAmount -= resource.resourceAmount; UpdateUI(); return(true); } else { return(false); } } } throw new NotImplementedException("resource " + resource.resourceType + " not found"); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Serverless, "/v1/Services/ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds/ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { BuildResource.Fetch("ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public static void BeginTarget(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool) { BuildContext context = buildSystem.GetContext(from); if (context == null) { return; } int lastRes = context.LastResourceIndex; BuildSubResCol subRes = buildSystem.BuildSubRes; if (lastRes >= 0 && lastRes < subRes.Count) { BuildSubRes res = subRes.GetAt(lastRes); if (LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Value < res.RequiredLokaiSkill) { from.SendGump(new BuildGump(from, buildSystem, tool, res.Message)); } else { BuildResource resource = BuildResources.GetFromType(res.ItemType); if (resource != BuildResource.None) { from.Target = new InternalTarget(buildSystem, tool, res.ItemType, resource); from.SendLocalizedMessage(1061004); // Target an item to enhance with the properties of your selected material. } else { from.SendGump(new BuildGump(from, buildSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } } } else { from.SendGump(new BuildGump(from, buildSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } }
/// <summary> /// Returns a <see cref="BuildResourceInfo"/> instance describing '<paramref name="resource"/>' -or- null if an invalid resource was specified. /// </summary> public static BuildResourceInfo GetInfo(BuildResource resource) { BuildResourceInfo[] list = null; switch (GetType(resource)) { case BuildResourceType.BasePieces: list = m_BaseInfo; break; case BuildResourceType.Supplies: list = m_SuppliesInfo; break; case BuildResourceType.Flooring: list = m_FlooringInfo; break; case BuildResourceType.Roofing: list = m_RoofingInfo; break; case BuildResourceType.Panels: list = m_PanelInfo; break; case BuildResourceType.Walls: list = m_WallsInfo; break; case BuildResourceType.Doors: list = m_DoorsInfo; break; case BuildResourceType.Windows: list = m_WindowsInfo; break; case BuildResourceType.Stairs: list = m_StairsInfo; break; case BuildResourceType.Foundations: list = m_FoundationsInfo; break; } if (list != null) { int index = GetIndex(resource); if (index >= 0 && index < list.Length) { return(list[index]); } } return(null); }
double ProcessResources(VesselResources resources, List<BuildResource> report_resources) { double hullMass = 0; var reslist = resources.resources.Keys.ToList (); foreach (string res in reslist) { double amount = resources.ResourceAmount (res); var br = new BuildResource (res, amount); if (br.hull) { //FIXME better hull resources check hullMass += br.mass; } else { report_resources.Add (br); } } return hullMass; }
double ResourceProgress(string label, BuildResource br, BuildResource req, bool forward) { double fraction = 1; if (req.amount > 0) { fraction = (req.amount - br.amount) / req.amount; } double required = br.amount; double available = control.padResources.ResourceAmount (br.name); double alarmTime; string percent = (fraction * 100).ToString ("G4") + "%"; if (control.paused) { percent = percent + "[paused]"; alarmTime = 0; // need assignment or compiler complains about use of unassigned variable } else { double eta = BuildETA (br, req, forward); alarmTime = Planetarium.GetUniversalTime () + eta; percent = percent + " " + EL_Utils.TimeSpanString (eta); } GUILayout.BeginHorizontal (); // Resource name GUILayout.Box (label, Styles.white, GUILayout.Width (125), GUILayout.Height (40)); GUILayout.BeginVertical (); Styles.bar.Draw ((float) fraction, percent, 300); GUILayout.EndVertical (); // Calculate if we have enough resources to build GUIStyle requiredStyle = Styles.green; if (required > available) { requiredStyle = Styles.yellow; } // Required and Available GUILayout.Box (displayAmount(required), requiredStyle, GUILayout.Width (100), GUILayout.Height (40)); GUILayout.Box (displayAmount(available), Styles.white, GUILayout.Width (100), GUILayout.Height (40)); GUILayout.FlexibleSpace (); GUILayout.EndHorizontal (); return alarmTime; }
double BuildETA(BuildResource br, BuildResource req, bool forward) { double numberOfFramesLeft; if (br.deltaAmount <= 0) { return 0; } if (forward) { numberOfFramesLeft = (br.amount / br.deltaAmount); } else { numberOfFramesLeft = ((req.amount-br.amount) / br.deltaAmount); } return numberOfFramesLeft * TimeWarp.fixedDeltaTime; }
/// <summary> /// Returns true if '<paramref name="resource"/>' is None. False if otherwise. /// </summary> public static bool IsStandard(BuildResource resource) { return(resource == BuildResource.None); }
double ResourceProgress(string label, BuildResource br, BuildResource req, bool forward) { double fraction = (req.amount - br.amount) / req.amount; double required = br.amount; double available = control.padResources.ResourceAmount (br.name); double alarmTime; string percent = (fraction * 100).ToString ("G4") + "% "; if (control.paused) { percent = percent + "[paused]"; alarmTime = 0; // need assignment or compiler complains about use of unassigned variable } else { double numberOfFramesLeft; TimeSpan timeLeft; try { if (forward) { numberOfFramesLeft = (br.amount / br.deltaAmount); } else { numberOfFramesLeft = ((req.amount-br.amount) / br.deltaAmount); } double numberOfSecondsLeft = numberOfFramesLeft * TimeWarp.fixedDeltaTime; timeLeft = TimeSpan.FromSeconds (numberOfSecondsLeft); alarmTime = Planetarium.GetUniversalTime () + timeLeft.TotalSeconds; } catch { // catch overflows or any other math errors, and just give a value // it will be overwritten the next time timeLeft = TimeSpan.FromSeconds(0); alarmTime=0; } percent = percent + String.Format ("{0:D2}:{1:D2}:{2:D2}", timeLeft.Hours, timeLeft.Minutes, timeLeft.Seconds); } GUILayout.BeginHorizontal (); // Resource name GUILayout.Box (label, Styles.white, GUILayout.Width (120), GUILayout.Height (40)); GUILayout.BeginVertical (); Styles.bar.Draw ((float) fraction, percent, 300); GUILayout.EndVertical (); // Calculate if we have enough resources to build GUIStyle requiredStyle = Styles.green; if (required > available) { requiredStyle = Styles.yellow; } // Required and Available GUILayout.Box ((Math.Round (required, 2)).ToString (), requiredStyle, GUILayout.Width (75), GUILayout.Height (40)); GUILayout.Box ((Math.Round (available, 2)).ToString (), Styles.white, GUILayout.Width (75), GUILayout.Height (40)); GUILayout.FlexibleSpace (); GUILayout.EndHorizontal (); return alarmTime; }
static void Main(string[] args) { // Your Account Sid and Auth Token from twilio.com/console string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); // Setup Default Twilio Client TwilioClient.Init(accountSid, authToken); // Create string for Basic Auth using RestSharp string upload_auth = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(accountSid + ":" + authToken)); // Create Service // https://www.twilio.com/docs/runtime/functions-assets-api/api/service#create-a-service-resource var service = ServiceResource.Create( includeCredentials: true, uniqueName: "my-new-app", friendlyName: "My New App" ); // Create Environment // https://www.twilio.com/docs/runtime/functions-assets-api/api/environment#create-an-environment-resource var environment = EnvironmentResource.Create( domainSuffix: "stage", uniqueName: "staging", pathServiceSid: service.Sid ); // Create Asset // https://www.twilio.com/docs/runtime/functions-assets-api/api/asset#create-an-asset-resource var asset = AssetResource.Create( friendlyName: "friendly_name", pathServiceSid: service.Sid ); // Create Asset Verion const string remote_path = "/mypath"; const string remote_visibility = "Public"; const string asset_file = "hello.txt"; const string asset_type = "text/plain"; string asset_path = Path.Combine("assets", asset_file); string url = $"https://serverless-upload.twilio.com/v1/Services/{service.Sid}/Assets/{asset.Sid}/Versions"; var client = new RestClient(url); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Authorization", upload_auth); request.AddFile("Content", asset_path, asset_type); request.AddParameter("Path", remote_path); request.AddParameter("Visibility", remote_visibility); IRestResponse response = client.Execute(request); var obj = JsonConvert.DeserializeObject <dynamic>(response.Content); List <string> asset_versions = new List <string>() { obj.sid.ToString() }; // Create a Build // https://www.twilio.com/docs/runtime/functions-assets-api/api/build#create-a-build-resource var build = BuildResource.Create( assetVersions: asset_versions, pathServiceSid: service.Sid ); Console.WriteLine("Sleep for 10 seconds."); Thread.Sleep(10000); // Create a Deployment // https://www.twilio.com/docs/runtime/functions-assets-api/api/deployment var deployment = DeploymentResource.Create( buildSid: build.Sid, pathServiceSid: service.Sid, pathEnvironmentSid: environment.Sid ); // Show URL Console.Write($"http://{environment.DomainName}{remote_path}"); }
/// <summary> /// Returns the <see cref="BuildResourceInfo.Number"/> property of '<paramref name="resource"/>' -or- 0 if an invalid resource was specified. /// </summary> public static int GetLocalizationNumber(BuildResource resource) { BuildResourceInfo info = GetInfo(resource); return(info == null ? 0 : info.Number); }
public static EnhanceResult Invoke(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, Item item, BuildResource resource, Type resType, ref object resMessage) { return(EnhanceResult.BadItem); }
public void Load (ConfigNode node) { recycle_parts = new HashSet<uint> (); if (node.HasValue ("recycle_parts")) { var ids = node.GetValue ("recycle_parts").Split (new char[]{' '}); uint id; for (int i = 0; i < ids.Length; i++) { if (uint.TryParse (ids[i], out id)) { recycle_parts.Add (id); } } } if (node.HasNode ("part_resource")) { part_resources = new List<BuildResource> (); foreach (var pr in node.GetNodes ("part_resource")) { var res = new BuildResource (); res.Load (pr); part_resources.Add (res); } } if (node.HasValue ("state")) { var state = fsm.FindState (node.GetValue ("state")); if (state != null) { start_state = state; } } }
double ReclaimResource (BuildResource br, double deltat) { if (br.density > 0) { var amount = recycler.RecycleRate * deltat / br.density; var base_amount = amount; if (amount > br.amount) { amount = br.amount; } var remain = recycler_resources.TransferResource (br.name, amount); br.amount -= amount - remain; br.mass = br.amount * br.density; deltat = deltat * remain / base_amount; } else { recycler_resources.TransferResource (br.name, br.amount); br.amount = 0; deltat = 0; } return deltat; }
/// <summary> /// Returns the <see cref="BuildResourceInfo.Name"/> property of '<paramref name="resource"/>' -or- an empty string if the resource specified was invalid. /// </summary> public static string GetName(BuildResource resource) { BuildResourceInfo info = GetInfo(resource); return(info == null ? String.Empty : info.Name); }
/// <summary> /// Returns the <see cref="BuildResourceInfo.Hue"/> property of '<paramref name="resource"/>' -or- 0 if an invalid resource was specified. /// </summary> public static int GetHue(BuildResource resource) { BuildResourceInfo info = GetInfo(resource); return(info == null ? 0 : info.Hue); }
double DumpResource (BuildResource br, double deltat) { if (br.density > 0) { var amount = recycler.RecycleRate * deltat / br.density; var base_amount = amount; if (amount > br.amount) { amount = br.amount; } br.amount -= amount; deltat = deltat * (base_amount - amount) / base_amount; } else { br.amount = 0; deltat = 0; } return deltat; }
public BuildResourceInfo(string name, BuildResource resource, params Type[] resourceTypes) : this(0x000, 0, name, BuildAttributeInfo.Blank, resource, resourceTypes) { }
public void AddResource(BuildResource resourceType, int amount) { resources[resourceType] += amount; UpdateResourceVisual(); TryBuild(); }
public void Remove (BuildResource res) { resources.Remove (res.name); }
void ProcessIngredient (Ingredient ingredient, BuildResourceSet rd, bool xfer) { var res = ingredient.name; Recipe recipe = null; // If the resource is being transfered from a tank (rather than // coming from the part body itself), then a transfer recipe will // override a recycle recipe if (xfer) { recipe = ExRecipeDatabase.TransferRecipe (res); } if (recipe == null) { recipe = ExRecipeDatabase.RecycleRecipe (res); } if (recipe != null) { recipe = recipe.Bake (ingredient.ratio); foreach (var ing in recipe.ingredients) { if (ing.isReal) { var br = new BuildResource (ing); rd.Add (br); } } } else { if (ExRecipeDatabase.ResourceRecipe (res) != null) { } else { if (ingredient.isReal) { var br = new BuildResource (ingredient); rd.Add (br); } } } }