fix: Moves mods and fixes migrations for lights (#1080)
- [X] Removes duplicate property for owner. - [X] Codegens them all (even though they aren't used, just in case someone wants to).
This commit is contained in:
parent
dc7033d71f
commit
7adf52ef48
20 changed files with 557 additions and 219 deletions
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.DefaultSkillMod"
|
||||
}
|
||||
11
Projects/Server/Migrations/Server.EquippedSkillMod.v0.json
Normal file
11
Projects/Server/Migrations/Server.EquippedSkillMod.v0.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.EquippedSkillMod",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Item",
|
||||
"type": "Server.Item",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
Projects/Server/Migrations/Server.MobileMod.v0.json
Normal file
4
Projects/Server/Migrations/Server.MobileMod.v0.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.MobileMod"
|
||||
}
|
||||
19
Projects/Server/Migrations/Server.ResistanceMod.v0.json
Normal file
19
Projects/Server/Migrations/Server.ResistanceMod.v0.json
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.ResistanceMod",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Type",
|
||||
"type": "Server.ResistanceType",
|
||||
"rule": "EnumMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Offset",
|
||||
"type": "int",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
43
Projects/Server/Migrations/Server.SkillMod.v0.json
Normal file
43
Projects/Server/Migrations/Server.SkillMod.v0.json
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.SkillMod",
|
||||
"properties": [
|
||||
{
|
||||
"name": "ObeyCap",
|
||||
"type": "bool",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Skill",
|
||||
"type": "Server.SkillName",
|
||||
"rule": "EnumMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Relative",
|
||||
"type": "bool",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Absolute",
|
||||
"type": "bool",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Value",
|
||||
"type": "double",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
40
Projects/Server/Migrations/Server.StatMod.v0.json
Normal file
40
Projects/Server/Migrations/Server.StatMod.v0.json
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.StatMod",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Added",
|
||||
"type": "System.DateTime",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Duration",
|
||||
"type": "System.TimeSpan",
|
||||
"rule": "PrimitiveTypeMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Type",
|
||||
"type": "Server.StatType",
|
||||
"rule": "EnumMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "string",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Offset",
|
||||
"type": "int",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
14
Projects/Server/Migrations/Server.TimedSkillMod.v0.json
Normal file
14
Projects/Server/Migrations/Server.TimedSkillMod.v0.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.TimedSkillMod",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Expire",
|
||||
"type": "System.DateTime",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -27,224 +27,6 @@ namespace Server
|
|||
|
||||
public delegate void PromptStateCallback<in T>(Mobile from, string text, T state);
|
||||
|
||||
public class TimedSkillMod : SkillMod
|
||||
{
|
||||
private readonly DateTime m_Expire;
|
||||
|
||||
public TimedSkillMod(SkillName skill, bool relative, double value, TimeSpan delay)
|
||||
: this(skill, relative, value, Core.Now + delay)
|
||||
{
|
||||
}
|
||||
|
||||
public TimedSkillMod(SkillName skill, bool relative, double value, DateTime expire)
|
||||
: base(skill, relative, value) =>
|
||||
m_Expire = expire;
|
||||
|
||||
public override bool CheckCondition() => Core.Now < m_Expire;
|
||||
}
|
||||
|
||||
public class EquippedSkillMod : SkillMod
|
||||
{
|
||||
private readonly Item m_Item;
|
||||
private readonly Mobile m_Mobile;
|
||||
|
||||
public EquippedSkillMod(SkillName skill, bool relative, double value, Item item, Mobile mobile)
|
||||
: base(skill, relative, value)
|
||||
{
|
||||
m_Item = item;
|
||||
m_Mobile = mobile;
|
||||
}
|
||||
|
||||
public override bool CheckCondition() => !m_Item.Deleted && !m_Mobile.Deleted && m_Item.Parent == m_Mobile;
|
||||
}
|
||||
|
||||
public class DefaultSkillMod : SkillMod
|
||||
{
|
||||
public DefaultSkillMod(SkillName skill, bool relative, double value)
|
||||
: base(skill, relative, value)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CheckCondition() => true;
|
||||
}
|
||||
|
||||
public abstract class SkillMod
|
||||
{
|
||||
private bool m_ObeyCap;
|
||||
private Mobile m_Owner;
|
||||
private bool m_Relative;
|
||||
private SkillName m_Skill;
|
||||
private double m_Value;
|
||||
|
||||
protected SkillMod(SkillName skill, bool relative, double value)
|
||||
{
|
||||
m_Skill = skill;
|
||||
m_Relative = relative;
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
public bool ObeyCap
|
||||
{
|
||||
get => m_ObeyCap;
|
||||
set
|
||||
{
|
||||
m_ObeyCap = value;
|
||||
|
||||
var sk = m_Owner?.Skills[m_Skill];
|
||||
sk?.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Owner
|
||||
{
|
||||
get => m_Owner;
|
||||
set
|
||||
{
|
||||
if (m_Owner != value)
|
||||
{
|
||||
m_Owner?.RemoveSkillMod(this);
|
||||
m_Owner = value;
|
||||
m_Owner?.AddSkillMod(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SkillName Skill
|
||||
{
|
||||
get => m_Skill;
|
||||
set
|
||||
{
|
||||
if (m_Skill != value)
|
||||
{
|
||||
var oldUpdate = m_Owner?.Skills[m_Skill];
|
||||
|
||||
m_Skill = value;
|
||||
|
||||
var sk = m_Owner?.Skills[m_Skill];
|
||||
sk?.Update();
|
||||
oldUpdate?.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Relative
|
||||
{
|
||||
get => m_Relative;
|
||||
set
|
||||
{
|
||||
if (m_Relative != value)
|
||||
{
|
||||
m_Relative = value;
|
||||
|
||||
var sk = m_Owner?.Skills[m_Skill];
|
||||
sk?.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Absolute
|
||||
{
|
||||
get => !m_Relative;
|
||||
set
|
||||
{
|
||||
if (m_Relative == value)
|
||||
{
|
||||
m_Relative = !value;
|
||||
|
||||
var sk = m_Owner?.Skills[m_Skill];
|
||||
sk?.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double Value
|
||||
{
|
||||
get => m_Value;
|
||||
set
|
||||
{
|
||||
if (m_Value != value)
|
||||
{
|
||||
m_Value = value;
|
||||
|
||||
var sk = m_Owner?.Skills[m_Skill];
|
||||
sk?.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
Owner = null;
|
||||
}
|
||||
|
||||
public abstract bool CheckCondition();
|
||||
}
|
||||
|
||||
public class ResistanceMod
|
||||
{
|
||||
private int m_Offset;
|
||||
private ResistanceType m_Type;
|
||||
|
||||
public ResistanceMod(ResistanceType type, int offset)
|
||||
{
|
||||
m_Type = type;
|
||||
m_Offset = offset;
|
||||
}
|
||||
|
||||
public Mobile Owner { get; set; }
|
||||
|
||||
public ResistanceType Type
|
||||
{
|
||||
get => m_Type;
|
||||
set
|
||||
{
|
||||
if (m_Type != value)
|
||||
{
|
||||
m_Type = value;
|
||||
|
||||
Owner?.UpdateResistances();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Offset
|
||||
{
|
||||
get => m_Offset;
|
||||
set
|
||||
{
|
||||
if (m_Offset != value)
|
||||
{
|
||||
m_Offset = value;
|
||||
|
||||
Owner?.UpdateResistances();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class StatMod
|
||||
{
|
||||
private readonly DateTime m_Added;
|
||||
private readonly TimeSpan m_Duration;
|
||||
|
||||
public StatMod(StatType type, string name, int offset, TimeSpan duration)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
Offset = offset;
|
||||
m_Duration = duration;
|
||||
m_Added = Core.Now;
|
||||
}
|
||||
|
||||
public StatType Type { get; }
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public int Offset { get; }
|
||||
|
||||
public bool HasElapsed() => m_Duration != TimeSpan.Zero && Core.Now - m_Added >= m_Duration;
|
||||
}
|
||||
|
||||
public class DamageEntry
|
||||
{
|
||||
public DamageEntry(Mobile damager) => Damager = damager;
|
||||
|
|
|
|||
32
Projects/Server/Mobiles/Mods/DefaultSkillMod.cs
Normal file
32
Projects/Server/Mobiles/Mods/DefaultSkillMod.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: DefaultSkillMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class DefaultSkillMod : SkillMod
|
||||
{
|
||||
public DefaultSkillMod(Mobile owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultSkillMod(SkillName skill, bool relative, double value) : base(skill, relative, value)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CheckCondition() => true;
|
||||
}
|
||||
34
Projects/Server/Mobiles/Mods/EquippedSkillMod.cs
Normal file
34
Projects/Server/Mobiles/Mods/EquippedSkillMod.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: EquippedSkillMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class EquippedSkillMod : SkillMod
|
||||
{
|
||||
[SerializableField(0)]
|
||||
private Item _item;
|
||||
|
||||
public EquippedSkillMod(Mobile owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public EquippedSkillMod(SkillName skill, bool relative, double value, Item item, Mobile mobile)
|
||||
: base(skill, relative, value, mobile) => _item = item;
|
||||
|
||||
public override bool CheckCondition() => !_item.Deleted && Owner?.Deleted == false && _item.Parent == Owner;
|
||||
}
|
||||
27
Projects/Server/Mobiles/Mods/MobileMod.cs
Normal file
27
Projects/Server/Mobiles/Mods/MobileMod.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MobileMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class MobileMod
|
||||
{
|
||||
[DirtyTrackingEntity]
|
||||
public virtual Mobile Owner { get; set; }
|
||||
|
||||
public MobileMod(Mobile owner) => Owner = owner;
|
||||
}
|
||||
70
Projects/Server/Mobiles/Mods/ResistanceMod.cs
Normal file
70
Projects/Server/Mobiles/Mods/ResistanceMod.cs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: ResistanceMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class ResistanceMod : MobileMod
|
||||
{
|
||||
// Field 0
|
||||
private int _offset;
|
||||
|
||||
// Field 1
|
||||
private ResistanceType _type;
|
||||
|
||||
public ResistanceMod(Mobile owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public ResistanceMod(ResistanceType type, int offset, Mobile owner = null) : base(owner)
|
||||
{
|
||||
_type = type;
|
||||
_offset = offset;
|
||||
}
|
||||
|
||||
[SerializableField(0)]
|
||||
public ResistanceType Type
|
||||
{
|
||||
get => _type;
|
||||
set
|
||||
{
|
||||
if (_type != value)
|
||||
{
|
||||
_type = value;
|
||||
|
||||
Owner?.UpdateResistances();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializableField(1)]
|
||||
public int Offset
|
||||
{
|
||||
get => _offset;
|
||||
set
|
||||
{
|
||||
if (_offset != value)
|
||||
{
|
||||
_offset = value;
|
||||
|
||||
Owner?.UpdateResistances();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
146
Projects/Server/Mobiles/Mods/SkillMod.cs
Normal file
146
Projects/Server/Mobiles/Mods/SkillMod.cs
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: SkillMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public abstract partial class SkillMod : MobileMod
|
||||
{
|
||||
private bool _obeyCap;
|
||||
|
||||
private bool _relative;
|
||||
private SkillName _skill;
|
||||
private double _value;
|
||||
|
||||
public SkillMod(Mobile owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public SkillMod(SkillName skill, bool relative, double value, Mobile owner = null) : base(owner)
|
||||
{
|
||||
_skill = skill;
|
||||
_relative = relative;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
[SerializableField(0)]
|
||||
public bool ObeyCap
|
||||
{
|
||||
get => _obeyCap;
|
||||
set
|
||||
{
|
||||
_obeyCap = value;
|
||||
|
||||
var sk = Owner?.Skills[_skill];
|
||||
sk?.Update();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override Mobile Owner
|
||||
{
|
||||
get => base.Owner;
|
||||
set
|
||||
{
|
||||
var owner = base.Owner;
|
||||
if (owner != value)
|
||||
{
|
||||
owner?.RemoveSkillMod(this);
|
||||
owner = value;
|
||||
owner?.AddSkillMod(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializableField(1)]
|
||||
public SkillName Skill
|
||||
{
|
||||
get => _skill;
|
||||
set
|
||||
{
|
||||
if (_skill != value)
|
||||
{
|
||||
var oldUpdate = Owner?.Skills[_skill];
|
||||
|
||||
_skill = value;
|
||||
|
||||
var sk = Owner?.Skills[_skill];
|
||||
sk?.Update();
|
||||
oldUpdate?.Update();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializableField(2)]
|
||||
public bool Relative
|
||||
{
|
||||
get => _relative;
|
||||
set
|
||||
{
|
||||
if (_relative != value)
|
||||
{
|
||||
_relative = value;
|
||||
|
||||
var sk = Owner?.Skills[_skill];
|
||||
sk?.Update();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializableField(3)]
|
||||
public bool Absolute
|
||||
{
|
||||
get => !_relative;
|
||||
set
|
||||
{
|
||||
if (_relative == value)
|
||||
{
|
||||
_relative = !value;
|
||||
|
||||
var sk = Owner?.Skills[_skill];
|
||||
sk?.Update();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializableField(4)]
|
||||
public double Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
if (_value != value)
|
||||
{
|
||||
_value = value;
|
||||
|
||||
var sk = Owner?.Skills[_skill];
|
||||
sk?.Update();
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
Owner = null;
|
||||
}
|
||||
|
||||
public abstract bool CheckCondition();
|
||||
}
|
||||
53
Projects/Server/Mobiles/Mods/StatMod.cs
Normal file
53
Projects/Server/Mobiles/Mods/StatMod.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: StatMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class StatMod : MobileMod
|
||||
{
|
||||
[SerializableField(0, getter: "private", setter: "private")]
|
||||
private DateTime _added;
|
||||
|
||||
[SerializableField(1, getter: "private", setter: "private")]
|
||||
private TimeSpan _duration;
|
||||
|
||||
[SerializableField(2, setter: "private")]
|
||||
private StatType _type;
|
||||
|
||||
[SerializableField(3, setter: "private")]
|
||||
private string _name;
|
||||
|
||||
[SerializableField(4, setter: "private")]
|
||||
private int _offset;
|
||||
|
||||
public StatMod(Mobile owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public StatMod(StatType type, string name, int offset, TimeSpan duration, Mobile owner = null) : base(owner)
|
||||
{
|
||||
_type = type;
|
||||
_name = name;
|
||||
_offset = offset;
|
||||
_duration = duration;
|
||||
_added = Core.Now;
|
||||
}
|
||||
|
||||
public bool HasElapsed() => _duration != TimeSpan.Zero && Core.Now - _added >= _duration;
|
||||
}
|
||||
40
Projects/Server/Mobiles/Mods/TimedSkillMod.cs
Normal file
40
Projects/Server/Mobiles/Mods/TimedSkillMod.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: TimedSkillMod.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using ModernUO.Serialization;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[SerializationGenerator(0)]
|
||||
public partial class TimedSkillMod : SkillMod
|
||||
{
|
||||
[SerializableField(0, setter: "private")]
|
||||
private DateTime _expire;
|
||||
|
||||
public TimedSkillMod(Mobile owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public TimedSkillMod(SkillName skill, bool relative, double value, TimeSpan delay)
|
||||
: this(skill, relative, value, Core.Now + delay)
|
||||
{
|
||||
}
|
||||
|
||||
public TimedSkillMod(SkillName skill, bool relative, double value, DateTime expire)
|
||||
: base(skill, relative, value) => _expire = expire;
|
||||
|
||||
public override bool CheckCondition() => Core.Now < _expire;
|
||||
}
|
||||
|
|
@ -24,7 +24,10 @@ namespace Server
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void MarkDirty(this ISerializable entity)
|
||||
{
|
||||
entity.SavePosition = -1;
|
||||
if (entity != null)
|
||||
{
|
||||
entity.SavePosition = -1;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.Candle"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.Lantern"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.LanternOfSouls"
|
||||
}
|
||||
4
Projects/UOContent/Migrations/Server.Items.Torch.v0.json
Normal file
4
Projects/UOContent/Migrations/Server.Items.Torch.v0.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.Torch"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue