mirror of
https://github.com/oshima-studios/OshimaGameModule.git
synced 2025-12-05 08:09:04 +00:00
添加user参数
This commit is contained in:
parent
98e92e0611
commit
22889598ec
@ -32,7 +32,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects
|
||||
caster.EP += 实际获得;
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(List<Character> targets, Dictionary<string, object> others)
|
||||
public override void OnSkillCasted(User user, List<Character> targets, Dictionary<string, object> others)
|
||||
{
|
||||
foreach (Character target in targets)
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects
|
||||
caster.EXP += 实际获得;
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(List<Character> targets, Dictionary<string, object> others)
|
||||
public override void OnSkillCasted(User user, List<Character> targets, Dictionary<string, object> others)
|
||||
{
|
||||
foreach (Character target in targets)
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects
|
||||
HealToTarget(caster, caster, 实际回复, false);
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(List<Character> targets, Dictionary<string, object> others)
|
||||
public override void OnSkillCasted(User user, List<Character> targets, Dictionary<string, object> others)
|
||||
{
|
||||
foreach (Character target in targets)
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects
|
||||
HealToTarget(caster, caster, 实际回复, false);
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(List<Character> targets, Dictionary<string, object> others)
|
||||
public override void OnSkillCasted(User user, List<Character> targets, Dictionary<string, object> others)
|
||||
{
|
||||
foreach (Character target in targets)
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects
|
||||
caster.MP += 实际回复;
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(List<Character> targets, Dictionary<string, object> others)
|
||||
public override void OnSkillCasted(User user, List<Character> targets, Dictionary<string, object> others)
|
||||
{
|
||||
foreach (Character target in targets)
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules.Effects.ItemEffects
|
||||
caster.MP += 实际回复;
|
||||
}
|
||||
|
||||
public override void OnSkillCasted(List<Character> targets, Dictionary<string, object> others)
|
||||
public override void OnSkillCasted(User user, List<Character> targets, Dictionary<string, object> others)
|
||||
{
|
||||
foreach (Character target in targets)
|
||||
{
|
||||
|
||||
@ -21,11 +21,11 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
item.IsRemoveAfterUse = true;
|
||||
}
|
||||
|
||||
public static string UseItem(Item item, Character character)
|
||||
public static string UseItem(User user, Item item, Character character)
|
||||
{
|
||||
if (item.Skills.Active != null)
|
||||
{
|
||||
item.Skills.Active.OnSkillCasted([character]);
|
||||
item.Skills.Active.OnSkillCasted(user, [character]);
|
||||
string msg = $"对角色 [ {character} ] 使用 [ {item.Name} ] 成功!";
|
||||
if (item is HPRecovery hpBook)
|
||||
{
|
||||
@ -36,7 +36,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
return "此物品没有主动技能,无法被使用!";
|
||||
}
|
||||
|
||||
public static bool OnItemUsed(Item item, Dictionary<string, object> args)
|
||||
public static bool OnItemUsed(User user, Item item, Dictionary<string, object> args)
|
||||
{
|
||||
string msg = "";
|
||||
bool result = false;
|
||||
@ -47,7 +47,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
if (temp.Length > 0)
|
||||
{
|
||||
targets = [temp[0]];
|
||||
msg = UseItem(item, temp[0]);
|
||||
msg = UseItem(user, item, temp[0]);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
@ -84,9 +84,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
回复药.Init(this, HP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 回复药.OnItemUsed(this, args);
|
||||
return 回复药.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +104,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
回复药.Init(this, HP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 回复药.OnItemUsed(this, args);
|
||||
return 回复药.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
回复药.Init(this, HP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 回复药.OnItemUsed(this, args);
|
||||
return 回复药.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
item.IsRemoveAfterUse = true;
|
||||
}
|
||||
|
||||
public static string UseItem(Item item, Character character)
|
||||
public static string UseItem(User user, Item item, Character character)
|
||||
{
|
||||
if (item.Skills.Active != null)
|
||||
{
|
||||
item.Skills.Active.OnSkillCasted([character]);
|
||||
item.Skills.Active.OnSkillCasted(user, [character]);
|
||||
string msg = $"对角色 [ {character} ] 使用 [ {item.Name} ] 成功!";
|
||||
if (item is EXPBook expBook)
|
||||
{
|
||||
@ -36,7 +36,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
return "此物品没有主动技能,无法被使用!";
|
||||
}
|
||||
|
||||
public static bool OnItemUsed(Item item, Dictionary<string, object> args)
|
||||
public static bool OnItemUsed(User user, Item item, Dictionary<string, object> args)
|
||||
{
|
||||
string msg = "";
|
||||
bool result = false;
|
||||
@ -47,7 +47,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
if (temp.Length > 0)
|
||||
{
|
||||
targets = [temp[0]];
|
||||
msg = UseItem(item, temp[0]);
|
||||
msg = UseItem(user, item, temp[0]);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
@ -84,9 +84,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
经验书.Init(this, EXP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 经验书.OnItemUsed(this, args);
|
||||
return 经验书.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +104,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
经验书.Init(this, EXP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 经验书.OnItemUsed(this, args);
|
||||
return 经验书.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
经验书.Init(this, EXP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 经验书.OnItemUsed(this, args);
|
||||
return 经验书.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
item.IsRemoveAfterUse = true;
|
||||
}
|
||||
|
||||
public static string UseItem(Item item, Character character)
|
||||
public static string UseItem(User user, Item item, Character character)
|
||||
{
|
||||
if (item.Skills.Active != null)
|
||||
{
|
||||
item.Skills.Active.OnSkillCasted([character]);
|
||||
item.Skills.Active.OnSkillCasted(user, [character]);
|
||||
string msg = $"对角色 [ {character} ] 使用 [ {item.Name} ] 成功!";
|
||||
if (item is EPAdd hpBook)
|
||||
{
|
||||
@ -36,7 +36,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
return "此物品没有主动技能,无法被使用!";
|
||||
}
|
||||
|
||||
public static bool OnItemUsed(Item item, Dictionary<string, object> args)
|
||||
public static bool OnItemUsed(User user, Item item, Dictionary<string, object> args)
|
||||
{
|
||||
string msg = "";
|
||||
bool result = false;
|
||||
@ -47,7 +47,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
if (temp.Length > 0)
|
||||
{
|
||||
targets = [temp[0]];
|
||||
msg = UseItem(item, temp[0]);
|
||||
msg = UseItem(user, item, temp[0]);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
@ -84,9 +84,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
能量饮料.Init(this, EP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 能量饮料.OnItemUsed(this, args);
|
||||
return 能量饮料.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +104,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
能量饮料.Init(this, EP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 能量饮料.OnItemUsed(this, args);
|
||||
return 能量饮料.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
能量饮料.Init(this, EP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 能量饮料.OnItemUsed(this, args);
|
||||
return 能量饮料.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
item.IsRemoveAfterUse = true;
|
||||
}
|
||||
|
||||
public static string UseItem(Item item, Character character)
|
||||
public static string UseItem(User user, Item item, Character character)
|
||||
{
|
||||
if (item.Skills.Active != null)
|
||||
{
|
||||
item.Skills.Active.OnSkillCasted([character]);
|
||||
item.Skills.Active.OnSkillCasted(user, [character]);
|
||||
string msg = $"对角色 [ {character} ] 使用 [ {item.Name} ] 成功!";
|
||||
if (item is MPRecovery hpBook)
|
||||
{
|
||||
@ -36,7 +36,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
return "此物品没有主动技能,无法被使用!";
|
||||
}
|
||||
|
||||
public static bool OnItemUsed(Item item, Dictionary<string, object> args)
|
||||
public static bool OnItemUsed(User user, Item item, Dictionary<string, object> args)
|
||||
{
|
||||
string msg = "";
|
||||
bool result = false;
|
||||
@ -47,7 +47,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
if (temp.Length > 0)
|
||||
{
|
||||
targets = [temp[0]];
|
||||
msg = UseItem(item, temp[0]);
|
||||
msg = UseItem(user, item, temp[0]);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
@ -84,9 +84,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
魔力填充剂.Init(this, MP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 魔力填充剂.OnItemUsed(this, args);
|
||||
return 魔力填充剂.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +104,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
魔力填充剂.Init(this, MP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 魔力填充剂.OnItemUsed(this, args);
|
||||
return 魔力填充剂.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
魔力填充剂.Init(this, MP, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 魔力填充剂.OnItemUsed(this, args);
|
||||
return 魔力填充剂.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
item.IsRemoveAfterUse = true;
|
||||
}
|
||||
|
||||
public static bool OnItemUsed(Item item, Dictionary<string, object> args)
|
||||
public static bool OnItemUsed(User user, Item item, Dictionary<string, object> args)
|
||||
{
|
||||
string msg = "";
|
||||
if (item is GiftBox box)
|
||||
@ -61,9 +61,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
}, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 礼包.OnItemUsed(this, args);
|
||||
return 礼包.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,9 +93,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
}, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 礼包.OnItemUsed(this, args);
|
||||
return 礼包.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ namespace Oshima.FunGame.OshimaModules.Items
|
||||
}, remainUseTimes);
|
||||
}
|
||||
|
||||
protected override bool OnItemUsed(Dictionary<string, object> args)
|
||||
protected override bool OnItemUsed(User user, Dictionary<string, object> args)
|
||||
{
|
||||
return 礼包.OnItemUsed(this, args);
|
||||
return 礼包.OnItemUsed(user, this, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,14 +11,21 @@ namespace Oshima.FunGame.OshimaModules
|
||||
public override string Description => OshimaGameModuleConstant.Description;
|
||||
public override string Version => OshimaGameModuleConstant.Version;
|
||||
public override string Author => OshimaGameModuleConstant.Author;
|
||||
public Dictionary<string, Character> KnownCharacters { get; } = [];
|
||||
|
||||
public override Dictionary<string, Character> Characters
|
||||
{
|
||||
get
|
||||
{
|
||||
EntityModuleConfig<Character> config = new(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Character);
|
||||
config.LoadConfig();
|
||||
return config;
|
||||
Dictionary<string, Character> characters = Factory.GetGameModuleInstances<Character>(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Character);
|
||||
if (KnownCharacters.Count == 0 && characters.Count > 0)
|
||||
{
|
||||
foreach (string key in characters.Keys)
|
||||
{
|
||||
KnownCharacters[key] = characters[key];
|
||||
}
|
||||
}
|
||||
return characters;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules
|
||||
{
|
||||
return (id, name, args) =>
|
||||
{
|
||||
return id switch
|
||||
Character? character = id switch
|
||||
{
|
||||
1 => new OshimaShiya(),
|
||||
2 => new XinYin(),
|
||||
@ -42,6 +49,13 @@ namespace Oshima.FunGame.OshimaModules
|
||||
12 => new Quduoduo(),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
if (character is null && KnownCharacters.Values.FirstOrDefault(i => i.Id == id) is Character known)
|
||||
{
|
||||
character = known.Copy();
|
||||
}
|
||||
|
||||
return character;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,12 +11,21 @@ namespace Oshima.FunGame.OshimaModules
|
||||
public override string Description => OshimaGameModuleConstant.Description;
|
||||
public override string Version => OshimaGameModuleConstant.Version;
|
||||
public override string Author => OshimaGameModuleConstant.Author;
|
||||
public Dictionary<string, Item> KnownItems { get; } = [];
|
||||
|
||||
public override Dictionary<string, Item> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return Factory.GetGameModuleInstances<Item>(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Item);
|
||||
Dictionary<string, Item> items = Factory.GetGameModuleInstances<Item>(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Item);
|
||||
if (KnownItems.Count == 0 && items.Count > 0)
|
||||
{
|
||||
foreach (string key in items.Keys)
|
||||
{
|
||||
KnownItems[key] = items[key];
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +33,7 @@ namespace Oshima.FunGame.OshimaModules
|
||||
{
|
||||
return (id, name, args) =>
|
||||
{
|
||||
return id switch
|
||||
Item? item = id switch
|
||||
{
|
||||
(long)AccessoryID.攻击之爪8 => new 攻击之爪8(),
|
||||
(long)AccessoryID.攻击之爪20 => new 攻击之爪20(),
|
||||
@ -55,6 +64,13 @@ namespace Oshima.FunGame.OshimaModules
|
||||
(long)GiftBoxID.毕业礼包 => new 毕业礼包(),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
if (item is null && KnownItems.Values.FirstOrDefault(i => i.Id == id) is Item known)
|
||||
{
|
||||
item = known.Copy();
|
||||
}
|
||||
|
||||
return item;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,12 +15,21 @@ namespace Oshima.FunGame.OshimaModules
|
||||
public override string Description => OshimaGameModuleConstant.Description;
|
||||
public override string Version => OshimaGameModuleConstant.Version;
|
||||
public override string Author => OshimaGameModuleConstant.Author;
|
||||
public Dictionary<string, Skill> KnownSkills { get; } = [];
|
||||
|
||||
public override Dictionary<string, Skill> Skills
|
||||
{
|
||||
get
|
||||
{
|
||||
return Factory.GetGameModuleInstances<Skill>(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Skill);
|
||||
Dictionary<string, Skill> skills = Factory.GetGameModuleInstances<Skill>(OshimaGameModuleConstant.General, OshimaGameModuleConstant.Skill);
|
||||
if (KnownSkills.Count == 0 && skills.Count > 0)
|
||||
{
|
||||
foreach (string key in skills.Keys)
|
||||
{
|
||||
KnownSkills[key] = skills[key];
|
||||
}
|
||||
}
|
||||
return skills;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +42,7 @@ namespace Oshima.FunGame.OshimaModules
|
||||
{
|
||||
return (id, name, args) =>
|
||||
{
|
||||
return id switch
|
||||
Skill? skill = id switch
|
||||
{
|
||||
(long)MagicID.冰霜攻击 => new 冰霜攻击(),
|
||||
(long)MagicID.火之矢 => new 火之矢(),
|
||||
@ -90,6 +99,13 @@ namespace Oshima.FunGame.OshimaModules
|
||||
(long)ItemActiveID.礼包 => new 礼包技能(),
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (skill is null && KnownSkills.Values.FirstOrDefault(i => i.Id == id) is Skill known)
|
||||
{
|
||||
skill = known.Copy();
|
||||
}
|
||||
|
||||
return skill;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -999,7 +999,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
{
|
||||
{ "targets", targets.ToArray() }
|
||||
};
|
||||
bool result = item.UseItem(args);
|
||||
bool result = item.UseItem(user, args);
|
||||
if (item.EntityState == EntityState.Deleted)
|
||||
{
|
||||
user.Inventory.Items.Remove(item);
|
||||
@ -1037,7 +1037,7 @@ namespace Oshima.FunGame.OshimaServers.Service
|
||||
msgs.Add($"{item.Name} 的剩余使用次数为 0,无法使用!");
|
||||
result = false;
|
||||
}
|
||||
bool tempResult = item.UseItem(args);
|
||||
bool tempResult = item.UseItem(user, args);
|
||||
if (item.EntityState == EntityState.Deleted)
|
||||
{
|
||||
user.Inventory.Items.Remove(item);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user