《“组合式”实体(Entity)的实现》的评论 http://www.aisharing.com/archives/475 学习,思考,领悟,分享,收获,我是游戏AI程序员 Wed, 02 Jun 2021 23:00:19 +0000 hourly 1 https://wordpress.org/?v=5.5.15 作者:匿名 http://www.aisharing.com/archives/475/comment-page-1#comment-267935 Wed, 02 Jun 2021 23:00:19 +0000 http://www.aisharing.com/?p=475#comment-267935 回复给匿名

多用组合,少用继承。这是设计模式经常说的一句话。
组合用指针访问外部组件,继承是创建对象。指针很小,对象很大。

]]>
作者:匿名 http://www.aisharing.com/archives/475/comment-page-1#comment-236646 Mon, 20 May 2019 11:56:36 +0000 http://www.aisharing.com/?p=475#comment-236646 能否用类似 Ruby中混入 Mixin 的方式实现组件式的扩展? 这样所有的组件全部组合到Entity上,类似C#的Partial, Entity和它的所有组件结合成一个大类。 这样数据传递就等于在对象的内部进行

]]>
作者:Finney http://www.aisharing.com/archives/475/comment-page-1#comment-227786 Thu, 11 May 2017 14:25:15 +0000 http://www.aisharing.com/?p=475#comment-227786 回复给coffeecat

哈哈,是啊,我自己都没注意,想那个时候unity还远没有这么流行呢

]]>
作者:coffeecat http://www.aisharing.com/archives/475/comment-page-1#comment-227522 Tue, 25 Apr 2017 06:29:36 +0000 http://www.aisharing.com/?p=475#comment-227522 博主好超前啊,11年我才入行,博主已经思考“组合”式引擎与“继承”式引擎的差别了。现在在用unity3d开发游戏,深刻的理解了“万物即对象”。

]]>
作者:yyc http://www.aisharing.com/archives/475/comment-page-1#comment-222453 Fri, 15 May 2015 00:28:03 +0000 http://www.aisharing.com/?p=475#comment-222453 楼主好厉害!我最近也在思考引擎组件化的设计,感觉这个使用组合的设计方式比使用继承方式来实现用户自定义逻辑的方式好。

]]>
作者:龙凼毛毛虫 http://www.aisharing.com/archives/475/comment-page-1#comment-92524 Mon, 07 Jul 2014 03:57:41 +0000 http://www.aisharing.com/?p=475#comment-92524 我以为博主说的就是unity3d呢。

]]>
作者:Finney http://www.aisharing.com/archives/475/comment-page-1#comment-4722 Wed, 09 Oct 2013 08:16:31 +0000 http://www.aisharing.com/?p=475#comment-4722 回复给匿名

组件的继承一般是功能的重用,而不是数据的重用,所以问题不大

]]>
作者:匿名 http://www.aisharing.com/archives/475/comment-page-1#comment-3919 Sun, 08 Sep 2013 12:16:31 +0000 http://www.aisharing.com/?p=475#comment-3919 实体的继承会导致基类的臃肿,组件的继承不会导致组件基类的臃肿吗?

]]>
作者:Finney http://www.aisharing.com/archives/475/comment-page-1#comment-133 Tue, 27 Dec 2011 08:40:56 +0000 http://www.aisharing.com/?p=475#comment-133 回复给davylew

还没用过unity,不过现在这个很火呀,有时间可以研究下,谢谢提供文章连接,一会儿去看看:)

]]>
作者:davylew http://www.aisharing.com/archives/475/comment-page-1#comment-132 Tue, 27 Dec 2011 08:35:35 +0000 http://www.aisharing.com/?p=475#comment-132 使用Components来组合GameObject,的确很方便和灵活,不知道博主对unity3d有没研究,他的引擎结构很不错,因为GameObject是通过组件拼成的,所以可以实现重用功能,例如Unity 中的Prefab系统,这里有篇好文章介绍 http://altdevblogaday.com/2011/05/23/the-top-6-misconceptions-i-had-about-unity/
,关于组件间传递数据,我引用UNITY3D的一些方法,可以使用在某些特定的物体,组成管理器,使用单件类型,通过管理器间接调用组件指针,以及使用类似C#中event delegate的方式,个个组件注册,通过消息管理器来触发Components内的方法。例如:http://www.unifycommunity.com/wiki/index.php?title=Advanced_CSharp_Messenger

]]>