mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-16 12:33:47 +00:00
Make shallow copies of resources
This commit is contained in:
parent
c318bd8c13
commit
0203af4642
8 changed files with 55 additions and 15 deletions
|
|
@ -39,7 +39,7 @@ public partial class BulletResource : Resource
|
|||
Modifier = Modifier,
|
||||
LifeTime = LifeTime,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
TimeModifiers = TimeModifiers.ToList()
|
||||
TimeModifiers = TimeModifiers.Select(x => x.MakeClone()).ToList()
|
||||
// TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().Select(m => new ModifierWrapper()
|
||||
// {
|
||||
// TimeModifier = m,
|
||||
|
|
|
|||
12
Scripts/Resources/TestGeneric/GenericTestNode.cs
Normal file
12
Scripts/Resources/TestGeneric/GenericTestNode.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.TestGeneric;
|
||||
|
||||
public partial class GenericTestNode : Node2D
|
||||
{
|
||||
|
||||
[Export] public GenericTestResourceBase TestResource { get; set; } = null!;
|
||||
|
||||
|
||||
|
||||
}
|
||||
15
Scripts/Resources/TestGeneric/GenericTestResourceBase.cs
Normal file
15
Scripts/Resources/TestGeneric/GenericTestResourceBase.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.TestGeneric;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class GenericTestResourceBase : Resource
|
||||
{
|
||||
[Export]
|
||||
public int Value { get; set; }
|
||||
|
||||
public void Test()
|
||||
{
|
||||
var asfd = this.MemberwiseClone() as GenericTestResourceBase;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ public partial class TimeModifier : Resource
|
|||
[Export] public TimeModifierType ModifierType;
|
||||
[Export] public float Value;
|
||||
[Export] public bool Continuous = false;
|
||||
public bool Applied { get; set; } = false;
|
||||
|
||||
public ModifierWrapper Wrap()
|
||||
{
|
||||
|
|
@ -18,6 +19,11 @@ public partial class TimeModifier : Resource
|
|||
Applied = false
|
||||
};
|
||||
}
|
||||
|
||||
public TimeModifier MakeClone()
|
||||
{
|
||||
return this.MemberwiseClone() as TimeModifier;
|
||||
}
|
||||
}
|
||||
|
||||
public class ModifierWrapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue