Skip to content

Commit

Permalink
简化干员编写的部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Funny-ppt committed Apr 2, 2024
1 parent 22884de commit ac2c833
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions InfrastSim/TimeDriven/CompositionSkillInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InfrastSim.TimeDriven {
internal record struct CompositionSkillInfo(int UnlockUpgraded, SkillInfo Skill) {
public static implicit operator CompositionSkillInfo(SkillInfo skill) => new(0, skill);
public static implicit operator CompositionSkillInfo((int UnlockUpgraded, SkillInfo Skill) tuple) => new(tuple.UnlockUpgraded, tuple.Skill);
}
}
8 changes: 8 additions & 0 deletions InfrastSim/TimeDriven/OperatorAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace InfrastSim.TimeDriven;

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
internal class OperatorAttribute : Attribute {
public string Name { get; }
public OperatorGroup[] Groups { get; }
public CompositionSkillInfo[] Skills { get; }
}
5 changes: 5 additions & 0 deletions InfrastSim/TimeDriven/OperatorGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace InfrastSim.TimeDriven;
internal record struct OperatorGroup(string GroupName, int GroupUpgraded = 0) {
public static implicit operator OperatorGroup(string group) => new(group);
public static implicit operator OperatorGroup((string name, int upgraded) tuple) => new(tuple.name, tuple.upgraded);
}
11 changes: 11 additions & 0 deletions InfrastSim/TimeDriven/SkillInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InfrastSim.TimeDriven {
internal class SkillInfo {
string Name { get; }

Check warning on line 9 in InfrastSim/TimeDriven/SkillInfo.cs

View workflow job for this annotation

GitHub Actions / build-linux

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 9 in InfrastSim/TimeDriven/SkillInfo.cs

View workflow job for this annotation

GitHub Actions / build-linux

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
}

0 comments on commit ac2c833

Please sign in to comment.