基础内容-9
为次级模块增加存档类,仍在思考框架中
This commit is contained in:
@@ -67,5 +67,49 @@ namespace Ichni.RhythmGame
|
||||
this.baseColorDirtyMark = false;
|
||||
this.emissionColorDirtyMark = false;
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.ColorSubmodule_BM(attachedElement, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class ColorSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public Color originalBaseColor;
|
||||
public bool emissionEnabled;
|
||||
public Color originalEmissionColor;
|
||||
public float originalEmissionIntensity;
|
||||
|
||||
public ColorSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ColorSubmodule_BM(BaseElement attachedElement, Color originalBaseColor, bool emissionEnabled,
|
||||
Color originalEmissionColor, float originalEmissionIntensity) : base(attachedElement)
|
||||
{
|
||||
this.originalBaseColor = originalBaseColor;
|
||||
this.emissionEnabled = emissionEnabled;
|
||||
this.originalEmissionColor = originalEmissionColor;
|
||||
this.originalEmissionIntensity = originalEmissionIntensity;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
attachedElement.colorSubmodule = new ColorSubmodule(attachedElement, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
attached.colorSubmodule = new ColorSubmodule(attached, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,45 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
effectList = new List<EffectBase>();
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.EffectSubmodule_BM(attachedElement);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IHaveEffect
|
||||
{
|
||||
public EffectSubmodule effectSubmodule { get; set; }
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class EffectSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public List<EffectBase> effectList;
|
||||
|
||||
public EffectSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EffectSubmodule_BM(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
effectList = new List<EffectBase>();
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
(attachedElement as IHaveEffect).effectSubmodule = new EffectSubmodule(attachedElement);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
(attached as IHaveEffect).effectSubmodule = new EffectSubmodule(attached);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class EffectBase
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
@@ -7,15 +9,58 @@ namespace Ichni.RhythmGame
|
||||
public abstract class SubmoduleBase
|
||||
{
|
||||
public BaseElement attachedElement;
|
||||
|
||||
|
||||
public Submodule_BM matchedBM;
|
||||
|
||||
public SubmoduleBase(BaseElement attachedElement)
|
||||
{
|
||||
this.attachedElement = attachedElement;
|
||||
}
|
||||
|
||||
|
||||
public virtual void InitialRefresh()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract void SaveBM();
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public abstract class Submodule_BM
|
||||
{
|
||||
[System.NonSerialized] public BaseElement attachedElement; //存档类对应的游戏物体
|
||||
public Guid attachedElementGuid;
|
||||
|
||||
public Submodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Submodule_BM(BaseElement attachedElement)
|
||||
{
|
||||
this.attachedElement = attachedElement;
|
||||
attachedElementGuid = attachedElement.elementGuid;
|
||||
}
|
||||
|
||||
public static BaseElement_BM GetElementBM(Guid id)
|
||||
{
|
||||
if (BaseElement_BM.identifier.TryGetValue(id, out BaseElement_BM element_BM))
|
||||
{
|
||||
return element_BM;
|
||||
}
|
||||
|
||||
Debug.LogAssertion("Element not found or do not have id");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BaseElement GetElement(Guid id)
|
||||
{
|
||||
return GetElementBM(id)?.matchedElement;
|
||||
}
|
||||
|
||||
public abstract void ExecuteBM();
|
||||
public abstract void DuplicateBM(BaseElement attached);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ namespace Ichni.RhythmGame
|
||||
endTime = 999;//TODO: 换为songLength
|
||||
}
|
||||
|
||||
public TimeDurationSubmodule(BaseElement attachedElement, float startTime, float endTime) : base(attachedElement)
|
||||
public TimeDurationSubmodule(BaseElement attachedElement, bool isOverridingDuration, float startTime, float endTime) : base(attachedElement)
|
||||
{
|
||||
this.isOverridingDuration = false;
|
||||
this.isOverridingDuration = isOverridingDuration;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
@@ -73,5 +73,42 @@ namespace Ichni.RhythmGame
|
||||
startTime = durations.Min(duration => duration.x);
|
||||
endTime = durations.Max(duration => duration.y);
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TimeDurationSubmodule_BM(attachedElement, this);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TimeDurationSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public bool isOverridingDuration;
|
||||
public float startTime, endTime;
|
||||
|
||||
public TimeDurationSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TimeDurationSubmodule_BM(BaseElement attachedElement, TimeDurationSubmodule timeDurationSubmodule) : base(attachedElement)
|
||||
{
|
||||
isOverridingDuration = timeDurationSubmodule.isOverridingDuration;
|
||||
startTime = timeDurationSubmodule.startTime;
|
||||
endTime = timeDurationSubmodule.endTime;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
attachedElement.timeDurationSubmodule = new TimeDurationSubmodule(attachedElement, isOverridingDuration, startTime, endTime);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
attached.timeDurationSubmodule = new TimeDurationSubmodule(attached, isOverridingDuration, startTime, endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,7 @@ namespace Ichni.RhythmGame
|
||||
public bool scaleDirtyMark;
|
||||
|
||||
public bool eulerAnglesOffsetLock;
|
||||
|
||||
public UnityAction OnPositionChanged;
|
||||
public UnityAction OnEulerAnglesChanged;
|
||||
public UnityAction OnScaleChanged;
|
||||
|
||||
|
||||
public TransformSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
@@ -79,5 +76,45 @@ namespace Ichni.RhythmGame
|
||||
|
||||
attachedElement.SetTransformObserver();
|
||||
}
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TransformSubmodule_BM(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TransformSubmodule_BM : Submodule_BM
|
||||
{
|
||||
public Vector3 originalPosition;
|
||||
public Vector3 originalEulerAngles;
|
||||
public Vector3 originalScale;
|
||||
|
||||
public TransformSubmodule_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TransformSubmodule_BM(BaseElement attachedElement, Vector3 originalPosition,
|
||||
Vector3 originalEulerAngles, Vector3 originalScale) :
|
||||
base(attachedElement)
|
||||
{
|
||||
this.originalPosition = originalPosition;
|
||||
this.originalEulerAngles = originalEulerAngles;
|
||||
this.originalScale = originalScale;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GetElement(attachedElementGuid);
|
||||
attachedElement.transformSubmodule = new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(BaseElement attached)
|
||||
{
|
||||
attached.transformSubmodule = new TransformSubmodule(attached, originalPosition, originalEulerAngles, originalScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user