-
Notifications
You must be signed in to change notification settings - Fork 2
/
SystemTemplate.cs
125 lines (102 loc) · 3.34 KB
/
SystemTemplate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.CodeDom;
using System.Collections;
using System.Linq;
using Invert.Core.GraphDesigner;
using Invert.uFrame.ECS;
using uFrame.Actions;
using uFrame.Attributes;
using uFrame.ECS;
using uFrame.Kernel;
using UnityEngine;
namespace Invert.uFrame.ECS.Templates
{
[ForceBaseType(typeof(EcsSystem))]
[RequiresNamespace("uFrame.ECS")]
[RequiresNamespace("UniRx")]
[RequiresNamespace("UnityEngine")]
public partial class SystemTemplate
{
[GenerateMethod(TemplateLocation.Both), AsOverride, InsideAll]
public void Setup()
{
//Ctx._("Instance = this");
Ctx.CurrentMethod.invoke_base();
foreach (var item in Groups)
{
//Ctx._("{0}Manager = ComponentSystem.RegisterGroup<{0}Group,{0}>({1})", item.Name, item.ComponentId);
var component = item as ComponentNode;
if (component != null)
{
Ctx._("{0}Manager = ComponentSystem.RegisterComponent<{0}>({1})", item.Name, component.ComponentId);
//if (component.BlackBoard)
//{
// Ctx._("BlackBoardSystem.EnsureBlackBoard<{0}>()", item.Name);
//}
}
else
{
Ctx._("{0}Manager = ComponentSystem.RegisterGroup<{0}Group,{1}>()", item.Name, item.ContextTypeName);
}
}
foreach (var item in Ctx.Data.FilterNodes.OfType<ISetupCodeWriter>().ToArray())
{
item.WriteSetupCode(new CSharpSequenceVisitor() {_=Ctx}, Ctx);
}
if (!Ctx.IsDesignerFile)
{
Ctx.CurrentDeclaration.Members.Remove(Ctx.CurrentMethod);
}
}
//[ForEach("Components"), GenerateProperty, WithField]
//public IEcsComponentManagerOf<_ITEMTYPE_> _Name_Manager { get; set; }
[ForEach("Groups"), GenerateProperty, WithField]
public IEcsComponentManagerOf<_ITEM_TYPE_AS_INTERFACE> _Name_Manager { get; set; }
}
public class _ITEM_TYPE_AS_INTERFACE: _ITEMTYPE_
{
public override string TheType(TemplateContext context)
{
var item = context.Item as IMappingsConnectable;
if (item != null)
return item.ContextTypeName;
return base.TheType(context);
}
}
public partial class CustomActionEditableTemplate
{
}
public partial class CustomActionDesignerTemplate
{
}
//public IObservable<_ITEMTYPE_> _Name_Observable
//{
// get
// {
// // return _MaxNavigatorsObservable ?? (_MaxNavigatorsObservable = new Subject<int>());
// }
//}
//public virtual Int32 MaxNavigators
//{
// get
// {
// return _MaxNavigators;
// }
// set
// {
// _MaxNavigators = value;
// if (_MaxNavigatorsObservable != null)
// {
// _MaxNavigatorsObservable.OnNext(value);
// }
// }
//}
//[RequiresNamespace("uFrame.ECS")]
//public partial class OnEventTemplate
//{
//}
//[RequiresNamespace("uFrame.ECS")]
//public partial class PublishTemplate
//{
//}
}