Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server/Mods: Implement Mod Pack functionality #63

Open
5 tasks
assofohdz opened this issue Jan 9, 2023 · 2 comments
Open
5 tasks

Server/Mods: Implement Mod Pack functionality #63

assofohdz opened this issue Jan 9, 2023 · 2 comments

Comments

@assofohdz
Copy link
Owner

assofohdz commented Jan 9, 2023

Implement a system that can load groovy mod packs (much like the dynamic loading of java classes that is in already):

https://github.com/pspeed42/moss/tree/master/action/src/main/java/com/simsilica/action
https://github.com/pspeed42/moss/tree/master/mmod

See also: https://github.com/assofohdz/moss/blob/master/tools/blocked2/src/main/java/com/simsilica/blocked/ScriptState.java

and https://github.com/assofohdz/moss/tree/master/tools/mapper/sample/scripts

This is a lot of new stuff to take in, but would be very cool to have in.

  • Get action and actionenvironment implemented
  • Get mmod implemented
  • Get ScriptState implemented and running
  • How to test?
  • Write a guide/doc on how to use mod packs
@assofohdz assofohdz converted this from a draft issue Jan 9, 2023
@assofohdz assofohdz moved this to Todo or Ready in @assofohdz's Subspace-Infinity Jan 10, 2023
@assofohdz assofohdz moved this from Todo or Ready to In Progress in @assofohdz's Subspace-Infinity Jan 10, 2023
@assofohdz assofohdz self-assigned this Jan 10, 2023
@assofohdz
Copy link
Owner Author

base-apis.json

{
    "groupId":"com.simsilica",
    "name":"base-apis",    
    "formatVersion":"1.0",
    "author":"Simsilica, LLC",
    "version":"1.0",
    dependencies: [
        "com.simsilica:base-includes"
    ],
    initScripts: [
        "base-apis.groovy"
    ],
    config: {
    }
}

modpack json file:

{
    "groupId":"com.simsilica",
    "name":"base-includes",    
    "formatVersion":"1.0",
    "author":"Simsilica, LLC",
    "version":"1.0",
    dependencies: [        
    ],
    initScripts: [
        "base-includes.groovy"
    ],
    config: {
    }
}

base-includes.groovy:

modManager.addGlobalImport("com.simsilica.action.Option");
modManager.addGlobalImport("com.simsilica.action.PromptType");
modManager.addGlobalImport("com.simsilica.mblock.*");
...

Setting up modmanager:

modManager = new ModManager();
        modManager.loadFromResource("/mythruna/base-includes.json");
        modManager.loadFromResource("/mythruna/base-apis.json");
        modManager.loadFromResource("/mythruna/base-object-api.json");
        modManager.loadFromResource("/mythruna/base-hooks-api.json");
        modManager.loadFromResource("/mythruna/base-time-api.json");
        modManager.loadFromResource("/mythruna/base-encounter-api.json");
        modManager.loadFromResource("/mythruna/objects/standard-objects.json");
        modManager.loadFromResource("/mythruna/encounters/standard-encounters.json");
        modManager.loadFromResource("/mythruna/property/base-property.json");
        modManager.loadFromResource("/mythruna/base-accounts.json");
....
        modManager.setGlobalBinding("world", world);

...then sometime later I initialize it.

message.txt

@assofohdz
Copy link
Owner Author

Entity.metadata:

EntityId.metaClass {    
    getAt() { Class c ->
        return entityData.getComponent(delegate, c);
    }
    
    get() { String name ->
        // Look up the object type
        def objectType = objectTypes.getType(delegate);
        return resolveProperty(objectType, delegate, name);
    }

    isSameEntity() { Object other ->
        return resolveEntityId(other)?.id == delegate.id; 
    }
    
    leftShift() { EntityComponent component ->
        entityData.setComponent(delegate, component);
    }

    leftShift() { List components ->
        entityData.setComponents(delegate, components as EntityComponent[]);
    }
    
    remove() { Class type ->
        entityData.removeComponent(delegate, type);
    }
    
    contains() { Object o ->
        def other = resolveEntityId(o);
        def contained = other[ContainedIn];
        if( contained == null ) {
            // It's not contained in anything
            return false;
        }
        // Are we its root?
        if( delegate == contained.root ) {
            // We are their root so contain them by definition
            return true;
        }
        
        // Check the hiearchy starting here
        while( contained != null ) {
            // Are we the container?
            if( delegate == contained.container ) {
                return true;
            }
            // Try the parent
            contained = contained.container[ContainedIn];
        }                
        return false;  
    }
    
    getType() { ->
        return objectTypes.getType(delegate);
    }
    
    getContext() { ->
        return objectTypes.getContext(delegate);
    }        

    run() { ActionEnvironment env, ...vargs ->
        if( log.isDebugEnabled() ) {
            log.debug("run:" + vargs);
        }
        return objectTypes.getContext(delegate).run(env, *vargs);
    }
}

@assofohdz assofohdz moved this from In Progress to Todo or Ready in @assofohdz's Subspace-Infinity Jan 10, 2023
@assofohdz assofohdz removed their assignment Jan 10, 2023
@assofohdz assofohdz moved this from Todo or Ready to In Progress in @assofohdz's Subspace-Infinity Jan 11, 2023
@assofohdz assofohdz self-assigned this Jan 11, 2023
@assofohdz assofohdz moved this from In Progress to Todo or Ready in @assofohdz's Subspace-Infinity Jan 11, 2023
@assofohdz assofohdz removed their assignment Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo or Ready
Development

No branches or pull requests

1 participant