ModernUO/Projects/UOContent/Items/Resources/Fishing/BigFish.cs
Kamron Batman 4ddb3de026
fix(core): Fixes several serialization issues (#355)
- [X] Fixes an issue where a buffer smaller than 8 bytes would not double with enough space in some cases.
- [X] Fixes an issue with dupe copying the savebuffer reference (ugh).
- [X] Streamlines the IGenericWriter API to use better generics.
- [X] Streamlines the IGenericReader API to use better generics.
- [X] Forces `tidying` of a List/HashSet to be done externally since Writers/Readers should not have side effects.
- [X] Fixes an issue where Tidying a list didn't TrimExcess, causing memory leaks.
- [X] Reverted the meaning of `World.Running` to specifically refer to any world state post world loading.
  - NOTE: Do not use this if you want to block on world saves. Instead use checks against `WorldState.Saving` states.
- [X] Fixes an issue with serializing negative DateTime deltas.
- [X] Fixes a potential issue with serializing non-UTC DateTime.

Bumps release version
2020-12-23 07:11:41 -08:00

86 lines
2.2 KiB
C#

using System;
namespace Server.Items
{
public class BigFish : Item, ICarvable
{
private Mobile m_Fisher;
[Constructible]
public BigFish() : base(0x09CC)
{
Weight = Utility.RandomMinMax(
3,
200
); // TODO: Find correct formula. max on OSI currently 200, OSI dev says it's not 200 as max, and ~ 1/1,000,000 chance to get highest
Hue = Utility.RandomBool() ? 0x847 : 0x58C;
}
public BigFish(Serial serial) : base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Fisher
{
get => m_Fisher;
set
{
m_Fisher = value;
InvalidateProperties();
}
}
public override int LabelNumber => 1041112; // a big fish
public void Carve(Mobile from, Item item)
{
ScissorHelper(from, new RawFishSteak(), Math.Max(16, (int)Weight) / 4, false);
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Weight >= 20)
{
if (m_Fisher != null)
{
list.Add(1070857, m_Fisher.Name); // Caught by ~1_fisherman~
}
list.Add(1070858, ((int)Weight).ToString()); // ~1_weight~ stones
}
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(1); // version
writer.Write(m_Fisher);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
switch (version)
{
case 1:
{
m_Fisher = reader.ReadEntity<Mobile>();
break;
}
case 0:
{
Weight = Utility.RandomMinMax(3, 200);
break;
}
}
}
}
}