Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
scilla-core
Commits
3b34d398
Commit
3b34d398
authored
Jul 17, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
82bc2481
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
126 additions
and
1657 deletions
+126
-1657
Component.ts
src/core/Component.ts
+19
-19
Entity.ts
src/core/Entity.ts
+8
-0
ScillaEngine.ts
src/core/ScillaEngine.ts
+13
-13
Texture.ts
src/core/Texture.ts
+0
-2
index.ts
src/core/index.ts
+1
-2
interpreter.ts
src/core/interpreter.ts
+60
-67
Circle.ts
src/core/nodes/Circle.ts
+0
-53
GraphicNode.ts
src/core/nodes/GraphicNode.ts
+0
-118
Image.ts
src/core/nodes/Image.ts
+0
-194
Node.ts
src/core/nodes/Node.ts
+0
-1113
Rect.ts
src/core/nodes/Rect.ts
+0
-42
index.ts
src/core/nodes/index.ts
+0
-9
utils.ts
src/core/utils.ts
+19
-19
engine-config.ts
src/engine-config.ts
+4
-4
DataCenter.ts
src/support/DataCenter.ts
+2
-2
No files found.
src/core/Component.ts
View file @
3b34d398
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*/
*/
import
HashObject
from
"./HashObject"
;
import
HashObject
from
"./HashObject"
;
import
{
Node
,}
from
"./nodes/Node"
;
import
{
EngineConfig
}
from
"../engine-config"
;
import
{
EngineConfig
}
from
"../engine-config"
;
import
{
Entity
}
from
"./Entity"
;
const
interactiveMap
=
[
const
interactiveMap
=
[
'_dealGlobalTouchBegin'
,
'_dealGlobalTouchBegin'
,
...
@@ -17,9 +17,9 @@ const interactiveMap = [
...
@@ -17,9 +17,9 @@ const interactiveMap = [
*/
*/
export
class
Component
extends
HashObject
{
export
class
Component
extends
HashObject
{
/**
/**
* 所依附的
节点
* 所依附的
实体
*/
*/
node
:
Node
;
entity
:
Entity
;
protected
delayCallbacks
=
[];
protected
delayCallbacks
=
[];
//是否有效
//是否有效
...
@@ -37,7 +37,7 @@ export class Component extends HashObject {
...
@@ -37,7 +37,7 @@ export class Component extends HashObject {
set
enabled
(
value
:
boolean
)
{
set
enabled
(
value
:
boolean
)
{
if
(
this
.
_enabled
!==
value
)
{
if
(
this
.
_enabled
!==
value
)
{
this
.
_enabled
=
value
;
this
.
_enabled
=
value
;
if
(
this
.
node
&&
this
.
node
.
isActive
)
{
if
(
this
.
entity
&&
this
.
entity
.
isActive
)
{
if
(
!
EngineConfig
.
editorMode
)
{
if
(
!
EngineConfig
.
editorMode
)
{
if
(
this
.
_enabled
)
{
if
(
this
.
_enabled
)
{
this
.
onEnable
();
this
.
onEnable
();
...
@@ -50,18 +50,18 @@ export class Component extends HashObject {
...
@@ -50,18 +50,18 @@ export class Component extends HashObject {
}
}
/**
/**
* 装配
节点
* 装配
实体
* @param
node
* @param
entity
*/
*/
_setup
(
node
:
Node
)
{
_setup
(
entity
:
Entity
)
{
this
.
node
=
node
;
this
.
entity
=
entity
;
}
}
/**
/**
* 卸载
节点
* 卸载
实体
*/
*/
_unSetup
()
{
_unSetup
()
{
this
.
node
=
null
;
this
.
entity
=
null
;
}
}
/**
/**
...
@@ -111,12 +111,12 @@ export class Component extends HashObject {
...
@@ -111,12 +111,12 @@ export class Component extends HashObject {
this
.
onEditorUpdate
(
t
);
this
.
onEditorUpdate
(
t
);
}
}
$
onRegression
()
{
$
afterUpdate
()
{
this
.
onRegression
();
this
.
afterUpdate
();
}
}
$
onEditorRegression
()
{
$
afterEditorUpdate
()
{
this
.
onEditorRegression
();
this
.
afterEditorUpdate
();
}
}
private
invokeDelayCallback
(
t
)
{
private
invokeDelayCallback
(
t
)
{
...
@@ -144,13 +144,13 @@ export class Component extends HashObject {
...
@@ -144,13 +144,13 @@ export class Component extends HashObject {
}
}
/**
/**
* 当子
节点
的时钟更新结束后
* 当子
实体
的时钟更新结束后
*/
*/
onRegression
()
{
afterUpdate
()
{
}
}
onEditorRegression
()
{
afterEditorUpdate
()
{
}
}
...
@@ -273,7 +273,7 @@ export class Component extends HashObject {
...
@@ -273,7 +273,7 @@ export class Component extends HashObject {
* @param params 参数
* @param params 参数
*/
*/
broadcast
(
method
,
level
=
-
1
,
...
params
)
{
broadcast
(
method
,
level
=
-
1
,
...
params
)
{
this
.
node
.
broadcast
(
method
,
level
,
...
params
);
this
.
entity
.
broadcast
(
method
,
level
,
...
params
);
}
}
/**
/**
...
@@ -283,6 +283,6 @@ export class Component extends HashObject {
...
@@ -283,6 +283,6 @@ export class Component extends HashObject {
* @param params 参数
* @param params 参数
*/
*/
bubbling
(
method
,
...
params
)
{
bubbling
(
method
,
...
params
)
{
this
.
node
.
bubbling
(
method
,
...
params
);
this
.
entity
.
bubbling
(
method
,
...
params
);
}
}
}
}
src/core/Entity.ts
View file @
3b34d398
...
@@ -122,6 +122,14 @@ export class Entity extends EventDispatcher {
...
@@ -122,6 +122,14 @@ export class Entity extends EventDispatcher {
//----- tree
//----- tree
/**
* 清空所有子实体和所有组件
*/
clean
(){
this
.
removeChildren
();
this
.
removeAllComponents
();
}
/**
/**
* 获取父实体
* 获取父实体
*/
*/
...
...
src/core/ScillaEngine.ts
View file @
3b34d398
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
* 引擎
* 引擎
*/
*/
import
{
Node
,
RootNode
}
from
"./nodes/Node"
;
import
{
injectProp
}
from
"../tools/utils"
;
import
{
injectProp
}
from
"../tools/utils"
;
import
InteractContext
from
"./context/InteractContext"
;
import
InteractContext
from
"./context/InteractContext"
;
import
RenderContext
,
{
ScaleMode
}
from
"./context/RenderContext"
;
import
RenderContext
,
{
ScaleMode
}
from
"./context/RenderContext"
;
...
@@ -12,6 +11,7 @@ import './requestAnimationFrame';
...
@@ -12,6 +11,7 @@ import './requestAnimationFrame';
import
{
AssetsManager
}
from
"../assets-manager"
;
import
{
AssetsManager
}
from
"../assets-manager"
;
import
{
traverse
,
traversePostorder
}
from
"./utils"
;
import
{
traverse
,
traversePostorder
}
from
"./utils"
;
import
DataCenter
from
"../support/DataCenter"
;
import
DataCenter
from
"../support/DataCenter"
;
import
{
Entity
,
RootEntity
}
from
"./Entity"
;
/**
/**
* 引擎类
* 引擎类
...
@@ -36,7 +36,7 @@ export class ScillaEngine {
...
@@ -36,7 +36,7 @@ export class ScillaEngine {
*/
*/
readonly
dataCenterConfig
:
any
=
{};
readonly
dataCenterConfig
:
any
=
{};
private
_root
:
Root
Node
;
private
_root
:
Root
Entity
;
private
_canvasElement
:
HTMLCanvasElement
;
private
_canvasElement
:
HTMLCanvasElement
;
private
_flush
=
0
;
private
_flush
=
0
;
...
@@ -139,7 +139,7 @@ export class ScillaEngine {
...
@@ -139,7 +139,7 @@ export class ScillaEngine {
onUpdateScale
:
this
.
onUpdateScale
.
bind
(
this
),
onUpdateScale
:
this
.
onUpdateScale
.
bind
(
this
),
});
});
this
.
_root
=
new
Root
Node
(
this
);
this
.
_root
=
new
Root
Entity
(
this
);
this
.
_root
.
_restrict
();
this
.
_root
.
_restrict
();
}
}
...
@@ -163,19 +163,19 @@ export class ScillaEngine {
...
@@ -163,19 +163,19 @@ export class ScillaEngine {
}
}
/**
/**
* 获取根
Node
* 获取根
Entity
*/
*/
get
root
():
Node
{
get
root
():
Entity
{
return
this
.
_root
;
return
this
.
_root
;
}
}
/**
/**
* 获取
节点
路径
* 获取
实体
路径
* @param
node
* @param
entity
*/
*/
get
NodePath
(
node
?:
Node
):
string
{
get
EntityPath
(
entity
?:
Entity
):
string
{
let
path
=
''
;
let
path
=
''
;
let
current
=
node
||
this
.
_root
;
let
current
=
entity
||
this
.
_root
;
while
(
current
.
parent
)
{
while
(
current
.
parent
)
{
path
=
current
.
parent
.
children
.
indexOf
(
current
)
+
(
path
.
length
>
0
?
'|'
:
''
)
+
path
;
path
=
current
.
parent
.
children
.
indexOf
(
current
)
+
(
path
.
length
>
0
?
'|'
:
''
)
+
path
;
current
=
current
.
parent
;
current
=
current
.
parent
;
...
@@ -184,10 +184,10 @@ export class ScillaEngine {
...
@@ -184,10 +184,10 @@ export class ScillaEngine {
}
}
/**
/**
* 根据
节点路径获取节点
* 根据
实体路径获取实体
* @param path
* @param path
*/
*/
get
NodeByPath
(
path
?:
string
):
Node
{
get
EntityByPath
(
path
?:
string
):
Entity
{
let
target
=
this
.
_root
;
let
target
=
this
.
_root
;
if
(
path
.
length
>
0
)
{
if
(
path
.
length
>
0
)
{
...
@@ -308,7 +308,7 @@ export class ScillaEngine {
...
@@ -308,7 +308,7 @@ export class ScillaEngine {
return
true
;
return
true
;
}
}
},
-
1
,
true
,
function
(
current
)
{
},
-
1
,
true
,
function
(
current
)
{
current
.
onRegression
();
current
.
$afterUpdate
();
});
});
for
(
let
i
=
0
,
li
=
this
.
nextTicks
.
length
;
i
<
li
;
i
++
)
{
for
(
let
i
=
0
,
li
=
this
.
nextTicks
.
length
;
i
<
li
;
i
++
)
{
...
@@ -356,7 +356,7 @@ export class ScillaEngine {
...
@@ -356,7 +356,7 @@ export class ScillaEngine {
}
}
/**
/**
* 射线测试获取
节点
* 射线测试获取
实体
* 注:暂时只用在编辑器内
* 注:暂时只用在编辑器内
*/
*/
getEntitiesByRayTest
(
x
,
y
,
ignoreMask
=
true
)
{
getEntitiesByRayTest
(
x
,
y
,
ignoreMask
=
true
)
{
...
...
src/core/Texture.ts
View file @
3b34d398
...
@@ -104,8 +104,6 @@ export default class Texture extends HashObject {
...
@@ -104,8 +104,6 @@ export default class Texture extends HashObject {
drawToCanvas
(
context
:
CanvasRenderingContext2D
,
dx
=
0
,
dy
=
0
,
sx
?,
sy
?,
dw
?,
dh
?)
{
drawToCanvas
(
context
:
CanvasRenderingContext2D
,
dx
=
0
,
dy
=
0
,
sx
?,
sy
?,
dw
?,
dh
?)
{
const
{
x
,
y
,
width
,
height
,
offX
,
offY
}
=
this
;
const
{
x
,
y
,
width
,
height
,
offX
,
offY
}
=
this
;
console
.
log
(
x
,
y
,
width
,
height
);
console
.
log
(
sx
||
x
,
sy
||
y
,
width
,
height
,
dx
+
offX
,
dy
+
offY
,
dw
||
width
,
dh
||
height
);
context
.
drawImage
(
this
.
img
,
sx
||
x
,
sy
||
y
,
width
,
height
,
dx
+
offX
,
dy
+
offY
,
dw
||
width
,
dh
||
height
);
context
.
drawImage
(
this
.
img
,
sx
||
x
,
sy
||
y
,
width
,
height
,
dx
+
offX
,
dy
+
offY
,
dw
||
width
,
dh
||
height
);
}
}
...
...
src/core/index.ts
View file @
3b34d398
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*/
*/
export
{
Component
}
from
"./Component"
;
export
{
Component
}
from
"./Component"
;
export
{
Node
,
RootNode
}
from
'./nodes/Node'
export
{
ScillaEvent
}
from
'./ScillaEvent'
export
{
ScillaEvent
}
from
'./ScillaEvent'
export
{
Entity
,
RootEntity
}
from
'./Entity'
export
{
createCanvas
,
ScaleMode
}
from
'./context/RenderContext'
;
export
{
createCanvas
,
ScaleMode
}
from
'./context/RenderContext'
;
export
{
default
as
engine
,
ScillaEngine
}
from
'./ScillaEngine'
export
{
default
as
engine
,
ScillaEngine
}
from
'./ScillaEngine'
...
@@ -13,4 +13,3 @@ export * from './Sheet'
...
@@ -13,4 +13,3 @@ export * from './Sheet'
export
*
from
'./FrameAnimation'
export
*
from
'./FrameAnimation'
export
*
from
'./interpreter'
export
*
from
'./interpreter'
export
*
from
'./nodes'
src/core/interpreter.ts
View file @
3b34d398
...
@@ -4,13 +4,13 @@
...
@@ -4,13 +4,13 @@
* 配置文件解释器
* 配置文件解释器
*/
*/
import
{
Node
}
from
"./nodes/Node
"
;
import
{
Entity
}
from
"./Entity
"
;
import
{
ScillaEvent
}
from
"../core/ScillaEvent"
;
import
{
ScillaEvent
}
from
"../core/ScillaEvent"
;
import
{
EngineConfig
}
from
"../engine-config"
;
import
{
EngineConfig
}
from
"../engine-config"
;
import
engine
from
"./ScillaEngine"
;
import
engine
from
"./ScillaEngine"
;
import
{
traverse
}
from
"./utils"
;
import
{
traverse
}
from
"./utils"
;
let
node
Map
=
{};
let
entity
Map
=
{};
let
prefabID
:
number
=
0
;
let
prefabID
:
number
=
0
;
let
_getResProxy
:
Function
;
let
_getResProxy
:
Function
;
...
@@ -24,7 +24,7 @@ export function setGetResProxy(func: Function) {
...
@@ -24,7 +24,7 @@ export function setGetResProxy(func: Function) {
* @param root
* @param root
* @param getResProxy
* @param getResProxy
*/
*/
export
function
setupScene
(
config
:
any
,
root
:
Node
,
getResProxy
:
Function
)
{
export
function
setupScene
(
config
:
any
,
root
:
Entity
,
getResProxy
:
Function
)
{
setGetResProxy
(
getResProxy
);
setGetResProxy
(
getResProxy
);
instantiateConfig
(
config
,
root
);
instantiateConfig
(
config
,
root
);
...
@@ -34,75 +34,70 @@ export function setupScene(config: any, root: Node, getResProxy: Function) {
...
@@ -34,75 +34,70 @@ export function setupScene(config: any, root: Node, getResProxy: Function) {
* 装配预制体
* 装配预制体
* @param config
* @param config
*/
*/
export
function
instantiate
(
config
:
any
):
Node
{
export
function
instantiate
(
config
:
any
):
Entity
{
let
pid
=
++
prefabID
;
let
pid
=
++
prefabID
;
const
node
=
instantiateConfig
(
config
,
null
,
pid
);
const
entity
=
instantiateConfig
(
config
,
null
,
pid
);
return
node
.
children
[
0
];
return
entity
.
children
[
0
];
}
}
/**
/**
* 装配树
节点
* 装配树
实体
* @param config
* @param config
* @param root
* @param root
* @param pid
* @param pid
*/
*/
function
instantiateConfig
(
config
,
root
?:
Node
,
pid
?:
number
):
Node
{
function
instantiateConfig
(
config
,
root
?:
Entity
,
pid
?:
number
):
Entity
{
let
rootConfig
=
config
.
root
;
let
rootConfig
=
config
.
root
;
const
node
=
setupNode
(
rootConfig
,
root
,
pid
);
const
entity
=
setupEntity
(
rootConfig
,
root
,
pid
);
setupComponent
(
rootConfig
,
node
,
true
);
setupComponent
(
rootConfig
,
entity
,
true
);
injectComponent
(
rootConfig
,
node
,
true
,
pid
);
injectComponent
(
rootConfig
,
entity
,
true
,
pid
);
traverse
(
node
,
child
=>
{
traverse
(
entity
,
child
=>
{
child
.
active
();
child
.
active
();
return
false
;
return
false
;
});
});
node
Map
=
{};
entity
Map
=
{};
return
node
;
return
entity
;
}
}
/**
/**
* 装配
节点
* 装配
实体
* @param config
* @param config
* @param root
* @param root
* @param pid
* @param pid
*/
*/
function
setup
Node
(
config
,
root
?:
Node
,
pid
?:
number
):
Node
{
function
setup
Entity
(
config
,
root
?:
Entity
,
pid
?:
number
):
Entity
{
let
node
:
Node
=
null
;
let
entity
:
Entity
=
null
;
if
(
config
)
{
if
(
config
)
{
let
{
name
,
uuid
,
children
,
base
}
=
config
;
let
{
name
,
uuid
,
children
}
=
config
;
if
(
pid
!==
undefined
&&
uuid
!==
undefined
)
{
if
(
pid
!==
undefined
&&
uuid
!==
undefined
)
{
uuid
=
pid
+
'_'
+
uuid
;
uuid
=
pid
+
'_'
+
uuid
;
}
}
if
(
root
)
{
entity
=
root
||
new
Entity
(
name
,
uuid
);
node
=
root
;
}
else
{
let
temp
=
engine
.
getDefByName
(
base
);
node
=
new
temp
(
name
,
uuid
);
}
nodeMap
[
uuid
]
=
node
;
entityMap
[
uuid
]
=
entity
;
if
(
children
)
{
if
(
children
)
{
for
(
let
i
=
0
,
li
=
children
.
length
;
i
<
li
;
i
++
)
{
for
(
let
i
=
0
,
li
=
children
.
length
;
i
<
li
;
i
++
)
{
let
child
=
children
[
i
];
let
child
=
children
[
i
];
const
child
Node
=
setupNode
(
child
,
null
,
pid
);
const
child
Entity
=
setupEntity
(
child
,
null
,
pid
);
node
.
addChild
(
childNode
);
entity
.
addChild
(
childEntity
);
}
}
}
}
if
(
!
root
)
{
if
(
!
root
)
{
node
.
enabled
=
!
config
.
disabled
;
entity
.
enabled
=
!
config
.
disabled
;
}
}
}
}
return
node
;
return
entity
;
}
}
/**
/**
...
@@ -111,18 +106,18 @@ function setupNode(config, root?: Node, pid?: number): Node {
...
@@ -111,18 +106,18 @@ function setupNode(config, root?: Node, pid?: number): Node {
* @param root
* @param root
* @param includeSelf
* @param includeSelf
*/
*/
function
setupComponent
(
config
,
root
:
Node
,
includeSelf
:
boolean
=
false
)
{
function
setupComponent
(
config
,
root
:
Entity
,
includeSelf
:
boolean
=
false
)
{
if
(
includeSelf
)
{
if
(
includeSelf
)
{
instantiateComponents
(
root
,
config
);
instantiateComponents
(
root
,
config
);
}
}
if
(
config
&&
config
.
children
)
{
if
(
config
&&
config
.
children
)
{
for
(
let
i
=
0
,
li
=
root
.
children
.
length
;
i
<
li
;
i
++
)
{
for
(
let
i
=
0
,
li
=
root
.
children
.
length
;
i
<
li
;
i
++
)
{
const
child
=
config
.
children
[
i
];
const
child
=
config
.
children
[
i
];
const
node
=
root
.
children
[
i
];
const
entity
=
root
.
children
[
i
];
instantiateComponents
(
node
,
child
);
instantiateComponents
(
entity
,
child
);
setupComponent
(
child
,
node
);
setupComponent
(
child
,
entity
);
}
}
}
}
}
}
...
@@ -134,46 +129,44 @@ function setupComponent(config, root: Node, includeSelf: boolean = false) {
...
@@ -134,46 +129,44 @@ function setupComponent(config, root: Node, includeSelf: boolean = false) {
* @param includeSelf
* @param includeSelf
* @param pid
* @param pid
*/
*/
function
injectComponent
(
config
,
root
:
Node
,
includeSelf
=
false
,
pid
?:
number
)
{
function
injectComponent
(
config
,
root
:
Entity
,
includeSelf
=
false
,
pid
?:
number
)
{
if
(
includeSelf
)
{
if
(
includeSelf
)
{
injectComponents
(
root
,
config
,
pid
);
injectComponents
(
root
,
config
,
pid
);
}
}
if
(
config
&&
config
.
children
)
{
if
(
config
&&
config
.
children
)
{
for
(
let
i
=
0
,
li
=
root
.
children
.
length
;
i
<
li
;
i
++
)
{
for
(
let
i
=
0
,
li
=
root
.
children
.
length
;
i
<
li
;
i
++
)
{
const
child
=
config
.
children
[
i
];
const
child
=
config
.
children
[
i
];
const
node
=
root
.
children
[
i
];
const
entity
=
root
.
children
[
i
];
injectComponents
(
node
,
child
,
pid
);
injectComponents
(
entity
,
child
,
pid
);
injectComponent
(
child
,
node
,
false
,
pid
);
injectComponent
(
child
,
entity
,
false
,
pid
);
}
}
}
}
}
}
/**
/**
* 实例化组件列表
* 实例化组件列表
* @param
node
* @param
entity
* @param config
* @param config
*/
*/
function
instantiateComponents
(
node
:
Node
,
config
:
any
)
{
function
instantiateComponents
(
entity
:
Entity
,
config
:
any
)
{
if
(
config
.
components
)
{
if
(
config
.
components
)
{
for
(
const
component
of
config
.
components
)
{
for
(
const
component
of
config
.
components
)
{
instantiateComponent
(
node
,
component
);
instantiateComponent
(
entity
,
component
);
}
}
}
}
}
}
/**
/**
* 注入组件列表参数
* 注入组件列表参数
* @param
node
* @param
entity
* @param config
* @param config
* @param pid
* @param pid
*/
*/
function
injectComponents
(
node
:
Node
,
config
:
any
,
pid
?:
number
)
{
function
injectComponents
(
entity
:
Entity
,
config
:
any
,
pid
?:
number
)
{
injectComponentProperties
(
node
,
config
,
pid
);
if
(
config
.
components
)
{
if
(
config
.
components
)
{
const
components
=
node
.
components
;
const
components
=
entity
.
components
;
for
(
let
i
=
0
,
li
=
config
.
components
.
length
;
i
<
li
;
i
++
)
{
for
(
let
i
=
0
,
li
=
config
.
components
.
length
;
i
<
li
;
i
++
)
{
const
component
=
config
.
components
[
i
];
const
component
=
config
.
components
[
i
];
...
@@ -198,10 +191,10 @@ export function injectComponentProperties(component, config, pid?: number) {
...
@@ -198,10 +191,10 @@ export function injectComponentProperties(component, config, pid?: number) {
/**
/**
* 实例化组件
* 实例化组件
* @param
node
* @param
entity
* @param config
* @param config
*/
*/
export
function
instantiateComponent
(
node
:
Node
,
config
:
any
)
{
export
function
instantiateComponent
(
entity
:
Entity
,
config
:
any
)
{
const
{
script
,}
=
config
;
const
{
script
,}
=
config
;
let
def
=
engine
.
getDefByName
(
script
);
let
def
=
engine
.
getDefByName
(
script
);
...
@@ -212,7 +205,7 @@ export function instantiateComponent(node: Node, config: any) {
...
@@ -212,7 +205,7 @@ export function instantiateComponent(node: Node, config: any) {
const
instance
:
any
=
new
def
();
const
instance
:
any
=
new
def
();
instance
.
enabled
=
!
config
.
disabled
;
instance
.
enabled
=
!
config
.
disabled
;
node
.
addComponent
(
instance
);
entity
.
addComponent
(
instance
);
return
instance
;
return
instance
;
}
}
...
@@ -221,13 +214,13 @@ const skipKeys = ['_type_', '_constructor_'];
...
@@ -221,13 +214,13 @@ const skipKeys = ['_type_', '_constructor_'];
/**
/**
* 属性注入
* 属性注入
* @param
node
* @param
entity
* @param propertiesConfig
* @param propertiesConfig
* @param pid
* @param pid
*/
*/
function
injectProperties
(
node
,
propertiesConfig
,
pid
?:
number
)
{
function
injectProperties
(
entity
,
propertiesConfig
,
pid
?:
number
)
{
if
(
!
node
)
{
if
(
!
entity
)
{
console
.
warn
(
'
node
is null.'
);
console
.
warn
(
'
entity
is null.'
);
return
;
return
;
}
}
for
(
const
key
in
propertiesConfig
)
{
for
(
const
key
in
propertiesConfig
)
{
...
@@ -235,22 +228,22 @@ function injectProperties(node, propertiesConfig, pid?: number) {
...
@@ -235,22 +228,22 @@ function injectProperties(node, propertiesConfig, pid?: number) {
continue
;
continue
;
}
}
const
propertyOfConfig
:
any
=
propertiesConfig
[
key
];
const
propertyOfConfig
:
any
=
propertiesConfig
[
key
];
let
propertyOfInstance
=
node
[
key
];
let
propertyOfInstance
=
entity
[
key
];
if
(
typeof
propertyOfConfig
===
'object'
)
{
if
(
typeof
propertyOfConfig
===
'object'
)
{
if
(
propertyOfInstance
instanceof
ScillaEvent
)
{
if
(
propertyOfInstance
instanceof
ScillaEvent
)
{
if
(
!
EngineConfig
.
editorMode
)
{
if
(
!
EngineConfig
.
editorMode
)
{
injectEvent
(
propertyOfInstance
,
propertyOfConfig
,
pid
);
injectEvent
(
propertyOfInstance
,
propertyOfConfig
,
pid
);
}
}
}
else
if
(
propertyOfConfig
.
_type_
===
'raw'
)
{
}
else
if
(
propertyOfConfig
.
_type_
===
'raw'
)
{
node
[
key
]
=
propertyOfInstance
=
propertyOfConfig
.
data
;
entity
[
key
]
=
propertyOfInstance
=
propertyOfConfig
.
data
;
}
else
{
}
else
{
if
(
Array
.
isArray
(
propertyOfConfig
)
&&
!
propertyOfInstance
)
{
if
(
Array
.
isArray
(
propertyOfConfig
)
&&
!
propertyOfInstance
)
{
node
[
key
]
=
propertyOfInstance
=
[]
entity
[
key
]
=
propertyOfInstance
=
[]
}
}
node
[
key
]
=
injectObject
(
propertyOfInstance
,
propertyOfConfig
,
pid
);
entity
[
key
]
=
injectObject
(
propertyOfInstance
,
propertyOfConfig
,
pid
);
}
}
}
else
{
}
else
{
injectBaseType
(
node
,
key
,
propertyOfConfig
,
pid
);
injectBaseType
(
entity
,
key
,
propertyOfConfig
,
pid
);
}
}
}
}
}
}
...
@@ -275,7 +268,7 @@ function injectObject(propertyOfInstance, propertyOfConfig, pid?: number) {
...
@@ -275,7 +268,7 @@ function injectObject(propertyOfInstance, propertyOfConfig, pid?: number) {
return
propertyOfInstance
;
return
propertyOfInstance
;
}
}
function
injectBaseType
(
node
,
key
,
propertyOfConfig
,
pid
?:
number
)
{
function
injectBaseType
(
entity
,
key
,
propertyOfConfig
,
pid
?:
number
)
{
let
propertyValue
;
let
propertyValue
;
if
(
typeof
propertyOfConfig
===
'string'
)
{
if
(
typeof
propertyOfConfig
===
'string'
)
{
propertyValue
=
getLink
(
propertyOfConfig
,
pid
);
propertyValue
=
getLink
(
propertyOfConfig
,
pid
);
...
@@ -289,23 +282,23 @@ function injectBaseType(node, key, propertyOfConfig, pid?: number) {
...
@@ -289,23 +282,23 @@ function injectBaseType(node, key, propertyOfConfig, pid?: number) {
}
}
if
(
typeof
propertyValue
===
'function'
)
{
if
(
typeof
propertyValue
===
'function'
)
{
Object
.
defineProperty
(
node
,
keyAvatar
,
{
Object
.
defineProperty
(
entity
,
keyAvatar
,
{
get
()
{
get
()
{
return
this
[
`func_
${
keyAvatar
}
`
](
node
,
engine
.
dataCenter
)
return
this
[
`func_
${
keyAvatar
}
`
](
entity
,
engine
.
dataCenter
)
},
},
set
(
v
)
{
set
(
v
)
{
this
[
`func_
${
keyAvatar
}
`
]
=
v
;
this
[
`func_
${
keyAvatar
}
`
]
=
v
;
}
}
})
})
}
}
node
[
keyAvatar
]
=
propertyValue
;
entity
[
keyAvatar
]
=
propertyValue
;
}
}
function
injectEvent
(
event
:
ScillaEvent
,
config
,
pid
?)
{
function
injectEvent
(
event
:
ScillaEvent
,
config
,
pid
?)
{
for
(
const
{
node
:
node
Name
,
component
:
componentIndex
,
method
:
methodName
,
param
}
of
config
)
{
for
(
const
{
entity
:
entity
Name
,
component
:
componentIndex
,
method
:
methodName
,
param
}
of
config
)
{
if
(
node
Name
&&
componentIndex
>=
0
&&
methodName
)
{
if
(
entity
Name
&&
componentIndex
>=
0
&&
methodName
)
{
const
node
=
getLink
(
node
Name
,
pid
);
const
entity
=
getLink
(
entity
Name
,
pid
);
const
component
=
node
.
components
[
componentIndex
];
const
component
=
entity
.
components
[
componentIndex
];
const
method
=
component
[
methodName
];
const
method
=
component
[
methodName
];
if
(
method
)
{
if
(
method
)
{
if
(
param
==
undefined
)
{
if
(
param
==
undefined
)
{
...
@@ -323,9 +316,9 @@ function getLink(str: string, pid?: number) {
...
@@ -323,9 +316,9 @@ function getLink(str: string, pid?: number) {
if
(
str
.
indexOf
(
'res|'
)
==
0
)
{
//res uuid
if
(
str
.
indexOf
(
'res|'
)
==
0
)
{
//res uuid
const
uuid
=
str
.
substr
(
4
);
const
uuid
=
str
.
substr
(
4
);
result
=
_getResProxy
(
uuid
);
result
=
_getResProxy
(
uuid
);
}
else
if
(
str
.
indexOf
(
'
node|'
)
==
0
)
{
//node
uuid
}
else
if
(
str
.
indexOf
(
'
entity|'
)
==
0
)
{
//entity
uuid
const
uuid
=
transPrefabUUID
(
str
.
substr
(
7
),
pid
);
const
uuid
=
transPrefabUUID
(
str
.
substr
(
7
),
pid
);
result
=
node
Map
[
uuid
];
result
=
entity
Map
[
uuid
];
}
else
if
(
str
.
indexOf
(
'dynamic|'
)
==
0
)
{
//dynamic
}
else
if
(
str
.
indexOf
(
'dynamic|'
)
==
0
)
{
//dynamic
const
[
_
,
type
,
expression
]
=
str
.
split
(
'|'
);
const
[
_
,
type
,
expression
]
=
str
.
split
(
'|'
);
result
=
()
=>
{
result
=
()
=>
{
...
...
src/core/nodes/Circle.ts
deleted
100644 → 0
View file @
82bc2481
/**
* Created by rockyl on 2019-07-05.
*
* (圆角)矩形
*/
import
{
GraphicNode
}
from
"./GraphicNode"
;
import
{
dirtyFieldDetector
}
from
"../../tools/decorators"
;
export
class
Circle
extends
GraphicNode
{
/**
* 开始角度
*/
@
dirtyFieldDetector
startAngle
:
number
=
0
;
/**
* 结束角度
*/
@
dirtyFieldDetector
endAngle
:
number
=
360
;
/**
* 是否回归到圆心
*/
@
dirtyFieldDetector
backToCenter
:
boolean
=
true
;
/**
* @inheritDoc
*/
protected
draw
(
context
)
{
const
{
bounds
:
{
width
,
height
},
startAngle
,
endAngle
,
backToCenter
,
_margin
,
_useCacheMode
}
=
this
;
let
offset
=
_useCacheMode
?
_margin
:
0
;
const
radius
=
Math
.
min
(
width
,
height
)
/
2
;
const
pos
=
offset
+
radius
;
if
(
startAngle
==
0
&&
endAngle
==
360
){
context
.
arc
(
pos
,
pos
,
radius
,
0
,
2
*
Math
.
PI
);
}
else
{
if
(
backToCenter
){
context
.
moveTo
(
pos
,
pos
);
}
context
.
arc
(
pos
,
pos
,
radius
,
startAngle
*
Math
.
PI
/
180
,
endAngle
*
Math
.
PI
/
180
);
if
(
backToCenter
){
context
.
lineTo
(
pos
,
pos
);
}
}
super
.
draw
(
context
);
}
}
src/core/nodes/GraphicNode.ts
deleted
100644 → 0
View file @
82bc2481
/**
* Created by rockyl on 2019-07-05.
*
* 绘制节点
*/
import
{
Node
}
from
"./Node"
;
import
{
dirtyFieldDetector
}
from
"../../tools/decorators"
;
import
{
color
}
from
"../../ReType"
;
export
class
GraphicNode
extends
Node
{
/**
* 填充颜色
*/
@
dirtyFieldDetector
fillColor
:
color
=
'#42bce4'
;
/**
* 边框颜色
*/
@
dirtyFieldDetector
borderColor
:
color
=
'white'
;
/**
* 边框宽度
*/
@
dirtyFieldDetector
borderWidth
=
0
;
/**
* 是否为mask
*/
@
dirtyFieldDetector
isMask
=
false
;
/**
* 是否显示mask
*/
@
dirtyFieldDetector
maskVisible
=
false
;
useCacheMode
=
true
;
measureBounds
()
{
super
.
measureBounds
();
this
.
_margin
=
this
.
borderWidth
;
}
protected
getUseCacheMode
(){
return
this
.
_useCacheMode
&&
!
this
.
isMask
;
}
/**
* @inheritDoc
*/
protected
beforeDraw
()
{
super
.
beforeDraw
();
this
.
applyStyle
();
this
.
currentCanvasContext
.
beginPath
();
}
/**
* @inheritDoc
*/
protected
draw
(
context
)
{
super
.
draw
(
context
);
if
(
this
.
isMask
)
{
this
.
_context
.
clip
();
this
.
maskVisible
&&
this
.
fillAndStoke
()
}
else
{
this
.
fillAndStoke
()
}
}
/**
* 应用渲染样式
*/
protected
applyStyle
()
{
const
{
currentCanvasContext
,
fillColor
,
borderColor
,
borderWidth
}
=
this
;
currentCanvasContext
.
fillStyle
=
fillColor
;
if
(
borderWidth
>
0
)
{
currentCanvasContext
.
strokeStyle
=
borderColor
;
currentCanvasContext
.
lineWidth
=
borderWidth
;
}
}
/**
* 绘制
*/
protected
fillAndStoke
()
{
const
{
currentCanvasContext
,
borderWidth
}
=
this
;
currentCanvasContext
.
fill
();
if
(
borderWidth
>
0
)
{
currentCanvasContext
.
stroke
();
}
}
/**
* @inheritDoc
*/
protected
drawClip
()
{
this
.
isMask
&&
this
.
currentCanvasContext
.
save
();
}
/**
* @inheritDoc
*/
onRegression
()
{
this
.
isMask
&&
this
.
currentCanvasContext
.
restore
();
}
onEditorRegression
(){
this
.
onRegression
();
}
}
src/core/nodes/Image.ts
deleted
100644 → 0
View file @
82bc2481
/**
* Created by rockyl on 2019-07-11.
*
* 图片显示类
*/
import
{
Node
,}
from
"./Node"
;
import
Texture
from
"../Texture"
;
import
{
deepDirtyFieldDetector
,
dirtyFieldDetector
}
from
"../../tools/decorators"
;
import
{
Vector2D
}
from
"../../support"
;
import
Bounds
from
"../../support/Bounds"
;
import
{
Sheet
}
from
"../Sheet"
;
export
class
Image
extends
Node
{
/**
* 纹理资源
*/
@
dirtyFieldDetector
texture
:
Texture
;
/**
* 填充模式
*/
@
dirtyFieldDetector
fillMode
:
FillMode
=
FillMode
.
NORMAL
;
/**
* tiled模式的偏移
*/
@
deepDirtyFieldDetector
tiledOffset
:
Vector2D
=
new
Vector2D
();
/**
* 切片边界配置
*/
@
deepDirtyFieldDetector
slicedBounds
:
Bounds
=
new
Bounds
();
protected
_pattern
;
protected
_sheetForSliced
:
Sheet
=
new
Sheet
();
/**
* 异步资源
* @param promise
*/
private
set
async_texture
(
promise
:
Promise
<
Texture
>
)
{
if
(
!
promise
)
{
return
;
}
promise
.
then
(
(
texture
)
=>
{
this
.
texture
=
texture
;
}
)
}
/**
* 重写缓存模式
*/
protected
getUseCacheMode
()
{
return
this
.
_useCacheMode
||
this
.
fillMode
===
FillMode
.
TILED
||
this
.
fillMode
===
FillMode
.
SLICED
;
}
/**
* 准备切片用的图集
*/
protected
prepareSheetForSliced
()
{
if
(
this
.
dirty
&&
!
this
.
slicedBounds
.
isEmpty
)
{
const
sheet
=
this
.
_sheetForSliced
;
sheet
.
cleanAllTexture
();
const
{
sourceW
,
sourceH
}
=
this
.
texture
;
const
{
x
,
y
,
width
,
height
,
right
,
bottom
}
=
this
.
slicedBounds
;
const
xs
=
[
0
,
x
,
right
];
const
ys
=
[
0
,
y
,
bottom
];
const
ws
=
[
x
,
width
,
sourceW
-
right
];
const
hs
=
[
y
,
height
,
sourceH
-
bottom
];
const
frames
=
{};
for
(
let
i
=
0
;
i
<
9
;
i
++
){
let
gx
=
i
%
3
;
let
gy
=
Math
.
floor
(
i
/
3
);
frames
[
i
]
=
{
x
:
xs
[
gx
],
y
:
ys
[
gy
],
width
:
ws
[
gx
],
height
:
hs
[
gy
],}
}
sheet
.
init
(
this
.
texture
,
frames
);
sheet
.
generateAll
();
}
}
protected
draw
(
context
)
{
super
.
draw
(
context
);
this
.
drawImage
(
context
);
}
/**
* 根据模式绘制图片
*/
drawImage
(
context
)
{
if
(
!
this
.
texture
)
{
return
;
}
const
{
texture
,
fillMode
,
width
,
height
}
=
this
;
const
{
x
,
y
,
sourceW
,
sourceH
}
=
texture
;
let
drawWidth
=
width
,
drawHeight
=
height
;
switch
(
fillMode
)
{
case
FillMode
.
NORMAL
:
texture
.
drawToCanvas
(
context
,
0
,
0
,
undefined
,
undefined
,
width
,
height
);
break
;
case
FillMode
.
SLICED
:
this
.
prepareSheetForSliced
();
const
{
x
:
sx
,
y
:
sy
,
right
,
bottom
}
=
this
.
slicedBounds
;
const
rightWidth
=
sourceW
-
right
;
const
bottomHeight
=
sourceH
-
bottom
;
const
xs
=
[
0
,
sx
,
drawWidth
-
rightWidth
];
const
ys
=
[
0
,
sy
,
drawHeight
-
bottomHeight
];
const
ws
=
[
sx
,
drawWidth
-
sx
-
rightWidth
,
rightWidth
];
const
hs
=
[
sy
,
drawHeight
-
sy
-
bottomHeight
,
bottomHeight
];
for
(
let
i
=
0
;
i
<
9
;
i
++
)
{
const
slicedTexture
=
this
.
_sheetForSliced
.
getTexture
(
i
);
let
gx
=
i
%
3
;
let
gy
=
Math
.
floor
(
i
/
3
);
console
.
log
(
xs
[
gx
],
ys
[
gy
]);
slicedTexture
.
drawToCanvas
(
context
,
xs
[
gx
],
ys
[
gy
],
undefined
,
undefined
,
ws
[
gx
],
hs
[
gy
]);
}
break
;
case
FillMode
.
TILED
:
if
(
!
this
.
_pattern
||
texture
[
'isDirty'
])
{
const
textureCanvas
=
texture
.
getCacheCanvas
();
this
.
_pattern
=
context
.
createPattern
(
textureCanvas
,
'repeat'
);
}
if
(
!
this
.
tiledOffset
.
isZero
)
{
const
{
x
:
offX
,
y
:
offY
}
=
this
.
tiledOffset
;
let
x
=
offX
%
sourceW
;
x
=
x
>
0
?
x
-
sourceW
:
x
;
let
y
=
offY
%
sourceH
;
y
=
y
>
0
?
y
-
sourceH
:
y
;
drawWidth
-=
x
;
drawHeight
-=
y
;
context
.
transform
(
1
,
0
,
0
,
1
,
x
,
y
);
}
context
.
beginPath
();
context
.
rect
(
0
,
0
,
drawWidth
,
drawHeight
);
context
.
closePath
();
context
.
fillStyle
=
this
.
_pattern
;
context
.
fill
();
if
(
!
this
.
tiledOffset
.
isZero
)
{
//ctx.restore();
}
break
;
}
}
protected
measureRenderSize
()
{
if
(
this
.
texture
)
{
const
{
sourceW
,
sourceH
}
=
this
.
texture
;
return
{
width
:
sourceW
,
height
:
sourceH
,
}
}
}
}
export
enum
FillMode
{
/**
* 正常
*/
NORMAL
,
/**
* 九宫裁切
*/
SLICED
,
/**
* 瓦片
*/
TILED
,
}
src/core/nodes/Node.ts
deleted
100644 → 0
View file @
82bc2481
This diff is collapsed.
Click to expand it.
src/core/nodes/Rect.ts
deleted
100644 → 0
View file @
82bc2481
/**
* Created by rockyl on 2019-07-05.
*
* (圆角)矩形
*/
import
{
GraphicNode
}
from
"./GraphicNode"
;
import
{
dirtyFieldDetector
}
from
"../../tools/decorators"
;
export
class
Rect
extends
GraphicNode
{
/**
* 圆角
*/
@
dirtyFieldDetector
cornerRadius
=
0
;
/**
* @inheritDoc
*/
protected
draw
(
context
)
{
const
{
PI
}
=
Math
;
const
{
cornerRadius
:
r
,
bounds
:
{
width
,
height
},
_margin
,
_useCacheMode
}
=
this
;
let
offset
=
_useCacheMode
?
_margin
:
0
;
if
(
r
)
{
context
.
moveTo
(
offset
+
r
,
offset
);
context
.
lineTo
(
offset
+
width
-
r
,
offset
);
context
.
arc
(
offset
+
width
-
r
,
offset
+
r
,
r
,
PI
*
3
/
2
,
PI
*
2
);
context
.
lineTo
(
offset
+
width
,
offset
+
height
-
r
);
context
.
arc
(
offset
+
width
-
r
,
offset
+
height
-
r
,
r
,
0
,
PI
/
2
);
context
.
lineTo
(
offset
+
r
,
offset
+
height
);
context
.
arc
(
offset
+
r
,
offset
+
height
-
r
,
r
,
PI
/
2
,
PI
);
context
.
lineTo
(
offset
,
offset
+
r
);
context
.
arc
(
offset
+
r
,
offset
+
r
,
r
,
PI
,
PI
*
3
/
2
);
}
else
{
context
.
rect
(
offset
,
offset
,
width
,
height
);
}
super
.
draw
(
context
);
}
}
src/core/nodes/index.ts
deleted
100644 → 0
View file @
82bc2481
/**
* Created by rockyl on 2019-07-05.
*/
export
*
from
'./Node'
export
*
from
'./GraphicNode'
export
*
from
'./Rect'
export
*
from
'./Circle'
export
*
from
'./Image'
src/core/utils.ts
View file @
3b34d398
/**
/**
* Created by rockyl on 2019-04-22.
* Created by rockyl on 2019-04-22.
*
*
*
节点
相关工具
*
实体
相关工具
*/
*/
import
{
Node
}
from
"./nodes/Node
"
;
import
{
Entity
}
from
"./Entity
"
;
/**
/**
*
节点
遍历(先序遍历)
*
实体
遍历(先序遍历)
* @param target 目标
节点
* @param target 目标
实体
* @param hitChild 遇到子
节点
回调
* @param hitChild 遇到子
实体
回调
* @param level 深度,默认全部遍历
* @param level 深度,默认全部遍历
* @param includeSelf 是否包括自身
* @param includeSelf 是否包括自身
* @param fullCallback 子
节点
遍历完后回调
* @param fullCallback 子
实体
遍历完后回调
* @param params 其他参数
* @param params 其他参数
*/
*/
export
function
traverse
(
target
:
Node
,
hitChild
:
(
child
:
Node
,
...
params
)
=>
boolean
,
level
=
-
1
,
includeSelf
=
false
,
fullCallback
?:
(
current
:
Node
)
=>
void
,
...
params
)
{
export
function
traverse
(
target
:
Entity
,
hitChild
:
(
child
:
Entity
,
...
params
)
=>
boolean
,
level
=
-
1
,
includeSelf
=
false
,
fullCallback
?:
(
current
:
Entity
)
=>
void
,
...
params
)
{
let
interrupt
;
let
interrupt
;
if
(
includeSelf
)
{
if
(
includeSelf
)
{
hitChild
(
target
,
...
params
);
hitChild
(
target
,
...
params
);
...
@@ -37,15 +37,15 @@ export function traverse(target: Node, hitChild: (child: Node, ...params) => boo
...
@@ -37,15 +37,15 @@ export function traverse(target: Node, hitChild: (child: Node, ...params) => boo
}
}
/**
/**
*
节点
遍历(后序遍历且倒序)
*
实体
遍历(后序遍历且倒序)
* @param target 目标
节点
* @param target 目标
实体
* @param hitChild 遇到子
节点
回调
* @param hitChild 遇到子
实体
回调
* @param level 深度,默认全部遍历
* @param level 深度,默认全部遍历
* @param includeSelf 是否包括自身
* @param includeSelf 是否包括自身
* @param fullCallback 子
节点
遍历完后回调
* @param fullCallback 子
实体
遍历完后回调
* @param params 其他参数
* @param params 其他参数
*/
*/
export
function
traversePostorder
(
target
:
Node
,
hitChild
:
(
child
:
Node
,
...
params
)
=>
boolean
,
level
=
-
1
,
includeSelf
=
false
,
fullCallback
?:
(
current
:
Node
)
=>
void
,
...
params
)
{
export
function
traversePostorder
(
target
:
Entity
,
hitChild
:
(
child
:
Entity
,
...
params
)
=>
boolean
,
level
=
-
1
,
includeSelf
=
false
,
fullCallback
?:
(
current
:
Entity
)
=>
void
,
...
params
)
{
if
(
level
!==
0
)
{
if
(
level
!==
0
)
{
for
(
let
i
=
target
.
children
.
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
target
.
children
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
child
=
target
.
children
[
i
];
const
child
=
target
.
children
[
i
];
...
@@ -70,19 +70,19 @@ export function traversePostorder(target: Node, hitChild: (child: Node, ...param
...
@@ -70,19 +70,19 @@ export function traversePostorder(target: Node, hitChild: (child: Node, ...param
}
}
/**
/**
*
节点
冒泡
*
实体
冒泡
* @param target 目标
节点
* @param target 目标
实体
* @param hitParent 遇到父
节点
回调
* @param hitParent 遇到父
实体
回调
* @param includeSelf 是否包括自身
* @param includeSelf 是否包括自身
* @param params 其他参数
* @param params 其他参数
*/
*/
export
function
bubbling
(
target
:
Node
,
hitParent
:
(
parent
:
Node
,
...
params
)
=>
boolean
,
includeSelf
=
false
,
...
params
)
{
export
function
bubbling
(
target
:
Entity
,
hitParent
:
(
parent
:
Entity
,
...
params
)
=>
boolean
,
includeSelf
=
false
,
...
params
)
{
if
(
includeSelf
)
{
if
(
includeSelf
)
{
hitParent
(
target
,
...
params
);
hitParent
(
target
,
...
params
);
}
}
let
node
=
target
;
let
entity
=
target
;
while
(
node
=
node
.
parent
)
{
while
(
entity
=
entity
.
parent
)
{
if
(
hitParent
(
node
,
...
params
))
{
if
(
hitParent
(
entity
,
...
params
))
{
break
;
break
;
}
}
}
}
...
...
src/engine-config.ts
View file @
3b34d398
...
@@ -15,19 +15,19 @@ export const EngineConfig = {
...
@@ -15,19 +15,19 @@ export const EngineConfig = {
*/
*/
lineHeightRatio
:
1.2
,
lineHeightRatio
:
1.2
,
/**
/**
*
节点
实例化时enabled的初始值
*
实体
实例化时enabled的初始值
*/
*/
node
Enabled
:
true
,
entity
Enabled
:
true
,
/**
/**
* 组件实例化时enabled的初始值
* 组件实例化时enabled的初始值
*/
*/
componentEnabled
:
true
,
componentEnabled
:
true
,
/**
/**
* 组件被添加到
节点
树上时是否执行onAwake方法
* 组件被添加到
实体
树上时是否执行onAwake方法
*/
*/
awakeComponentWhenAdded
:
true
,
awakeComponentWhenAdded
:
true
,
/**
/**
* 组件从
节点
树上被移除时是否执行onSleep方法
* 组件从
实体
树上被移除时是否执行onSleep方法
*/
*/
sleepComponentWhenRemoved
:
true
,
sleepComponentWhenRemoved
:
true
,
/**
/**
...
...
src/support/DataCenter.ts
View file @
3b34d398
...
@@ -68,11 +68,11 @@ export default class DataCenter extends EventEmitter {
...
@@ -68,11 +68,11 @@ export default class DataCenter extends EventEmitter {
* @param expression
* @param expression
*/
*/
public
parse
(
type
:
string
,
expression
:
string
)
{
public
parse
(
type
:
string
,
expression
:
string
)
{
let
node
=
this
.
store
[
type
];
let
entity
=
this
.
store
[
type
];
let
result
=
null
;
let
result
=
null
;
try
{
try
{
result
=
utils
.
dotEval
(
expression
,
node
);
result
=
utils
.
dotEval
(
expression
,
entity
);
}
catch
(
e
)
{
}
catch
(
e
)
{
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment