98 lines
3.3 KiB
C#
98 lines
3.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public partial class Trail : GameElement, IHaveTransformSubmodule
|
|
{
|
|
public TrailRenderer trailRenderer;
|
|
public Material renderMaterial;
|
|
|
|
public float visibleTimeLength;
|
|
|
|
public TransformSubmodule transformSubmodule { get; set; }
|
|
|
|
public static Trail GenerateElement(string name, Guid id, List<string> tags, bool isFirstGenerated,
|
|
GameElement parentElement, float visibleTimeLength, Material material = null)
|
|
{
|
|
Trail trail = Instantiate(EditorManager.instance.basePrefabs.trail).GetComponent<Trail>();
|
|
trail.trailRenderer = trail.GetComponent<TrailRenderer>();
|
|
|
|
trail.Initialize(name, id, tags, isFirstGenerated, parentElement);
|
|
trail.renderMaterial =
|
|
material == null ? EditorManager.instance.basePrefabs.defaultTrailMaterial : material;
|
|
trail.trailRenderer.material = trail.renderMaterial;
|
|
trail.visibleTimeLength = visibleTimeLength;
|
|
|
|
return trail;
|
|
}
|
|
|
|
protected override void SetDefaultSubmodules()
|
|
{
|
|
transformSubmodule = new TransformSubmodule(this);
|
|
submoduleList.Add(transformSubmodule);
|
|
}
|
|
}
|
|
|
|
public partial class Trail
|
|
{
|
|
public override void SaveBM()
|
|
{
|
|
matchedBM = new Trail_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
|
visibleTimeLength, renderMaterial);
|
|
}
|
|
}
|
|
|
|
public partial class Trail
|
|
{
|
|
public static void SetAllTrails(bool emitting, bool willClear)
|
|
{
|
|
foreach (GameElement x in EditorManager.instance.beatmapContainer.gameElementList)
|
|
{
|
|
if (x is Trail t)
|
|
{
|
|
t.trailRenderer.emitting = emitting;
|
|
if(willClear) t.trailRenderer.Clear();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace Beatmap
|
|
{
|
|
public class Trail_BM : GameElement_BM
|
|
{
|
|
public float visibleTimeLength;
|
|
public string renderMaterialName;
|
|
|
|
public Trail_BM()
|
|
{
|
|
|
|
}
|
|
|
|
public Trail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
|
float visibleTimeLength, Material renderMaterial) : base(elementName, elementGuid, tags,
|
|
attachedElement)
|
|
{
|
|
this.visibleTimeLength = visibleTimeLength;
|
|
this.renderMaterialName = renderMaterial.name;
|
|
}
|
|
|
|
public override void ExecuteBM()
|
|
{
|
|
matchedElement = Trail.GenerateElement(elementName, elementGuid, tags,
|
|
false, GetElement(attachedElementGuid),
|
|
visibleTimeLength); //TODO: Implement Material
|
|
}
|
|
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|
{
|
|
return Trail.GenerateElement(elementName, elementGuid, tags,
|
|
false, parent, visibleTimeLength); //TODO: Implement Material
|
|
}
|
|
}
|
|
}
|
|
} |