简体   繁体   English

如何在 alt:V 中设置资源依赖项

[英]How to setup resources dependencies in alt:V

I have seen that it is possible to have dependencies between multiple resources.我已经看到多个资源之间可能存在依赖关系。 So that resource1 uses functionality of resource2.因此resource1 使用resource2 的功能。 How does the communication between resources work?资源之间的通信是如何工作的?

When should I separate scripts in different resources?什么时候应该将不同资源中的脚本分开? Is it better to stick to one resource for a whole gamemode or to split it up?将一个资源用于整个游戏模式还是将其拆分更好?

Cheers干杯

Serverside服务器端

Each resource is isolated from each other.每个资源都是相互隔离的。 The resources are using the cpp-sdk for communication.资源使用 cpp-sdk 进行通信。 The isolation is depending on the script runtime.隔离取决于脚本运行时。 Some runtimes like c# support sharing memory between resources, while nodejs doesn't support sharing memory between resources running on different threads.一些运行时如 c# 支持在资源之间共享 memory,而 nodejs 不支持在不同线程上运行的资源之间共享 memory。 You always have to explicitly tell the runtime which functions and data you want to expose to other resources.您总是必须明确地告诉运行时您想要向其他资源公开哪些函数和数据。 This means that you have a small runtime overhead when calling a function or accessing the data, because the communication data needs to be serialized to the unmanaged cpp memory and then back again to the memory of the other resource.这意味着在调用 function 或访问数据时,您的运行时开销很小,因为通信数据需要序列化到非托管 cpp memory,然后再返回到其他资源的 ZCD69B4957F06CD818D7BF3D6811。 When the runtime supports sharing the same memory this overhead doesn't happen between resources with the same type.当运行时支持共享相同的 memory 时,这种开销不会发生在具有相同类型的资源之间。 When sticking to a single resource you don't have the runtime overhead but can't swap out resources individually.坚持使用单个资源时,您没有运行时开销,但无法单独交换资源。

Clientside客户端

Its basically the same as for serverside with the exception that currently only a v8 javascript module exists that doesn't support sharing memory between resources.它与服务器端基本相同,只是目前仅存在一个不支持在资源之间共享 memory 的 v8 javascript 模块。 For clientside the overhead of calling other resources most likely doesn't matter as much as for serverside.对于客户端而言,调用其他资源的开销很可能不如服务器端那么重要。 Especially when you want to reduce the cpu intensive tasks the server main thread has to execute.特别是当您想减少服务器主线程必须执行的 CPU 密集型任务时。 For clientside multiple resources also reduce the amount of data the client has to download, because when you change something in a resource the client has to redownload the whole resource.对于客户端,多个资源也减少了客户端必须下载的数据量,因为当您更改资源中的某些内容时,客户端必须重新下载整个资源。

tl;dr tl;博士

Serverside服务器端

When performance matters most stick to a single resource for serverside.当性能最重要时,最重要的是服务器端的单一资源。 When you need to swap out resources from time to time use multiple resources.当您需要不时更换资源时,请使用多个资源。

Clientside客户端

Use multiple resources when you use resources from other people or want to have a modulized resource.当您使用其他人的资源或想要拥有模块化资源时,请使用多个资源。 Split your assets (mods, images, ...) in as many resources,that make sense, as possible to reduce data download when changes are happening.将您的资产(模组、图像等)拆分为尽可能多的资源,这是有意义的,以减少发生更改时的数据下载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM