riperiperi / FreeSO

Re-implementation of The Sims Online.
http://freeso.org
Mozilla Public License 2.0
830 stars 97 forks source link

[WIP] Implementing Plugins (EODs) #23

Open riperiperi opened 8 years ago

riperiperi commented 8 years ago

Plugins, or EODs, are TSO's way of adding extra functionality to objects that the normal gameplay of The Sims doesn't allow. They're a large part of what made TSO what it is, and made it easier for people to manage their lots, have fun and make money with others.

image

Our implementation works in a "Client/Server" kind of fashion, where the EOD acts as a standalone server within the simulation. This server is started upon the first call of the SimAntics "Invoke Plugin" primitive, and closed when everyone disconnects. Here's a textdump from VMEODServer:

        When Invoke Plugin is called, the calling thread blocks in the format of an animation.
        The plugin returns EVENTS (short code, short[] dataForTemps) on the false branch.
        These events obviously queue up, multiple per frame and have priority over the final "close".
         - these MUST be synchronised across clients (using commands)! all other comms (UI) are done async

        Plugins can either run on an object, with connections (Thread, ObjectID) (joinable, objects share same plugin)
        ...or run just on their thread alone. (Thread)
        AvatarID specifies who sees the UI and "connects" to the plugin. This can be 0. (Dance Floor Controller connects to itself to get events)

The primitive "Invoke Plugin", as well as providing events allows SimAntics to send events to the plugin server, contained in the specified local. Special event "-2" initiates a connection, while special event "-1" closes one. See VMInvokePlugin.cs for more details.

Plugins need two different handlers, one for UI and one for the "server".

UI handlers are in FSO.Client.UI,Panels.EODs and are managed by UIEODController. They subclass UIEOD, which provides the messaging functionality.

Server handlers are in FSO.SimAntics.NetPlay.EODs.Handlers, and are managed by VMEODServer. They subclass VMEODHandler, which provides some functionality, but most of it (outgoing messages) is through a back reference to the VMEODServer that owns it. Save data for plugin servers is currently accessed via the GlobalLink, and generally tied to the persist id of the object in question. See SignsPlugin for an example.

Have a look at the existing classes to get a feel of how this all works. To implement additional plugins, you will need to watch videos of how they worked, and look at their scripts within Volcanic or Edith.

Plugins to be implemented:

riperiperi commented 7 years ago

PaperChasePlugin has been implemented by @ddfczm - #35

The (UI)EODLobby and StateMachine look like useful classes for the remaining group money objects and war game.

riperiperi commented 7 years ago

Also implemented by @ddfczm - #37

riperiperi commented 7 years ago

[x] ScoreboardPlugin: 0949E698 [x] PermissionDoorPlugin: 0A69F29F

riperiperi commented 7 years ago

Thanks to The Architect: [x] TrunkPlugin: AA5E36DC [x] SlotsPlugin: CB2819CB