public Schedule(string plantsAreaId, int timeout, int actionDuration, Plant plantRequirements) { Timeout = timeout; ActionDuration = actionDuration; PlantRequirements = plantRequirements; PlantsAreaId = plantsAreaId; }
public void DoPlanting(Plant plant) { plant.PercentPlanted += GetPlantingCompletionIncrement (); if (plant.PercentPlanted > 100) plant.PercentPlanted = 100; }
public void DoPlanting() { if (Person.Activity.Type == ActivityType.Gardening) { var tile = Person.Tile; var plant = (Plant)Person.Activity.Target; if (plant == null) { plant = new Plant (PlantType.Vegetable); throw new NotImplementedException (); //plant.TimePlanted = Clock.GameDuration; plant.WasPlanted = true; var plants = new List<Plant> (tile.Plants); plants.Add (plant); tile.Plants = plants.ToArray (); } DoPlanting (plant); if (plant.PercentPlanted >= 100) { tile.TotalVegetablesPlanted++; Finish(); throw new NotImplementedException (); //PlayerLog.WriteLine (CurrentEngine.Id, "A vegetable seedling has been planted."); } else { DoPlanting (plant); } } }
public void ChangePlant(Plant plant) { if (plant != Plant.None) { clickfx.PlayOneShot(clickfx.clip); } active = plant; }
public void IncreaseToSpecificStage(Plant.stageEnum stage, bool hasFlowers = false, bool hasProducts = false){ plantStage = stage; switch(stage){ case Plant.stageEnum.germination: germinationPrefab = (GameObject)Instantiate(GameModel.Instance.germination, transform.position, Quaternion.Euler(-90, 0, 0)); germinationPrefab.transform.SetParent(transform); break; case Plant.stageEnum.growth: AddGrowth(); break; case Plant.stageEnum.pollination: if(hasFlowers) AddPollination(); break; case Plant.stageEnum.product: if(hasFlowers) AddPollination(); if(hasProducts) AddProduct(); break; default: break; } }
public static void IncreaseProductNumber(Plant plant, bool inc){ if(inc) plant.productNumber++; else plant.productNumber--; plant.plantBtn.GetComponent<BtnPlant>().RefreshInventory(); }
public PlantViewModel(Plant plant, JupiterViewModel JVM) { jVM = JVM; this.plant = plant; Name = plant.Name; ID = plant.IDNumber; }
//For testing purposes we print out plant species public string onLeftMouseDown(Seed playerSeed, Plant playerPlant) { if(occupied) { return "Space is occupied!"; // Call remove function? } //If player is holding seed, set it. else if(playerSeed) { currentSeed = playerSeed; occupied = true; currentSeed.GetComponent<Seed>().currentSpace = this.gameObject.GetComponent<Plantable_Space>(); //Spawn GameObject of Seed return "Planted " + playerSeed.species; } //Else if holding a plant, set that. else if(playerPlant) { currentPlant = playerPlant; occupied = true; currentPlant.GetComponent<Plant>().currentSpace = this.gameObject.GetComponent<Plantable_Space>(); return "Planted " + playerPlant.species; } else { //Player has no plant or seed selected in inventory, nothing happens. return null; } }
private void afterDeserialization(StreamingContext context) { Plant = Cache.Instance.Plants[plantId]; if (Cache.Instance is ClientCache) { Plant.ReproductionSteps[ID] = this; } }
public virtual bool Apply(Plant plant) { flashTimer.Start(); plant.CurrentAnimation.Color = GMath.GammaBlend(plant.CurrentAnimation.Color, Color.Red, 0.5f); plant.DecreaseHP(this.Damage); return true; }
static void Main(string[] args) { Console.Title = "种植不同种类的水果"; Plant plant = new Plant(); plant.PlantAppleOrange(); //北京果园种植苹果和桔子 plant.PlantOrangeBanana (); //上海果园种植桔子和香蕉 Console.Read(); }
public void ResetCycle(Parcel thisParcel, Plant plant){ ResetParcel(thisParcel); GameObject newPlant = Instantiate(GameModel.Instance.plantPrefab) as GameObject; thisParcel.mesh = GameModel.Instance.seedling; newPlant.transform.SetParent(thisParcel.transform, false); newPlant.GetComponent<PlantPrefab>().plant = plant; }
public int EatPlant(Plant plant) { if (plant != null) { this.Size++; return plant.GetEatenQuantity(2); } return 0; }
void world_PlantEaten(object sender, IAgent eater, Plant eaten) { // Only update the observed reward if it was a result of our action if (eater != this) return; // If we receive a reward for taking a step, record it reward += eaten.Reward; }
public int EatPlant(Plant p) { if (p != null) { return p.GetEatenQuantity(this.biteSize); } return 0; }
private int GetCurrentPlant (Plant plant) { for(int i = 0; i < plants.Length; i++) { if(plants[i] == plant) return i; } return 1; }
public int EatPlant(Plant plant) { if (plant != null) { this.Size += 1; return plant.GetEatenQuantity(this.biteSize); } return 0; }
public int EatPlant(Plant plant) { int quantityEaten = 0; if (plant != null) { quantityEaten = plant.GetEatenQuantity(this.biteSize); base.Size++; } return quantityEaten; }
public void DoPlanting(Plant plant) { if (plant.PercentPlanted < 100) { plant.PercentPlanted += PlantingIncrement; } if (plant.PercentPlanted >= 100) { plant.PercentPlanted = 100; plant.WasPlanted = true; } }
public int EatPlant(Plant plant) { if (plant != null) { var quantityEaten = 0; quantityEaten = plant.GetEatenQuantity(BoarBiteSize); this.Size++; return quantityEaten; } return 0; }
public Plant CreatePlant(Plant plant) { using (var database = new Core.Entity.SeedsEntities()) { var entity = plant.ToEntity(database); entity.ID = database.Plant.Execute(MergeOption.NoTracking).Any() ? database.Plant.Execute(MergeOption.NoTracking).Max(p => p.ID) + 1 : 0; database.AddToPlant(entity); database.SaveChanges(); var result = new Plant(database.Plant.Execute(MergeOption.NoTracking).Single(p => p.ID == entity.ID), true); result.UpdateParent(); Cache.Instance.Plants[result.ID] = result; return result; } }
public override bool Test(Sim a, Plant target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { MagicControl control = MagicControl.GetBestControl(a, this); if (control == null) { greyedOutTooltipCallback = Common.DebugTooltip("No Control"); return false; } if (((target is OmniPlant) || (target is MoneyTree)) && (target.GrowthState >= PlantGrowthState.Mature)) { return false; } return (target.mGrowthState != PlantGrowthState.Harvest); }
// 난수 생성 오브젝트를 만든다. public Plant createPlant(string id, int cycle = 16) { Plant plant = null; do { Seed seed = this.create_seed(id); if(seed == null) { break; } plant = new Plant(seed, cycle); } while(false); return(plant); }
public ChangeDescription AddIntakeToPlant(PumpingIntake Intake, Plant plant) { ChangeDescription change = GetGenericPlantIntake(); change.Action = TableAction.InsertRow; change.ChangeValues.Add(new Change("PLANTID", plant.IDNumber.ToString(), "")); change.ChangeValues.Add(new Change("BOREHOLENO", Intake.Intake.well.ID, "")); change.ChangeValues.Add(new Change("INTAKENO", Intake.Intake.IDNumber.ToString(), "")); if (Intake.StartNullable.HasValue) change.ChangeValues.Add(new Change("STARTDATE", Intake.StartNullable.Value.ToShortDateString(), "")); if (Intake.EndNullable.HasValue) change.ChangeValues.Add(new Change("ENDDATE", Intake.EndNullable.Value.ToShortDateString(), "")); return change; }
static void Main() { Plant thePlant = new Plant( int.Parse(Console.ReadLine()), // reads the plant's coordinates: Px1, int.Parse(Console.ReadLine()), // Py1, int.Parse(Console.ReadLine()), // Px2, int.Parse(Console.ReadLine()) // Py2 (and sort them!) ); int Fx = int.Parse(Console.ReadLine()); // reads the x coordinate of a fighter int Fy = int.Parse(Console.ReadLine()); // reads the y coordinate of a fighter int Dist = int.Parse(Console.ReadLine()); // reads the missale distance int damage = 0; damage += (thePlant.Damage(Fx + Dist, Fy)) ? 100 : 0; // if missle's main target is inside the plant - 100% damage damage += (thePlant.Damage(Fx + Dist, Fy - 1)) ? 50 : 0; // if missle's target to the left of main is inside the plant - 50% damage damage += (thePlant.Damage(Fx + Dist, Fy + 1)) ? 50 : 0; // if missle's target to the right of main is inside the plant - 50% damage damage += (thePlant.Damage(Fx + Dist + 1, Fy)) ? 75 : 0; // if missle's target one cell forward of main is inside the plant - 75% damage Console.WriteLine("{0}%", damage); }
public bool addPlantableObject(GameObject obj) { if (occupied) return false; obj.transform.parent = transform; Plant plant; Seed seed; if ((plant = obj.GetComponent<Plant>()) != null) { currentPlant = plant; currentPlant.currentSpace = this; } else if ((seed = obj.GetComponent<Seed>()) != null) { currentSeed = seed; currentSeed.currentSpace = this; } occupied = true; return true; }
public void PlantOnFront() { var expectedCarnivoreInputs = TrainingCamp.CreateInputs(plantsOnProximity: 1); var landscape = Landscape.CreateForTest(); var carnivore = new Agent(AgentType.Carnivore); carnivore.Direction = Direction.East; carnivore.Location = new Location(0, 2); landscape.Agents[0] = carnivore; landscape.SetAgentInPosition(carnivore); var plant = new Plant(); plant.Location = new Location(1, 3); landscape.Plants[0] = plant; landscape.SetPlantToPosition(plant); landscape.UpdatePerception(carnivore); carnivore.Inputs.ShouldBeEqualTo(expectedCarnivoreInputs); }
/// <summary> /// 将单元列表转换成 /// </summary> /// <param name="plants"></param> /// <returns></returns> private IList <TypeDeviceVO> convertToSDeviceVOs(IList <Device> devices, Plant plant) { string apath = Request.Url.AbsolutePath; string auri = Request.Url.AbsoluteUri; string devicePicBaseWebappUrl = auri.Substring(0, auri.IndexOf(apath)) + "/devicepic"; IList <TypeDeviceVO> splants = new List <TypeDeviceVO>(); IDictionary <string, IList <SimpleDeviceVO> > typeDic = new Dictionary <string, IList <SimpleDeviceVO> >(); SimpleDeviceVO sdvo = null; foreach (Device device in devices) { sdvo = new SimpleDeviceVO(); sdvo.deviceId = device.id; sdvo.deviceModel = (device.name != null && device.name.IndexOf("#") > -1) ? device.name.Substring(0, device.name.IndexOf("#")) : device.xinhaoName; sdvo.deviceType = device.typeName; if (device.deviceTypeCode == DeviceData.ENVRIOMENTMONITOR_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_SUNLINGHT); sdvo.displayField = mt.name + ":" + device.Sunlight + " " + mt.unit; } else if (device.deviceTypeCode == DeviceData.HUILIUXIANG_CODE || device.deviceTypeCode == DeviceData.CABINET_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_TOTALCURRENT); float totalCurrent = device.runData == null ? 0 : device.runData.getMonitorValue(MonitorType.MIC_BUSBAR_TOTALCURRENT); sdvo.displayField = mt.name + ":" + totalCurrent + " " + mt.unit; } else if (device.deviceTypeCode == DeviceData.AMMETER_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_AMMETER_POSITIVEACTIVEPOWERDEGREE); double totalCurrent = device.getMonitorValue(MonitorType.MIC_AMMETER_POSITIVEACTIVEPOWERDEGREE); sdvo.displayField = mt.name + ": " + totalCurrent + mt.unit; } else { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALYGPOWER); sdvo.displayField = mt.name + ":" + device.TotalPower + " " + mt.unit; } sdvo.workStatus = (device.Over1Day(plant.timezone) ? 0 : 1).ToString();//超过一天无数据为不工作,工作返回1 不工作返回0 sdvo.address = device.deviceAddress; sdvo.pic = devicePicBaseWebappUrl + "/devicepic_31.gif"; int stoptime = device.stopTime(0); sdvo.displayStatus = (stoptime > 24 ? 3 : (stoptime > 1 ? 2 : 1)).ToString(); sdvo.lastUpdatedTime = device.lastUpdateTime; IList <SimpleDeviceVO> deviceVoList = null; if (!typeDic.ContainsKey(device.typeName)) { deviceVoList = new List <SimpleDeviceVO>(); } else { deviceVoList = typeDic[device.typeName]; } deviceVoList.Add(sdvo); typeDic[device.typeName] = deviceVoList; } TypeDeviceVO tdvo = null; foreach (string key in typeDic.Keys) { tdvo = new TypeDeviceVO(); tdvo.type = key; tdvo.devices = typeDic[key]; splants.Add(tdvo); } return(splants); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_JobTransforms.MoveCurrentTargetIntoQueue(TargetIndex.A)); Toil initExtractTargetFromQueue = Toils_JobTransforms.ClearDespawnedNullOrForbiddenQueuedTargets(TargetIndex.A, (RequiredDesignation == null) ? null : new Func <Thing, bool>((Thing t) => Map.designationManager.DesignationOn(t, RequiredDesignation) != null)); yield return(initExtractTargetFromQueue); yield return(Toils_JobTransforms.SucceedOnNoTargetInQueue(TargetIndex.A)); yield return(Toils_JobTransforms.ExtractNextTargetFromQueue(TargetIndex.A, true)); Toil gotoThing = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch).JumpIfDespawnedOrNullOrForbidden(TargetIndex.A, initExtractTargetFromQueue); if (RequiredDesignation != null) { gotoThing.FailOnThingMissingDesignation(TargetIndex.A, RequiredDesignation); } yield return(gotoThing); Toil cut = new Toil(); cut.tickAction = delegate { Pawn actor = cut.actor; Job curJob = actor.jobs.curJob; curJob.expiryInterval = -1; float statValue = actor.GetStatValue(StatDefOf.PlantWorkSpeed, true); float num = statValue; Plant plant = Plant; num *= Mathf.Lerp(3.3f, 1f, plant.Growth); workDone += num; if (workDone >= plant.def.plant.harvestWork) { if (plant.def.plant.harvestedThingDef != null) { int num2 = plant.YieldNow(); if (num2 > 0) { Thing thing = ThingMaker.MakeThing(plant.def.plant.harvestedThingDef, null); thing.stackCount = num2; if (actor.Faction != Faction.OfPlayer) { thing.SetForbidden(true, true); } GenPlace.TryPlaceThing(thing, actor.Position, Map, ThingPlaceMode.Near, null, null); } } plant.def.plant.soundHarvestFinish.PlayOneShot(actor); plant.PlantCollected(); workDone = 0f; ReadyForNextToil(); return; } }; cut.FailOnDespawnedNullOrForbidden(TargetIndex.A); if (RequiredDesignation != null) { cut.FailOnThingMissingDesignation(TargetIndex.A, RequiredDesignation); } cut.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); cut.defaultCompleteMode = ToilCompleteMode.Never; cut.WithEffect(EffecterDefOf.Harvest, TargetIndex.A); cut.WithProgressBar(TargetIndex.A, () => workDone / Plant.def.plant.harvestWork, true, -0.5f); cut.PlaySustainerOrSound(() => Plant.def.plant.soundHarvesting); cut.activeSkill = (() => SkillDefOf.Plants); yield return(cut); Toil plantWorkDoneToil = PlantWorkDoneToil(); if (plantWorkDoneToil != null) { yield return(plantWorkDoneToil); } yield return(Toils_Jump.Jump(initExtractTargetFromQueue)); }
public override void Generate(Map map) { //Log.Error("running"); List <ThingDef> source = (from x in DefDatabase <ThingDef> .AllDefsListForReading where x.category == ThingCategory.Plant && x.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>() != null && x.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>().allowedBiomes.Contains(map.Biome.defName) select x).ToList <ThingDef>(); //Log.Error("1"); if (source == null || source.Count == 0) { return; } //Log.Error(source[0].defName); foreach (IntVec3 c in map.AllCells) { ThingDef source2 = source[Rand.RangeInclusive(0, source.Count - 1)]; if (c.GetEdifice(map) == null && c.GetCover(map) == null && c.GetFirstBuilding(map) == null) { if (source2.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>().allowedTiles.Contains(c.GetTerrain(map))) { if (Rand.Chance(source2.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>().spawnChance)) { Plant plant = (Plant)ThingMaker.MakeThing(source2, null); plant.Growth = Rand.Range(0.07f, 1f); if (plant.def.plant.LimitedLifespan) { plant.Age = Rand.Range(0, Mathf.Max(plant.def.plant.LifespanTicks - 50, 0)); } GenSpawn.Spawn(plant, c, map); } } else { if (source2.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>().growNearWater) { bool flag = false; for (int i = c.x - 1; i < c.x + 2; i++) { for (int j = c.z - 1; j < c.z + 2; j++) { IntVec3 temp = new IntVec3(i, 0, j); if (temp.InBounds(map) && source2.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>().allowedTiles.Contains(temp.GetTerrain(map)) && !isWater(temp, map) && !(temp.GetTerrain(map).defName == "Marsh")) { if (Rand.Chance(source2.GetCompProperties <RimWorldBiomesCore.CompProperties_WaterPlant>().spawnChance)) { Plant plant = (Plant)ThingMaker.MakeThing(source2, null); plant.Growth = Rand.Range(0.07f, 1f); if (plant.def.plant.LimitedLifespan) { plant.Age = Rand.Range(0, Mathf.Max(plant.def.plant.LifespanTicks - 50, 0)); } GenSpawn.Spawn(plant, c, map); flag = true; } } if (flag) { break; } } if (flag) { break; } } } } } } }
public void ThenTemp() { Plant plant = new Plant(new LSystem(new RuleSet(new Dictionary <string, List <LSystemRule> > { { "A", new List <LSystemRule> { new LSystemRule { Rule = "![AFAFF]LF\\S", Probability = 1 } } }, { "L", new List <LSystemRule> { new LSystemRule { Rule = "[OO&-O-O]&O^O", Probability = 1 } } }, { "S", new List <LSystemRule> { new LSystemRule { Rule = "!&+[+F^A[!-&!\\F]]!F", Probability = 1 } } }, { "F", new List <LSystemRule> { new LSystemRule { Rule = "-[^FAL-L]L+F", Probability = 1 } } } }), "A"), new TurtlePen(new NullRenderSystem()) { BranchReductionRate = new MinMax <float> { Max = 0.8f, Min = 0.8f }, ForwardStep = 0.1f, RotationStep = 22.5f, BranchDiameter = 0.1f }, new PersistentPlantGeometryStorage(), Vector3.zero, Color.white); for (int i = 0; i < 4; ++i) { plant.Update(); } plant.Generate(); PlantFitness fitnessEval = new PlantFitness(new LeafFitness(new SunInformation { Azimuth = 240, WinterAltitude = 30, SummerAltitude = 60, Light = Color.green })); float fitness = fitnessEval.EvaluateFitness(plant); Debug.Log(fitness); Debug.Log("Leaf Fitness: " + plant.Fitness.LeafEnergy); }
public static float TicksUntilFullyGrown(this Plant plant) { return((int)typeof(Plant).GetProperty("TicksUntilFullyGrown", Harmony.AccessTools.all).GetValue(plant, null)); }
public void AddPlant(Plant newPlant) { _allActivePlants.Add(newPlant); // Assume plant is not already in the list. }
public CreateReportViewModel(Plant plant, User user) { Plant = plant; User = user; }
public static float GrowthPerTick(this Plant plant) { return((int)typeof(Plant).GetProperty("GrowthPerTick", Harmony.AccessTools.all).GetValue(plant, null)); }
public override void SetValue(object value) { mValue = (Plant)value; }
private bool lonerStep() { if (payoff > 0) { List <Entity> nearplants = parentEnvironment.getNeighborsOfType(x, y, new Plant(parentEnvironment)); base.setImg("caveman"); if (nearplants.Count > 0) { bool hasEaten = false; foreach (Plant cPlant in nearplants) { if (cPlant.Value > 0) { cPlant.Value -= foodPerStep; hasEaten = true; if (cPlant.Value < 0) { cPlant.Value = 0; } break; } else { } } if (hasEaten) { base.setImg("caveman_eating"); payoff += foodPerStep; //increase payoff by 10 prevGoal = null; prevDistance = 1e9; } } else { DateTime dt = DateTime.Now; Plant nearplant = getNearestMammothFreePlant(); if (nearplant == null) { nearplant = (Plant)parentEnvironment.getNearestInLOS(x, y, new Plant(parentEnvironment)); } int ms = DateTime.Now.Second * 1000 + DateTime.Now.Millisecond - dt.Second * 1000 - dt.Millisecond; bool success = false; if (prevGoal != null) { if (parentEnvironment.get(prevGoal.x, prevGoal.y) == null || !(parentEnvironment.get(prevGoal.x, prevGoal.y) is Plant) || prevGoal.visible == false) { prevGoal = null; prevDistance = 1e9; } } if (nearplant != null || prevGoal != null) { if (prevGoal == null || nearplant != null && parentEnvironment.getDistance(x, y, nearplant.x, nearplant.y) < prevDistance - 2) { prevGoal = nearplant; prevDistance = parentEnvironment.getDistance(x, y, nearplant.x, nearplant.y); } //get direction with greatest distance gain to plant int mindx = 0, mindy = 0; double mindist = prevDistance; parentEnvironment.getBestDirection(this, prevGoal, ref mindx, ref mindy, ref mindist); if (mindist < prevDistance) { success = parentEnvironment.move(this, x + mindx, y + mindy); } } } } return(true); }
public void Import(string filePath, string sheetName) { using (var stream = File.OpenRead(filePath)) { var workbook = new XSSFWorkbook(stream); var sheet = workbook.GetSheet(sheetName); for (var i = 1; i < sheet.LastRowNum + 1; i++) { var row = sheet.GetRow(i); if (!isValidRow(row, i)) { break; } var dbSector = _repository.FindBy <Sector>(s => s.Name == _plantRow.Sector) .FirstOrDefault(); if (dbSector == null) { dbSector = new Sector { Name = _plantRow.Sector }; _repository.Add(dbSector); _repository.Save(); } var dbBusinessUnit = _repository.FindBy <BusinessUnit>(bu => bu.Name == _plantRow.BusinessUnit && bu.SectorId == dbSector.Id) .FirstOrDefault(); if (dbBusinessUnit == null) { dbBusinessUnit = new BusinessUnit { Name = _plantRow.BusinessUnit, SectorId = dbSector.Id }; _repository.Add(dbBusinessUnit); _repository.Save(); } var dbSOA = _repository.FindBy <SOA>(soa => soa.Name == _plantRow.SOA && soa.BusinessUnitId == dbBusinessUnit.Id) .FirstOrDefault(); if (dbSOA == null) { dbSOA = new SOA { Name = _plantRow.SOA, BusinessUnitId = dbBusinessUnit.Id }; _repository.Add(dbSOA); _repository.Save(); } var dbDelegation = _repository.FindBy <Delegation>(d => d.Name == _plantRow.Delegation) .FirstOrDefault(); if (dbDelegation == null) { dbDelegation = new Delegation { Name = _plantRow.Delegation }; _repository.Add(dbDelegation); _repository.Save(); } var dbCountry = _repository.FindBy <Country>(c => c.Name == _plantRow.Country && c.DelegationId == dbDelegation.Id) .FirstOrDefault(); if (dbCountry == null) { dbCountry = new Country { Name = _plantRow.Country, DelegationId = dbDelegation.Id }; _repository.Add(dbCountry); _repository.Save(); } var dbPlant = _repository.FindBy <Plant>(p => p.GaiaCode == _plantRow.GaiaCode) .FirstOrDefault(); if (dbPlant == null) { dbPlant = new Plant { Name = _plantRow.PlantName, GaiaCode = _plantRow.GaiaCode, CountryId = dbCountry.Id, SOAId = dbSOA.Id, }; _repository.Add(dbPlant); } else { dbPlant.Name = _plantRow.PlantName; dbPlant.SOAId = dbSOA.Id; dbPlant.CountryId = dbCountry.Id; _repository.Update(dbPlant); } _repository.Save(); System.Console.WriteLine($"Line {i} imported."); } } }
public WaterPlantSuccess(Plant plant) : base(true, "") { base.Plant = plant; }
public IActionResult Put([FromBody] Plant plant) { _context.Plants.Update(plant); _context.SaveChanges(); return(Ok()); }
static bool Prefix(ref Plant __instance, Pawn ingester, float nutritionWanted, out int numTaken, out float nutritionIngested) { if (/*__instance.def.plant.harvestYield <= 0 ||*/ __instance.def.plant.harvestedThingDef != null && !__instance.def.plant.harvestedThingDef.IsNutritionGivingIngestible) { numTaken = 0; nutritionIngested = 0f; return(true); } float maxAmount = 0; float needAmount = 0; float harvestYield = 0; float nutrition = 0; bool hasyield = __instance.def.plant.harvestYield > 0 && __instance.def.plant.harvestedThingDef != null; if (hasyield) { harvestYield = __instance.def.plant.harvestYield; nutrition = __instance.def.plant.harvestedThingDef.ingestible.CachedNutrition; maxAmount = RoundUp(harvestYield * Mathf.Lerp(0.5f, 1f, __instance.HitPoints / __instance.MaxHitPoints)); } else { harvestYield = 100; nutrition = __instance.GetStatValue(StatDefOf.Nutrition, false) / harvestYield * Settings.Multiplier; if (__instance.def.plant.HarvestDestroys) { maxAmount = RoundUp(harvestYield * Mathf.Lerp(0.5f, 1f, __instance.HitPoints / __instance.MaxHitPoints)); } else { maxAmount = RoundUp(harvestYield * __instance.Growth); } } needAmount = RoundUp(nutritionWanted / nutrition); if (__instance.def.plant.HarvestDestroys) { maxAmount = Mathf.Min(maxAmount, needAmount); nutritionIngested = maxAmount * nutrition; float potentialDamage = Mathf.Lerp(0f, 1f, maxAmount / harvestYield); potentialDamage = __instance.MaxHitPoints * potentialDamage * Settings.YieldDamage; if (__instance.HitPoints - potentialDamage <= 0) { numTaken = 1; } else { numTaken = 0; __instance.TakeDamage(new DamageInfo(DamageDefOf.Bite, potentialDamage, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); } } else { numTaken = 0; if (hasyield) { maxAmount = Mathf.Min(maxAmount, needAmount * Settings.YieldDamage); nutritionIngested = maxAmount / Settings.YieldDamage * nutrition; } else { maxAmount = Mathf.Min(maxAmount, needAmount); nutritionIngested = maxAmount * nutrition; } float potentialDamage = Mathf.Lerp(0f, 1f, maxAmount / harvestYield); __instance.Growth -= potentialDamage; if (__instance.Growth < 0.08f) { if (!hasyield && Settings.ConsumeChance > 0) { if (Settings.ConsumeChance == 100) { numTaken = 1; } else { Random r = new Random(); int val = Random.Range(1, 100); if (val <= Settings.ConsumeChance) { numTaken = 1; } } } if (numTaken == 0) { __instance.Growth = 0.08f; } } if (__instance.Spawned) { __instance.Map.mapDrawer.MapMeshDirty(__instance.Position, MapMeshFlag.Things); } } return(false); }
public PerenneGarden() { shade = new Plant("Ajo"); border = new Plant("Fresa"); center = new Plant("Romero"); }
public EditPlantDialog(SensorDataModel model, Plant plant) { Model = model; PlantModel = plant; InitializeComponent(); }
public void Run() { Init(); IList <Fault> faults = null; foreach (ReportConfig config in eventConfigs) { if (string.IsNullOrEmpty(config.email)) { Console.WriteLine("event report email is empty!"); continue; } //if ((DateTime.Now - config.lastSendTime).TotalMinutes < 30) // continue; Plant plant = PlantService.GetInstance().GetPlantInfoById(config.plantId); if (plant == null) { continue; } Console.WriteLine("start handle event report of " + plant.name + " last send time is :" + config.lastSendTime); //取出lastSendTime时间之后的日志 faults = LoadEventLogs(config.plantId, config.lastSendTime); //Console.WriteLine("fault count is :"+faults.Count); //if (faults == null || faults.Count < logLength) if (faults == null || faults.Count == 0) { continue; } string lang = "en-us"; User user = UserService.GetInstance().Get(int.Parse(config.sendMode)); if (user != null && user.Language != null && string.IsNullOrEmpty(user.Language.codename) == false) { lang = user.Language.codename.ToLower(); } Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang); int count = faults.Count; int index = 0; Console.WriteLine("start handle " + faults.Count + " fault"); while (true) { IList <Fault> temp = null; if (count >= logLength * (index + 1)) { temp = faults.Skip((index * logLength)).Take(logLength).ToList <Fault>(); index++; //Console.WriteLine("count >50 "); } else { temp = faults.Skip(index * logLength).Take((count % logLength)).ToList <Fault>(); // Console.WriteLine("get "+temp.Count+" record"); } EmailQueue queue = new EmailQueue(); object[] resArr = BulidContent(plant.name, temp, config.sendFormat == null ? "html" : config.sendFormat); queue.content = (string)resArr[0]; if (string.IsNullOrEmpty(queue.content)) { //Console.WriteLine("queue.content is empty "); continue; } //Console.WriteLine("put .content into queue "); queue.receiver = config.email; queue.state = 0; queue.title = plant.name + " event report " + CalenderUtil.formatDate(DateTime.Now, "yyyy-MM-dd"); queue.sender = "*****@*****.**"; if (Save(queue)) { Console.WriteLine(string.Format("a event report has been created {0}", DateTime.Now)); } else { Console.WriteLine("fail insert"); } config.lastSendTime = (DateTime)resArr[1];//将最近的一个日志时间作为上次处理时间,后续再从这个时间之后的日志处理 Thread.Sleep(1000); if (faults.Last().id.Equals(temp.Last().id)) { UPdateReportLastSendTime(config); break; } } } }
public void RemovePlant(Plant plant) { _allActivePlants.Remove(plant); }
public AnalyzePrice GetPrice(Plant plant, AnalyzeWork work) { var workPrices = Prices.Where(p => p.Work == work).ToList(); while (plant != null) { var result = workPrices.FirstOrDefault(p => p.Plant == plant); if (result != null) { return result; } else { plant = plant.Parent; } } return null; }
public static bool HasGroup(Plant plant) { var comp = plant.Map.GetComponent <MapCompGrowthSync>(); return(comp.allPlantsInGroup.Contains(plant)); }
// ��� ������� ������ ������������: �����, ��� �����, ������ � ������� � ������� ������ private void GetCurrentCellInfo(out Plant CurrentPlant, out ReportPart CurrentPart, out DataRow CurrentRow, out BookColumn CurrentBookColumn) { // ���� �����, ������ ������� �������� CurrentPlant = null; CurrentPart = null; CurrentBookColumn = null; CurrentRow = null; foreach (ReportPart part in Parts) { CurrentRow = part.GetDataRow(FM.CurrentRow); if (CurrentRow != null) { CurrentPart = part; if (CurrentPart.Data != null && CurrentPart.Data.Rows.Count > 0) CurrentPlant = plants.FindPlant(Convert.ToInt32(CurrentPart.Data[0, "plantid"])); break; } } // ���� ���������� ������� if (CurrentPart != null) CurrentBookColumn = CurrentPart.DynamicColumns.Search(FM.CurrentColumn); }
//回合结束时进行资源结算 public void RoundConsume() { if (Lose()) { } float totalO2Consume = 0; float totalCO2Consume = 0; float totalO2Produce = 0; float totalCO2Produce = 0; float totalSunProduce = 0; float totalMoonProduce = 0; float O2CO2TotalRate = 0; O2CO2Rate = O2 / CO2; plantList = GetAllPlant(); GameObject sun = GameObject.Find("sun"); GameObject moon = GameObject.Find("moon"); foreach (GameObject i in plantList) { Plant p = i.GetComponent <Plant>(); float[] sunMoonBuff = SunMoonEffect(sun, moon, i); //被感染的植物要减血, 减到0销毁植物 if (p.infected) { if (p.HpDown()) { switch (GardenMap.mapstate[p.GetPoint().GetX(), p.GetPoint().GetY()]) { case 7: GardenMap.mapstate[p.GetPoint().GetX(), p.GetPoint().GetY()] = 1; break; case 8: GardenMap.mapstate[p.GetPoint().GetX(), p.GetPoint().GetY()] = 2; break; case 9: GardenMap.mapstate[p.GetPoint().GetX(), p.GetPoint().GetY()] = 3; break; default: GardenMap.mapstate[p.GetPoint().GetX(), p.GetPoint().GetY()] = 6; break; } Destroy(i); bugController.GetComponent <BugController>().removeBug(p.GetPoint()); } } if (p.live) { totalO2Consume = totalO2Consume + p.O2Cost; totalCO2Consume = totalCO2Consume + p.CO2Cost; totalO2Produce = totalO2Produce + p.GetO2Produce(O2CO2Rate) * sunMoonBuff[2]; totalCO2Produce = totalCO2Produce + p.GetCO2Produce(O2CO2Rate) * sunMoonBuff[3]; if (round % p.produceCD == 0) { totalSunProduce = totalSunProduce + p.GetSunProduce(O2CO2Rate) * sunMoonBuff[0]; totalMoonProduce = totalMoonProduce + p.GetMoonProduce(O2CO2Rate) * sunMoonBuff[1]; } } } O2 = O2 - totalO2Consume + totalO2Produce; CO2 = CO2 - totalCO2Consume + totalCO2Produce; sunPower = sunPower + totalSunProduce; moonPower = moonPower + totalMoonProduce; O2CO2TotalRate = O2 / (O2 + CO2); GameObject.Find("Main Camera").GetComponent <UIControl>().ChangeSunMoon(sunPower, moonPower); GameObject.Find("Main Camera").GetComponent <UIControl>().ChangeAir(O2CO2TotalRate); //Debug.Log("O2:" + O2.ToString()); //Debug.Log("CO2:" + CO2.ToString()); //Debug.Log("SunPower:" + sunPower.ToString()); //Debug.Log("MoonPower:" + moonPower.ToString()); round += 1; Move = 3; UIControl.In_Round = true; }
public void PerformStandardSetOfOperations(Part part, Plant plant) { plant.PerformOperationOnPart(part, Grind); plant.PerformOperationOnPart(part, Paint); plant.PerformOperationOnPart(part, Cast); }
public static Group GroupOf(Plant plant) { var comp = plant.Map.GetComponent <MapCompGrowthSync>(); return(comp.GroupOf(plant)); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; IntVec3 root = IntVec3Utility.ToIntVec3(rp.rect.CenterVector3); IntVec3 motherVec; CellFinder.TryFindRandomCellNear(root, map, 3, (IntVec3 x) => x.Standable(map) && map.fertilityGrid.FertilityAt(x) > ThingDefOf.Plant_Ambrosia.plant.fertilityMin, out motherVec); float eventPoints = StorytellerUtility.DefaultThreatPointsNow(Find.World) * 0.6f; if (eventPoints > 4000f) { eventPoints *= 0.9f; if (eventPoints > 7000f) { eventPoints = 7000f; } } foreach (IntVec3 vec in rp.rect) { if (map.terrainGrid.TerrainAt(vec).fertility < 0.7f) { if (Rand.Chance(0.5f)) { map.terrainGrid.SetTerrain(vec, TerrainDefOf.Gravel); } } } //spawn mother plant MotherAmbrosiaLGE motherAmbrosia = (MotherAmbrosiaLGE)GenSpawn.Spawn(DefsOfLGE.Plant_MotherAmbrosiaLGE, motherVec, map, WipeMode.Vanish); motherAmbrosia.Growth = Rand.Range(0.9f, 0.98f); PawnKindDef animalKind; (from k in map.Biome.AllWildAnimals where Find.World.tileTemperatures.SeasonAndOutdoorTemperatureAcceptableFor(map.Tile, k.race) select k).TryRandomElement(out animalKind); if (animalKind == null) { animalKind = ThingDefOfVanilla.Warg; } motherAmbrosia.SpawnAnimals(animalKind, eventPoints); int randomInRange = (int)(eventPoints / 80);//SymbolResolver_AmbrosiaAnimalsLGE.CountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { IntVec3 intVec; if (!CellFinder.TryRandomClosewalkCellNear(motherVec, map, SpawnRadius, out intVec, (IntVec3 x) => this.CanSpawnAt(x, map))) { break; } Plant plant = intVec.GetPlant(map); if (plant != null) { plant.Destroy(DestroyMode.Vanish); } Plant ambrosia = (Plant)GenSpawn.Spawn(ThingDefOf.Plant_Ambrosia, intVec, map, WipeMode.Vanish); ambrosia.Growth = Rand.Range(0.6f, 0.95f); } //Spawn ambrosia reward ResolveParams resolveParamsReward = rp; resolveParamsReward.rect = CellRect.CenteredOn(motherVec, SpawnRadius - 2); resolveParamsReward.stockpileConcreteContents = RewardGeneratorUtilityLGE.GenerateAmbrosia((int)(eventPoints / 150f)); BaseGen.symbolStack.Push("spawnStockpileLGE", resolveParamsReward); }
public override async Task Update(Plant entity) { var indexOf = LstPlants.IndexOf(LstPlants.Find(a => a.Id == entity.Id)); await Task.Run(() => LstPlants[indexOf] = entity); }
/// <summary> /// 取得设备详细信息 /// </summary> /// <param name="pid"></param> /// <returns></returns> public ActionResult Deviceinfo(int did, string lan) { setlan(lan); string data; Device device = DeviceService.GetInstance().get(did); int timezone = 0; try { PlantUnit plantUnit = PlantUnitService.GetInstance().GetPlantUnitByCollectorId(device.collectorID); Plant plant = PlantService.GetInstance().GetPlantInfoById(plantUnit.plantID); timezone = plant.timezone; } catch (Exception ee) { LogUtil.error(ee.Message); } if (device == null) { AppError appError = new AppError(AppError.devicenoexist, Resources.SunResource.CHART_DEVICE_DONT_EXISTED); data = JsonUtil.convertToJson(appError, typeof(AppError)); } else { DeviceInfoVO vo = new DeviceInfoVO(); vo.deviceId = device.id; vo.deviceModel = device.xinhaoName; vo.deviceType = device.typeName; vo.deviceName = device.fullName; vo.address = device.deviceAddress; vo.deviceTypeCode = device.deviceTypeCode.ToString(); if (device.deviceTypeCode == DeviceData.ENVRIOMENTMONITOR_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_SUNLINGHT); string str = mt.name + " :" + device.Sunlight + " " + mt.unit; mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_ENRIONMENTTEMPRATURE); float tempr = device.runData == null ? 0 : device.runData.getMonitorValue(MonitorType.MIC_DETECTOR_ENRIONMENTTEMPRATURE); str += "," + mt.name + " :" + tempr + " " + mt.unit; mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_DETECTOR_WINDSPEED); double windspeed = device.getMonitorValue(MonitorType.MIC_DETECTOR_WINDSPEED); str += "," + mt.name + " :" + windspeed + " " + mt.unit; vo.displayField = str; } else if (device.deviceTypeCode == DeviceData.HUILIUXIANG_CODE || device.deviceTypeCode == DeviceData.CABINET_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_TOTALCURRENT); double totalCurrent = device.getMonitorValue(mt.code); string str = mt.name + " :" + totalCurrent + " " + mt.unit; mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_JNTEMPRATURE); double tempr = device.getMonitorValue(mt.code); str += "," + mt.name + " :" + tempr + " " + mt.unit; vo.displayField = str; } else if (device.deviceTypeCode == DeviceData.AMMETER_CODE) { MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_AMMETER_POSITIVEACTIVEPOWERDEGREE); float totalCurrent = device.runData == null ? 0 : device.runData.getMonitorValue(mt.code); string str = mt.name + " :" + totalCurrent + " " + mt.unit; //mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_BUSBAR_JNTEMPRATURE); //float tempr = device.runData == null ? 0 : float.Parse(device.runData.getMonitorValue(mt.code)); //str += "," + mt.name + " :" + tempr + " " + mt.unit; vo.displayField = str; } else { MonitorType TotalEmt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALENERGY); MonitorType TodayEmt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TODAYENERGY); MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.MIC_INVERTER_TOTALYGPOWER); string str = TodayEmt.name + " :" + device.TodayEnergy(timezone) + " " + TodayEmt.unit; str += "," + TotalEmt.name + " :" + device.TotalEnergy + " " + TotalEmt.unit; str += "," + mt.name + " :" + device.TotalPower + " " + mt.unit; vo.displayField = str; } vo.workStatus = device.status; vo.lastUpdateTime = CalenderUtil.formatDate(device.runData.updateTime, "yyyy-MM-dd HH:mm:ss"); vo.hasChart = (device.deviceTypeCode == DeviceData.INVERTER_CODE || device.deviceTypeCode == DeviceData.ENVRIOMENTMONITOR_CODE || device.deviceTypeCode == DeviceData.HUILIUXIANG_CODE || device.deviceTypeCode == DeviceData.AMMETER_CODE || device.deviceTypeCode == DeviceData.CABINET_CODE) ? "true" : "false"; vo.datas = convertToSPlantVOs(device.runData.convertRunstrToList(true, device.deviceTypeCode)); data = JsonUtil.convertToJson(vo, typeof(DeviceInfoVO)); } return(Content(data)); }
// GET: Plants //public ActionResult Index() //{ // return View(db.Plants.ToList()); //} // GET: Plants/Details/5 //Function to display selected plant details //Input - Plant id //Output - Details view of plant public ActionResult Details(string id) { if (id == null) { Session["Error message"] = "Plant not available for given ID."; return(View("Error")); } Plant plant = db.Plant.Find(id); if (plant == null) { Session["Error message"] = "Plant not available for given ID."; return(View("Error")); } else { //Adding plant occurences data plant.Occurances = new List <Plant_Location>(); HttpClient client = new HttpClient(); string plant_name = plant.Scientific_Name; string loc_path = "https://biocache.ala.org.au/ws/occurrences/search?q=" + plant_name + "&pageSize=3000"; var response = client.GetAsync(loc_path).Result; if (!response.IsSuccessStatusCode) { Session["Error message"] = "Plant location loading failed. " + response.ReasonPhrase; return(View("Error")); } response.EnsureSuccessStatusCode(); var data = response.Content.ReadAsStringAsync().Result; var d = JsonConvert.DeserializeObject <dynamic>(data); var occurances = d.occurrences; foreach (var p_occ in occurances) { if (p_occ.stateProvince != null && p_occ.decimalLatitude != null && p_occ.decimalLongitude != null) { if (p_occ.stateProvince.Value == "Victoria") { Plant_Location PL = new Plant_Location(); PL.Latitude = double.Parse(p_occ.decimalLatitude.Value.ToString()); PL.Longitude = double.Parse(p_occ.decimalLongitude.Value.ToString()); plant.Occurances.Add(PL); } } } //Display review of plant-Vivek if (Session["Postcode"] != null) { string connectionString = "Data Source=igtest01.database.windows.net;Initial Catalog=igardens;User ID=test;Password=Password01;Connect Timeout=60;Encrypt=True;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"; string sql = "select round(avg(cast(score as float)),1) as review,count(score) as rwcount from Review where PostCode=@postcode and PlantId=@plantid"; using (SqlConnection cnn = new SqlConnection(connectionString)) { using (SqlDataAdapter sda = new SqlDataAdapter(sql, cnn)) { sda.SelectCommand.Parameters.AddWithValue("@postcode", Session["Postcode"].ToString()); sda.SelectCommand.Parameters.AddWithValue("@plantid", id); DataTable dt = new DataTable(); sda.Fill(dt); if (string.IsNullOrEmpty(dt.Rows[0]["review"].ToString())) { Session["Score"] = "0"; } else { Session["Score"] = dt.Rows[0]["review"].ToString(); } Session["ReviewCount"] = dt.Rows[0]["rwcount"].ToString(); } } } } return(View(plant)); }
public static bool JobOnCell(WorkGiver_GrowerSow __instance, ref Job __result, Pawn pawn, IntVec3 c, bool forced = false) { Map map = pawn.Map; if (c.IsForbidden(pawn)) { __result = null; return(false); } if (!PlantUtility.GrowthSeasonNow(c, map, forSowing: true)) { __result = null; return(false); } ThingDef localWantedPlantDef = WorkGiver_Grower.CalculateWantedPlantDef(c, map); WorkGiver_GrowerSow.wantedPlantDef = localWantedPlantDef; if (localWantedPlantDef == null) { __result = null; return(false); } List <Thing> thingList = c.GetThingList(map); bool flag = false; for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def == localWantedPlantDef) { __result = null; return(false); } if ((thing is Blueprint || thing is Frame) && thing.Faction == pawn.Faction) { flag = true; } } if (flag) { Thing edifice = c.GetEdifice(map); if (edifice == null || edifice.def.fertility < 0f) { __result = null; return(false); } } if (localWantedPlantDef.plant.cavePlant) { if (!c.Roofed(map)) { JobFailReason.Is(WorkGiver_GrowerSow.CantSowCavePlantBecauseUnroofedTrans); __result = null; return(false); } if (map.glowGrid.GameGlowAt(c, ignoreCavePlants: true) > 0f) { JobFailReason.Is(WorkGiver_GrowerSow.CantSowCavePlantBecauseOfLightTrans); __result = null; return(false); } } if (localWantedPlantDef.plant.interferesWithRoof && c.Roofed(pawn.Map)) { __result = null; return(false); } Plant plant = c.GetPlant(map); if (plant != null && plant.def.plant.blockAdjacentSow) { if (!pawn.CanReserve(plant, 1, -1, null, forced) || plant.IsForbidden(pawn)) { __result = null; return(false); } __result = JobMaker.MakeJob(JobDefOf.CutPlant, plant); return(false); } Thing thing2 = PlantUtility.AdjacentSowBlocker(localWantedPlantDef, c, map); if (thing2 != null) { Plant plant2 = thing2 as Plant; if (plant2 != null && pawn.CanReserve(plant2, 1, -1, null, forced) && !plant2.IsForbidden(pawn)) { IPlantToGrowSettable plantToGrowSettable = plant2.Position.GetPlantToGrowSettable(plant2.Map); if (plantToGrowSettable == null || plantToGrowSettable.GetPlantDefToGrow() != plant2.def) { __result = JobMaker.MakeJob(JobDefOf.CutPlant, plant2); return(false); } } __result = null; return(false); } ThingDef thingdef = localWantedPlantDef; if (thingdef != null && thingdef.plant != null && thingdef.plant.sowMinSkill > 0 && pawn != null && pawn.skills != null && pawn.skills.GetSkill(SkillDefOf.Plants).Level < localWantedPlantDef.plant.sowMinSkill) { WorkGiver workGiver = __instance; JobFailReason.Is("UnderAllowedSkill".Translate(localWantedPlantDef.plant.sowMinSkill), workGiver.def.label); __result = null; return(false); } for (int j = 0; j < thingList.Count; j++) { Thing thing3 = thingList[j]; if (!thing3.def.BlocksPlanting()) { continue; } if (!pawn.CanReserve(thing3, 1, -1, null, forced)) { __result = null; return(false); } if (thing3.def.category == ThingCategory.Plant) { if (!thing3.IsForbidden(pawn)) { __result = JobMaker.MakeJob(JobDefOf.CutPlant, thing3); return(false); } __result = null; return(false); } if (thing3.def.EverHaulable) { __result = HaulAIUtility.HaulAsideJobFor(pawn, thing3); return(false); } __result = null; return(false); } if (!localWantedPlantDef.CanEverPlantAt(c, map) || !PlantUtility.GrowthSeasonNow(c, map, forSowing: true) || !pawn.CanReserve(c, 1, -1, null, forced)) { __result = null; return(false); } Job job = JobMaker.MakeJob(JobDefOf.Sow, c); job.plantDefToSow = localWantedPlantDef; __result = job; return(false); }
public bool startTurn() { iteration++; int count = 0; count = Client.getMappableCount(connection); mappables = new Mappable[count]; for(int i = 0; i < count; i++) { mappables[i] = new Mappable(Client.getMappable(connection, i)); } count = Client.getCreatureCount(connection); creatures = new Creature[count]; for(int i = 0; i < count; i++) { creatures[i] = new Creature(Client.getCreature(connection, i)); } count = Client.getPlantCount(connection); plants = new Plant[count]; for(int i = 0; i < count; i++) { plants[i] = new Plant(Client.getPlant(connection, i)); } count = Client.getPlayerCount(connection); players = new Player[count]; for(int i = 0; i < count; i++) { players[i] = new Player(Client.getPlayer(connection, i)); } if(!initialized) { initialized = true; init(); } return run(); }
public static void Postfix(Plant __instance, ref Graphic __result) { //return; if (!Settings.showCold) { return; } string id = __instance.def.defName; if (!__instance.def.HasModExtension <ThingWeatherReaction>()) { return; } ThingWeatherReaction mod = __instance.def.GetModExtension <ThingWeatherReaction>(); string path = ""; //get snow graphic if (__instance.Map.snowGrid.GetDepth(__instance.Position) >= 0.5f) { if (!String.IsNullOrEmpty(mod.snowGraphicPath)) { id += "snow"; path = mod.snowGraphicPath; } } else if (__instance.Map.GetComponent <FrostGrid>().GetDepth(__instance.Position) >= 0.6f) { if (!String.IsNullOrEmpty(mod.frostGraphicPath)) { id += "frost"; path = mod.frostGraphicPath; } } if (String.IsNullOrEmpty(path)) { return; } //if it's leafless if (__instance.def.plant.leaflessGraphic == __result) { id += "leafless"; path = path.Replace("Frosted", "Frosted/Leafless"); path = path.Replace("Snow", "Snow/Leafless"); path += "_Leafless"; } else if (__instance.def.blockWind) { //make it so snow doesn't fall under the tree until it's leafless. // __instance.Map.snowGrid.AddDepth(__instance.Position, -.05f); } if (!__instance.Map.GetComponent <Watcher>().graphicHolder.ContainsKey(id)) { //only load the image once. __instance.Map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, path, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo)); } if (__instance.Map.GetComponent <Watcher>().graphicHolder.ContainsKey(id)) { //only load the image once. __result = __instance.Map.GetComponent <Watcher>().graphicHolder[id]; } }
public IActionResult Post([FromBody] Plant value) { _context.Plants.Add(value); _context.SaveChanges(); return(Ok()); }
public ChemMix(Plant plant) { this.plant = plant; }