Skip to content

gameObjectScript

mtanksl edited this page Dec 11, 2023 · 2 revisions

Introduction

Behaviours can be attached during game object creation, using GameObjectScript.

Example

Let's attach a new Behaviour to all the monsters.

public class MonsterScript : GameObjectScript<string, Monster>
{
    public override string Key
    {
        get
        {
            return "";
        }
    }

    public override void Start(Monster monster)
    {
        if (monster.Metadata.Sentences != null && monster.Metadata.Sentences.Length > 0)
        {
            Context.Server.GameObjectComponents.AddComponent(monster, new CreatureTalkBehaviour(TalkType.MonsterSay, monster.Metadata.Sentences) );
        }
    }

    public override void Stop(Monster monster)
    {

    }
}