public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_PlantType = (PlantType)reader.ReadInt(); m_PlantHue = (PlantHue)reader.ReadInt(); m_ShowType = reader.ReadBool(); if (Weight != 1.0) { Weight = 1.0; } if (version < 1) { Stackable = true; } if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue)) { m_PlantHue |= PlantHue.Reproduces; } }
private void AddSeedsState(int x, int y) { PlantSystem system = m_Plant.PlantSystem; int totalSeeds = system.AvailableSeeds + system.LeftSeeds; if (!PlantHueInfo.IsCrossable(m_Plant.PlantHue) || totalSeeds == 0) { AddLabel(x + 5, y, 0x21, "X"); } else { AddLabel(x, y, PlantHueInfo.GetInfo(system.SeedHue).GumpHue, string.Format("{0}/{1}", system.AvailableSeeds, totalSeeds)); } }
public PlantSystem(PlantItem plant, GenericReader reader) { Plant = plant; int version = reader.ReadInt(); FertileDirt = reader.ReadBool(); if (version >= 1) { NextGrowth = reader.ReadDateTime(); } else { NextGrowth = reader.ReadDeltaTime(); } GrowthIndicator = (PlantGrowthIndicator)reader.ReadInt(); m_Water = reader.ReadInt(); m_Hits = reader.ReadInt(); m_Infestation = reader.ReadInt(); m_Fungus = reader.ReadInt(); m_Poison = reader.ReadInt(); m_Disease = reader.ReadInt(); m_PoisonPotion = reader.ReadInt(); m_CurePotion = reader.ReadInt(); m_HealPotion = reader.ReadInt(); m_StrengthPotion = reader.ReadInt(); Pollinated = reader.ReadBool(); m_SeedType = (PlantType)reader.ReadInt(); m_SeedHue = (PlantHue)reader.ReadInt(); m_AvailableSeeds = reader.ReadInt(); m_LeftSeeds = reader.ReadInt(); m_AvailableResources = reader.ReadInt(); m_LeftResources = reader.ReadInt(); if (version < 2 && PlantHueInfo.IsCrossable(m_SeedHue)) { m_SeedHue |= PlantHue.Reproduces; } }
private void Grow() { if (Health < PlantHealth.Healthy) { m_GrowthIndicator = PlantGrowthIndicator.NotHealthy; } else if (m_FertileDirt && m_Plant.PlantStatus <= PlantStatus.Stage5 && Utility.RandomDouble() < 0.1) { int curStage = (int)m_Plant.PlantStatus; m_Plant.PlantStatus = (PlantStatus)(curStage + 2); m_GrowthIndicator = PlantGrowthIndicator.DoubleGrown; } else if (m_Plant.PlantStatus < PlantStatus.Stage9) { int curStage = (int)m_Plant.PlantStatus; m_Plant.PlantStatus = (PlantStatus)(curStage + 1); m_GrowthIndicator = PlantGrowthIndicator.Grown; } else { if (Pollinated && LeftSeeds > 0 && PlantHueInfo.IsCrossable(m_Plant.PlantHue)) { LeftSeeds--; AvailableSeeds++; } if (LeftResources > 0 && PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue) != null) { LeftResources--; AvailableResources++; } m_GrowthIndicator = PlantGrowthIndicator.Grown; } if (m_Plant.PlantStatus >= PlantStatus.Stage9 && !Pollinated) { Pollinated = true; SeedType = m_Plant.PlantType; SeedHue = m_Plant.PlantHue; } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 2: case 1: { m_Level = (SecureLevel)reader.ReadInt(); goto case 0; } case 0: { if (version < 1) { m_Level = SecureLevel.CoOwners; } m_PlantStatus = (PlantStatus)reader.ReadInt(); m_PlantType = (PlantType)reader.ReadInt(); m_PlantHue = (PlantHue)reader.ReadInt(); m_ShowType = reader.ReadBool(); if (m_PlantStatus < PlantStatus.DecorativePlant) { m_PlantSystem = new PlantSystem(this, reader); } if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue)) { m_PlantHue |= PlantHue.Reproduces; } break; } } m_Instances.Add(this); }
protected override void OnTarget(Mobile from, object targeted) { if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant && from.InRange(m_Plant.GetWorldLocation(), 3)) { if (!m_Plant.IsUsableBy(from)) { m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it. } else if (!PlantHueInfo.IsCrossable(m_Plant.PlantHue)) { m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant! } else if (!m_Plant.PlantSystem.PollenProducing) { m_Plant.LabelTo(from, 1053051); // You cannot gather pollen from a plant in this stage of development! } else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy) { m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant! } else { PlantItem targ = targeted as PlantItem; if (targ == null || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt) { m_Plant.LabelTo(from, 1053070); // You can only pollinate other specially grown plants! } else if (!targ.IsUsableBy(from)) { targ.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it. } else if (!PlantHueInfo.IsCrossable(targ.PlantHue)) { targ.LabelTo(from, 1053073); // You cannot cross-pollinate with a mutated plant! } else if (!targ.PlantSystem.PollenProducing) { targ.LabelTo(from, 1053074); // This plant is not in the flowering stage. You cannot pollinate it! } else if (targ.PlantSystem.Health < PlantHealth.Healthy) { targ.LabelTo(from, 1053075); // You cannot pollinate an unhealthy plant! } else if (targ.PlantSystem.Pollinated) { targ.LabelTo(from, 1053072); // This plant has already been pollinated! } else if (targ == m_Plant) { targ.PlantSystem.Pollinated = true; targ.PlantSystem.SeedType = m_Plant.PlantType; targ.PlantSystem.SeedHue = m_Plant.PlantHue; targ.LabelTo(from, 1053071); // You pollinate the plant with its own pollen. } else { targ.PlantSystem.Pollinated = true; targ.PlantSystem.SeedType = PlantTypeInfo.Cross(m_Plant.PlantType, targ.PlantType); targ.PlantSystem.SeedHue = PlantHueInfo.Cross(m_Plant.PlantHue, targ.PlantHue); targ.LabelTo(from, 1053076); // You successfully cross-pollinate the plant. } } } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant || m_Plant.PlantStatus == PlantStatus.BowlOfDirt || !from.InRange(m_Plant.GetWorldLocation(), 3)) { return; } if (!m_Plant.IsUsableBy(from)) { m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it. return; } switch (info.ButtonID) { case 1: // Main menu { from.SendGump(new MainPlantGump(m_Plant)); break; } case 2: // Set to decorative { if (m_Plant.PlantStatus == PlantStatus.Stage9) { from.SendGump(new SetToDecorativeGump(m_Plant)); } break; } case 3: // Pollination { from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE from.SendGump(new ReproductionGump(m_Plant)); break; } case 4: // Resources { from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION from.SendGump(new ReproductionGump(m_Plant)); break; } case 5: // Seeds { from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION from.SendGump(new ReproductionGump(m_Plant)); break; } case 6: // Gather pollen { if (!PlantHueInfo.IsCrossable(m_Plant.PlantHue)) { m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant! } else if (!m_Plant.PlantSystem.PollenProducing) { m_Plant.LabelTo(from, 1053051); // You cannot gather pollen from a plant in this stage of development! } else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy) { m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant! } else { from.Target = new PollinateTarget(m_Plant); from.SendLocalizedMessage(1053054); // Target the plant you wish to cross-pollinate to. break; } from.SendGump(new ReproductionGump(m_Plant)); break; } case 7: // Gather resources { PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue); PlantSystem system = m_Plant.PlantSystem; if (resInfo == null) { if (PlantHueInfo.IsCrossable(m_Plant.PlantHue)) { m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather! } else { m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources! } } else if (system.AvailableResources == 0) { m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather! } else { Item resource = resInfo.CreateResource(); if (from.PlaceInBackpack(resource)) { system.AvailableResources--; m_Plant.LabelTo(from, 1053059); // You gather resources from the plant. } else { resource.Delete(); m_Plant.LabelTo(from, 1053058); // You attempt to gather as many resources as you can hold, but your backpack is full. } } from.SendGump(new ReproductionGump(m_Plant)); break; } case 8: // Gather seeds { PlantSystem system = m_Plant.PlantSystem; if (!PlantHueInfo.IsCrossable(m_Plant.PlantHue)) { m_Plant.LabelTo(from, 1053060); // Mutated plants do not produce seeds! } else if (system.AvailableSeeds == 0) { m_Plant.LabelTo(from, 1053061); // This plant has no seeds to gather! } else { Seed seed = new Seed(system.SeedType, system.SeedHue, true); if (from.PlaceInBackpack(seed)) { system.AvailableSeeds--; m_Plant.LabelTo(from, 1053063); // You gather seeds from the plant. } else { seed.Delete(); m_Plant.LabelTo(from, 1053062); // You attempt to gather as many seeds as you can hold, but your backpack is full. } } from.SendGump(new ReproductionGump(m_Plant)); break; } } }