public void BakeRotation(LiquidVolume lv) { if (PrefabUtility.GetPrefabObject(lv.gameObject) != null) { PrefabUtility.DisconnectPrefabInstance(lv.gameObject); } MeshFilter mf = lv.GetComponent <MeshFilter> (); string meshPath = AssetDatabase.GetAssetPath(mf.sharedMesh); Mesh mesh = Instantiate <Mesh> (mf.sharedMesh) as Mesh; Vector3[] vertices = mesh.vertices; Vector3 scale = lv.transform.localScale; lv.transform.localScale = Vector3.one; for (int k = 0; k < vertices.Length; k++) { vertices [k] = lv.transform.TransformVector(vertices [k]); } mesh.vertices = vertices; mesh.RecalculateBounds(); mf.sharedMesh = mesh; SaveMeshAsset(mesh, meshPath); lv.transform.localRotation = Quaternion.Euler(0, 0, 0); lv.transform.localScale = scale; RefreshCollider(lv); }
public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface) { Message.Append("&mIt is disgusting but incredibly calming."); Target.ApplyEffect(new Asleep(12, true, true)); return(true); }
public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface) { Message.Append("&cIt is terrifying."); Target.ApplyEffect(new Stun(12, Volume / 100)); return(true); }
public override void ObjectEnteredCell(LiquidVolume Liquid, GameObject GO) { if (Liquid.MaxVolume != -1 || !GO.HasPart("Body") || !GO.PhaseAndFlightMatches(Liquid.ParentObject) || GO.GetIntProperty("Slimewalking") > 0 || Liquid.Volume > 1000) { return; } int num = 10 + (int)((double)(Liquid.ComponentLiquids[ID] * 5) / 1000.0); if (!GO.MakeSave("Agility,Toughness", num - GO.GetIntProperty("Stable"), null, null, "Unwanted Growth")) { BodyPart bp = null; GO.GetPart <Body>()._Body.ForeachPart(delegate(BodyPart BP){ if (BP.GetTotalMobility() > 0 && (bp == null || BP.GetTotalMobility() > bp.GetTotalMobility())) { bp = BP; } }); if (bp != null) { if (GO.IsPlayer()) { MessageQueue.AddPlayerMessage("&CYour " + bp.Name + " grow" + (bp.Plural?"":"s") + " a little!"); } GO.pPhysics.Weight += 1; } } }
void Update() { if (Time.time < startingDelay) { return; } for (int k = 0; k < numCylinders; k++) { GameObject cylinder = Instantiate(Resources.Load <GameObject>("Prefabs/CylinderFlask")); cylinder.hideFlags = HideFlags.DontSave; cylinder.transform.SetParent(transform, false); cylinder.transform.localScale = new Vector3(scale, scale * heightMultiplier, scale); float x = Mathf.Cos(((float)k / numCylinders) * Mathf.PI * 2.0f) * circleRadius; float z = Mathf.Sin(((float)k / numCylinders) * Mathf.PI * 2.0f) * circleRadius; cylinder.transform.position = new Vector3(x, -2f, z); FlaskAnimator fa = cylinder.AddComponent <FlaskAnimator>(); fa.initialPosition = cylinder.transform.position; fa.finalPosition = cylinder.transform.position + Vector3.up; fa.duration = 5f + k * 0.5f; fa.acceleration = 0.001f; fa.delay = 4f; LiquidVolume lv = cylinder.GetComponent <LiquidVolume>(); lv.liquidColor1 = new Color(Random.value, Random.value, Random.value, Random.value); lv.liquidColor2 = new Color(Random.value, Random.value, Random.value, Random.value); lv.turbulence2 = 0; lv.refractionBlur = false; } Destroy(this); }
public override void RenderPrimary(LiquidVolume Liquid, RenderEvent eRender) { if (Liquid.ParentObject.IsFreezing()) { eRender.RenderString = "~"; eRender.ColorString = "&Y^k"; return; } Render pRender = Liquid.ParentObject.pRender; int num = (XRLCore.CurrentFrame + Liquid.nFrameOffset) % 60; if (Stat.RandomCosmetic(1, 60) == 1 || pRender.ColorString == "&c") { if (num < 15) { pRender.RenderString = string.Empty + '÷'; pRender.ColorString = "&Y^k"; } else if (num < 30) { pRender.RenderString = "~"; pRender.ColorString = "&Y^k"; } else if (num < 45) { pRender.RenderString = string.Empty + '÷'; pRender.ColorString = "&Y^k"; } else { pRender.RenderString = "~"; pRender.ColorString = "&Y^k"; } } }
public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface) { long turns = XRLCore.Core.Game.Turns; if (Target.HasPart("Stomach")) { Stomach part = Target.GetPart <Stomach>(); Target.FireEvent(Event.New("AddWater", "Amount", 2 * Volume, "Forced", 1)); Target.FireEvent(Event.New("AddFood", "Satiation", "Snack")); Message.Append("It is bitter and delicious.\n"); Message.Append("You are now " + part.FoodStatus() + "."); } if (!Target.Property.ContainsKey("ConfuseOnEatTurnWine")) { Target.Property.Add("ConfuseOnEatTurnWine", XRLCore.Core.Game.Turns.ToString()); } if (!Target.Property.ContainsKey("ConfuseOnEatAmountWine")) { Target.Property.Add("ConfuseOnEatAmountWine", "0"); } long longProperty = Target.GetLongProperty("ConfuseOnEatTurnWine"); int num = (int)Target.GetLongProperty("ConfuseOnEatAmountWine"); if (turns - longProperty > 80) { num = 0; } if (num > Math.Max(1, Target.Statistics["Toughness"].Modifier * 2) && Target.ApplyEffect(new Confused(Stat.Roll("5d5"), 1, 3))) { ExitInterface = true; } Target.SetLongProperty("ConfuseOnEatTurnWine", turns); Target.Property["ConfuseOnEatAmountWine"] = (num + 1).ToString(); return(true); }
public static LiquidVolume GetPuddle(Cell cell) { LiquidVolume ret = null; foreach (GameObject GO in cell.GetObjects()) { LiquidVolume volume = GO.GetPart <LiquidVolume>(); if (volume != null) { if (ret != null) { ret.MixWith(volume); GO.Destroy(); } else { ret = volume; } if (volume.MaxVolume == -1) { volume.MaxVolume = 10000; } } } return(ret); }
public void CenterPivot(LiquidVolume lv) { if (PrefabUtility.GetPrefabObject(lv.gameObject) != null) { PrefabUtility.DisconnectPrefabInstance(lv.gameObject); } MeshFilter mf = lv.GetComponent <MeshFilter> (); string meshPath = AssetDatabase.GetAssetPath(mf.sharedMesh); Mesh mesh = Instantiate <Mesh> (mf.sharedMesh) as Mesh; Vector3[] vertices = mesh.vertices; Vector3 midPoint = Vector3.zero; for (int k = 0; k < vertices.Length; k++) { midPoint += vertices [k]; } midPoint /= vertices.Length; for (int k = 0; k < vertices.Length; k++) { vertices [k] -= midPoint; } mesh.vertices = vertices; mesh.RecalculateBounds(); mf.sharedMesh = mesh; SaveMeshAsset(mesh, meshPath); lv.transform.localPosition += midPoint; RefreshCollider(lv); }
public override string GetAdjective(LiquidVolume Liquid) { if (Liquid == null || Liquid.ComponentLiquids[ID] > 0) { return("&" + Color + (Color == "k"?"^K":"") + "" + ColorNames[Color] + ""); } return(null); }
public override void BaseRenderPrimary(LiquidVolume Liquid) { if (Liquid.IsWadingDepth()) { Liquid.ParentObject.pRender.RenderString = "~"; } Liquid.ParentObject.pRender.ColorString = "&M^g"; }
public override bool FireEvent(Event E) { if (E.ID == "BeginTakeAction") { if (this.isCatalyzing) { this.EvolveSludge(); } } else if (E.ID == "EnteredCell") { if (!this.isCatalyzing) { if (!this.hasFormed) { this.hasFormed = true; } Cell currentCell = this.ParentObject.pPhysics.CurrentCell; if (currentCell != null) { List <GameObject> objectsWithPart = currentCell.GetObjectsWithPart("LiquidVolume"); if (objectsWithPart != null) { foreach (GameObject gameObject in objectsWithPart) { LiquidVolume part = gameObject.GetPart <LiquidVolume>(); if (part.MaxVolume == -1) { if (!this.ComponentLiquids.Contains(part.bPrimary) && part.bPrimary != (byte)19) { this.newLiquid = part.bPrimary; } else if (part.bSecondary != byte.MaxValue && part.bSecondary != (byte)19 && !this.ComponentLiquids.Contains(part.bSecondary)) { this.newLiquid = part.bSecondary; } if (this.newLiquid != (byte)99) { this.isCatalyzing = true; IPart.AddPlayerMessage(this.ParentObject.The + this.ParentObject.ShortDisplayName + "&y" + this.ParentObject.GetVerb("start", true, false) + " reacting with the " + LiquidVolume.ComponentLiquidTypes[this.newLiquid].GetName(part) + "&y."); part.UseDrams(500); if (part.Volume <= 0) { gameObject.Destroy(); } } } } } } } } else if (E.ID == "ObjectCreated") { this.ParentObject.SetStringProperty("AlwaysOffhand", "Yes"); } return(true); }
public override void RenderSmearPrimary(LiquidVolume Liquid, RenderEvent eRender) { int num = XRLCore.CurrentFrame % 60; if (num > 5 && num < 15) { eRender.ColorString = "&" + Color + (Color == "k"?"^K":""); } base.RenderSmearPrimary(Liquid, eRender); }
public override void RenderSmearPrimary(LiquidVolume Liquid, RenderEvent eRender, GameObject obj) { int num = XRLCore.CurrentFrame % 60; if (num > 5 && num < 15) { eRender.ColorString = "&w"; } base.RenderSmearPrimary(Liquid, eRender, obj); }
public override void ObjectEnteredCell(LiquidVolume Liquid, GameObject GO) { if (Liquid.MaxVolume == -1 && GO.PhaseAndFlightMatches(Liquid.ParentObject) && GO.GetIntProperty("Slimewalking") <= 0 && GO.HasPart("Body")) { int difficulty = 10 + (int)((double)(Liquid.ComponentLiquids[ID] * 5) / 1000.0); if (!GO.MakeSave("Strength,Agility", difficulty, null, null, "Restraining Agent Restraint")) { GO.ApplyEffect(new Stun(12, Liquid.ComponentLiquids[ID] / 100)); } } }
// public override void PouredOn(LiquidVolume Liquid, GameObject GO, GameObject By) // { // if (Liquid.ComponentLiquids.Count != 1) // { // return true; // } // if (Liquid.Volume > 0 && GO.HasPart("Stomach") && GO.HasPart("Body") && GO.GetIntProperty("Inorganic") == 0 && GO.HasStat("Toughness")) // { // BodyPart p = GO.GetPart<Body>()._Body.GetParts().GetRandomElement(); // BodyPart p2 = GO.GetPart<Body>()._Body.GetParts().GetRandomElement(); // p2.AddPart(p.DeepCopy(GO,GO.GetPart<Body>())); // GO.Statistics["Toughness"].Penalty += 3; // IPart.AddPlayerMessage(GO.The+GO.DisplayNameOnly+"'s "+p2.Name+" sprout"+(p2.Plural?"":"s")+" "+(p.Plural?"":"a ")+p.Name+"!"); // } // return true; // } public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface) { Message.Append("&bDisgusting!\nYour form bulges."); if (Target.HasStat("Strength") && Target.HasStat("Toughness")) { Target.Statistics["Strength"].Bonus += 1; Target.Statistics["Toughness"].Penalty += 2; Target.GetPart <Physics>().Weight += 10; } return(true); }
void RefreshCollider(LiquidVolume lv) { MeshCollider mc = lv.GetComponent <MeshCollider> (); if (mc != null) { Mesh oldMesh = mc.sharedMesh; mc.sharedMesh = null; mc.sharedMesh = oldMesh; } }
public LiquidVolume GetPuddle() { Cell cell = ParentObject.CurrentCell; foreach (GameObject GO in cell.GetObjects()) { LiquidVolume volume = GO.GetPart <LiquidVolume>(); if (volume != null) { return(volume); } } return(null); }
public override bool PouredOn(LiquidVolume Liquid, XRL.World.GameObject GO) { // if (Liquid.ComponentLiquids.Count != 1) // { // return true; // } if (Liquid.Volume > 0) { GO.pRender.TileColor = "&" + this.Color; GO.pRender.ColorString = "&" + this.Color; GO.pRender.DetailColor = ToggleCase(this.Color); } return(true); }
public override void ObjectGoingProne(LiquidVolume Liquid, GameObject GO) { if (Liquid.IsWadingDepth()) { if (GO.IsPlayer()) { BaseLiquid.AddPlayerMessage("{{R|Poisonous ichor splashes into your mouth. You feel your nervious system shutters.}}"); } GO.Splatter("&w."); if (!GO.MakeSave("Toughness", 30, null, null, "Goo Poison")) { GO.ApplyEffect(new Poisoned(Stat.Roll("1d4+4"), Stat.Roll("1d2+2") + "d2", 10)); } } }
public static void GetFerments() { if (ferments == null) { ferments = new Dictionary <string, string>(); List <GameObjectBlueprint> bps = GameObjectFactory.Factory.GetBlueprintsWithTag("FermentTo"); foreach (GameObjectBlueprint bp in bps) { if (bp.allparts.ContainsKey("LiquidVolume")) { string[] liquidbits = bp.allparts["LiquidVolume"].GetParameter("InitialLiquid").Split('-'); //IPart.AddPlayerMessage("Tryadd initliq:"+liquidbits[0]+" / "+String.Join(", ",LiquidVolume.ComponentLiquidNameMap.Keys.ToList().ToArray())); if (LiquidVolume.getLiquid(liquidbits[0]) != null) { BaseLiquid L = LiquidVolume.getLiquid(liquidbits[0]); if (LiquidVolume.getLiquid(bp.GetTag("FermentTo")) != null) { BaseLiquid F = LiquidVolume.getLiquid(bp.GetTag("FermentTo")); //ferments[L.Name] = Convert.ToByte(F.ID); IPart.AddPlayerMessage(L.ID + " can ferment to:" + F.ID + "!"); ferments[L.ID] = F.ID; } else { ferments[L.ID] = bp.GetTag("FermentTo"); IPart.AddPlayerMessage(L.ID + " can ferment to:" + bp.GetTag("FermentTo") + "!"); } } } else { if (LiquidVolume.getLiquid(bp.GetTag("FermentTo")) != null) { BaseLiquid F = LiquidVolume.getLiquid(bp.GetTag("FermentTo")); //ferments[bp.Name] = Convert.ToByte(F.ID); ferments[bp.Name] = F.ID; IPart.AddPlayerMessage(bp.Name + " can ferments to:" + F.ID + "!"); } else { ferments[bp.Name] = bp.GetTag("FermentTo"); IPart.AddPlayerMessage(bp.Name + " can ferment to:" + bp.GetTag("FermentTo") + "!"); } } } } }
public bool HandleEvent(BrewingFinishedEvent e) { var liquidVolume = ParentObject.GetPart <LiquidVolume>(); string beverage = null; if (LiquidVolume.isValidLiquid(e.Recipe.Beverage)) { beverage = e.Recipe.Beverage; } else if (PopulationManager.HasPopulation(e.Recipe.Beverage)) { beverage = PopulationManager.RollOneFrom(e.Recipe.Beverage).Blueprint; } if (beverage != null && LiquidVolume.isValidLiquid(beverage)) { liquidVolume.MixWith(new LiquidVolume(beverage, 1)); var message = e.Recipe.Mistake ? MESSAGE_BREWING_FAILURE : e.Recipe.Tricky ? MESSAGE_BREWING_SUCCESS_TRICKY : MESSAGE_BREWING_SUCCESS; AddPlayerMessage(VariableReplace( message.Replace( "=liquid=", liquidVolume.GetLiquidName() ), Subject: ParentObject )); if (e.Recipe.Mistake) { GetAnnoyed(e.Activator); } } else { AddPlayerMessage(VariableReplace( MESSAGE_BREWING_HUH, Subject: ParentObject )); } return(true); }
public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface) { if (Target.HasPart("Stomach") && !Target.FireEvent(new Event("AddWater", "Amount", 10 * Liquid.ComponentLiquids[ID]))) { return(false); } if (Target.HasPart("Amphibious")) { Message.Append("You pour the milk on yourself!\n"); } else { Message.Append("Ahh, warm and refreshing!\n"); } return(true); }
/// <summary> /// Gets the display name of this cooking recipe component (i.e. ingredient), not including /// any units or additional phrases. /// </summary> public static string GetComponentSimpleName(this ICookingRecipeComponent component) { if (component is PreparedCookingRecipieComponentDomain componentDomain) { return(componentDomain.ingredientType); } if (component is PreparedCookingRecipieComponentLiquid componentLiquid) { return(LiquidVolume.getLiquid(componentLiquid.liquid).GetName()); } if (component is PreparedCookingRecipieComponentBlueprint componentBlueprint) { return(componentBlueprint.ingredientDisplayName); } return("{{K|<unknown ingredient>}}"); }
public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface) { Message.Compound("{{poisonous| It tastes like bitter omens ...}}"); Damage value = new Damage((Liquid.Proportion("PoisonIchor") / 100 + 1 + "d100").Roll()); Event @event = Event.New("TakeDamage"); @event.SetParameter("Attribute", "Poison"); @event.SetParameter("Damage", value); @event.SetParameter("Owner", Liquid.ParentObject); @event.SetParameter("Attacker", Liquid.ParentObject); @event.SetParameter("Message", "from {{poisonous|drinking poison ichor}}!"); @event.SetParameter("Phase", Target.GetPhase()); Target.FireEvent(@event); ExitInterface = true; return(true); }
public override bool PouredOn(LiquidVolume Liquid, GameObject GO) { if (Liquid.ComponentLiquids.Count != 1) { return(true); } if (Liquid.Volume > 0 && GO.HasPart("Stomach") && GO.HasPart("Body") && GO.GetIntProperty("Inorganic") == 0 && GO.HasStat("Toughness")) { BodyPart p = GO.GetPart <Body>()._Body.GetParts().GetRandomElement(); BodyPart p2 = GO.GetPart <Body>()._Body.GetParts().GetRandomElement(); p2.AddPart(p.DeepCopy(GO, GO.GetPart <Body>())); GO.Statistics["Toughness"].Penalty += 3; IPart.AddPlayerMessage(GO.The + GO.DisplayNameOnly + "'s " + p2.Name + " sprout" + (p2.Plural?"":"s") + " " + (p.Plural?"":"a ") + p.Name + "!"); } return(true); }
public override void ObjectEnteredCell(LiquidVolume Liquid, ObjectEnteredCellEvent E) { var go = E.Object; if (Liquid.IsOpenVolume() && go.HasPart("Body")) { go.Move(E.Direction, true, EnergyCost: 0); go.ParticleText("!", 'B', false, 1.5f, -8f); IPart.XDidYToZ( what: go, verb: "slip", preposition: "on", obj: Liquid.ParentObject, terminalPunctuation: "!" ); } }
public override void RenderPrimary(LiquidVolume Liquid, RenderEvent eRender) { if (!Liquid.IsWadingDepth()) { return; } if (Liquid.ParentObject.IsFrozen()) { eRender.RenderString = "~"; eRender.ColorString = "&M^g"; return; } Render pRender = Liquid.ParentObject.pRender; int num = (XRLCore.CurrentFrame + Liquid.nFrameOffset) % 60; if (Stat.RandomCosmetic(1, 600) == 1) { eRender.RenderString = "\u000f"; eRender.ColorString = "&M^g"; } if (Stat.RandomCosmetic(1, 60) == 1) { if (num < 15) { pRender.RenderString = "÷"; pRender.ColorString = "&M^g"; } else if (num < 30) { pRender.RenderString = "~"; pRender.ColorString = "&M^g"; } else if (num < 45) { pRender.RenderString = "\t"; pRender.ColorString = "&M^g"; } else { pRender.RenderString = "~"; pRender.ColorString = "&M^g"; } } }
public void Water(GameObject who) { LiquidVolume volume = ParentObject.GetPart <LiquidVolume>(); if (volume == null || volume.Volume <= 0) { Popup.Show(ParentObject.The + ParentObject.DisplayNameOnly + " is empty."); return; } //IPart.AddPlayerMessage("startwater"); List <Cell> list = PickFieldAdjacent(9, who, "Water").Where(b => b.IsPassable(null, false)).ToList(); //List<Cell> list = PickBurst(1,3,false,AllowVis.OnlyVisible); //IPart.AddPlayerMessage("picked"); if (list == null) { //IPart.AddPlayerMessage("none"); return; } //IPart.AddPlayerMessage("do"); int PourAmount = (int)Math.Max(1, Math.Floor((double)(ParentObject.GetPart <LiquidVolume>().Volume / list.Count))); string getamount = Popup.AskString("How many drams each?", PourAmount.ToString(), 3, 1, "0123456789"); PourAmount = Int32.Parse(getamount); foreach (Cell item in list) { //IPart.AddPlayerMessage("cell"); if (item.IsPassable(null, false)) { if (volume == null || volume.Volume <= 0) { Popup.Show(ParentObject.The + ParentObject.DisplayNameOnly + " has run dry."); return; } acegiak_Seed.DoWater(who, ParentObject, item, PourAmount); //IPart.AddPlayerMessage("pour"); //volume.PourIntoCell(ParentObject, item,1); } } }
public override void ObjectEnteredCell(LiquidVolume Liquid, XRL.World.GameObject GO) { if (Liquid.MaxVolume != -1 || !GO.HasPart("Body") || !GO.PhaseAndFlightMatches(Liquid.ParentObject) || Liquid.Volume > 1000) { return; } int num = 10 + (int)((double)(Liquid.ComponentLiquids[this.ID] * 5) / 1000.0); if (!GO.MakeSave("Agility", num, null, null, "Dye")) { if (GO.IsPlayer()) { MessageQueue.AddPlayerMessage("&CYou get covered in " + ColorNames[this.Color] + " dye!"); } GO.pRender.TileColor = "&" + this.Color; GO.pRender.ColorString = "&" + this.Color; GO.pRender.DetailColor = ToggleCase(this.Color); } }