Coder Social home page Coder Social logo

kbengine_hotfix's Introduction

这是一个 KBEngine 脚本热更新方案

完全足够用到官方热更方案出来,相信我你根本用不上 def 和 协议 的热更新。

只要进程 baseapp、cellapp 上有活跃Entity 时才进行热更。

热更时自动处理继承关系,只需要依据继承关系调用。

新创建实体也会自动热更到最新版本。

使用方法

  1. 改写所有 from xxx import xxx 方式 为 import
from xxx import xxx
# 改为
import xxx
  1. 创建加载 Hotfix_Ent 实体

  2. 需要热更的类或实体继承 Hotfix.Hotfix 并增加 onTimer 回调。 公用类型的类不需要回调,只需要继承 Hotfix.Hotfix

import Hotfix
class YouEntity(KBEngine.Entity, Hotfix.Hotfix):
	def __init__(self):
		KBEngine.Entity.__init__(self)
		Hotfix.Hotfix.__init__(self)

	def onTimer(self, id, userArg):
		if userArg == GDefine.TUArg_Hotfix:
            self.Hotfix_Update()
  1. 使用 Hotfix_Ent 实体调用热更
'''
def B_Hotfix_Hotfile(componentType, hotFilenameList)
	componentType:  1 = baseapp
					2 = cellapp
					3 = common
'''

hot = KBEngine.globalData['Hotfix_Ent']
hot.B_Hotfix_Hotfile(1, ['Account', 'parent.C1'])  # 更新 BaseApp Account.py、parent.C1.py 文件
hot.B_Hotfix_Hotfile(1, ['parent.C1'])             # 更新 BaseApp parent.C1.py 文件
hot.B_Hotfix_Hotfile(2, ['Account'])               # 更新 CellApp Account.py 文件
hot.B_Hotfix_Hotfile(3, ['CustomClass'])           # 更新 BaseApp与CellApp 的 CustomClass.py 文件
  1. 更新工具类型 数据类
hot = KBEngine.globalData['Hotfix_Ent']
hot.B_Hotfix_Hotfile(3, ['Functor'])  # 更新 BaseApp Functor.py 文件
hot.B_Hotfix_Hotfile(3, ['d_data'])  # 更新 BaseApp d_data.py 文件

kbengine_hotfix's People

Contributors

ahffffffff avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.