📂
Bannerlord Modding CN
  • 骑马与砍杀2 领主 Mod 制作文档
  • C# API Documentation
    • Core
      • MBObjectManager
      • GameModel
      • InformationManager
      • BasicCharacterObject
      • Game
      • ItemObject
    • Campaign System
      • GameMenu
      • Settlement
      • CampaignGameStarter
      • actions
        • ChangeOwnerOfSettlementAction
      • TournamentGame
      • Hero : MBObjectBase, ITrackableCampaignObject, ITrackableBase
      • CampaignBehaviorBase
    • Mount And Blade
      • MissionBehaviour
        • MissionView
        • MissionLogic
      • MBInitialScreenBase
      • Mission
      • MBSubModuleBase
      • agent
      • Team
    • Input System
      • Input
    • Engine
      • GlobalLayer
      • ScriptComponentBehaviour
      • Scene
      • GameEntity
    • Library
      • ModuleInfo
    • Platform Service
    • Save System
    • Localization
      • MBTextManager
      • TextObject
    • Network
    • Two Dimension
  • XML Documentation
    • NPCCharacters
      • NPCCharacter(NPC角色)
        • upgrade_targets
          • upgrade_target
        • equipmentSet
          • equipment
        • Face
          • BodyProperties
          • hair_tags
            • hair_tag
          • BodyPropertiesMax
          • beard_tags
            • beard_tag
          • face_key_template
        • equipment
        • skills
          • skill
        • Traits
          • Trait
    • 物品(大类) Items
      • 物品 Item
        • 物品组件 ItemComponent
          • 马匹 Horse
            • Materials
              • Material
                • MeshMultipliers
                  • MeshMultiplier
          • 防具 Armor
          • Weapon
            • WeaponFlags
          • 食物 Food
        • 旗帜 Flags
      • CraftedItem
        • Pieces
          • Piece
    • Items (XML)
    • Scenes
      • Scene
        • GameType
        • TerrainType
          • TerrainType
    • SPCultures (XML)
    • SPCultures
      • Culture
        • female_names
          • name
        • male_names
          • name
        • clan_names
          • name
    • Atmosphere (XML)
    • SubModule (XML)
    • Scenes (XML)
    • NPCCharacters (XML)
  • Gauntlet
    • Brush
    • GauntletLayer
    • GauntletMovie
    • SceneLayer
    • Movie (XML)
    • Widget
    • GauntletView
    • ScreenBase
    • ViewModel
    • ScreenManager
  • Introduction
    • 高级用法
    • 开始第一步
    • 文件夹结构
    • Defining custom data
  • Tutorials
    • 将你的mod打包上传至Vortex
    • Making Banners
    • 不需要C#的UI系统Mod入门 #
    • 基本 C# Mod
    • new_settlements
  • ru
    • _intro
      • Начало
      • Структура папок
Powered by GitBook
On this page

Was this helpful?

  1. C# API Documentation
  2. Engine

ScriptComponentBehaviour

ScriptComponentBehaviours can be used to do anything from animating (rotating) windmills, to creating a custom weapon spawner, or even entirely new siege machines.

A basic example of a ScriptComponentBehaviour is the LumberJack class in TaleWorlds.MountAndBlade.dll:

    public class Lumberjack : ScriptComponentBehaviour
    {
        private bool _initialized;

        protected internal override void OnTick(float dt)
        {
            base.OnTick(dt);
            if (!this._initialized)
            {
                this._initialized = true;
                base.GameEntity.CreateSimpleSkeleton("human_skeleton");
                base.GameEntity.CopyComponentsToSkeleton();
                base.GameEntity.Skeleton.SetAnimationAtChannel("lumberjack", 0, 1f, -1f, 0f);
                MetaMesh copy = MetaMesh.GetCopy("peasent_hatchet", true, false);
                base.GameEntity.AddMultiMeshToSkeletonBone(copy, 27);
            }
        }
    }

** Note: It is probably better to override OnInit() instead of OnTick() here. Since this is how it was written by TaleWorlds, this example will remain as-is for the time being.

Possible Reason: Meshes can not be Edited/Set etc in OnInit u have to wait atleast a Tick, else ur Game Crashes

PreviousGlobalLayerNextScene

Last updated 4 years ago

Was this helpful?