Anime-Game-Servers / Grasscutter-Quests

A server software implementation, ineroperable with a certain anime game client. The code in this repository is fully custom made for edyoucational purposes and future preservation, no copyrighted code is allowed in this repository.
https://grasscutters.xyz/grasscutter
GNU Affero General Public License v3.0
133 stars 31 forks source link

[Feature Request] Add Viewpoints #108

Closed scooterboo closed 4 months ago

scooterboo commented 8 months ago

Is your feature request related to a problem? Please describe. The feature request is not related to a problem. This is just a good first pr kinda thing.

Describe the solution you'd like

Viewpoints are these purple things. image

To implement them, add ViewPoint to this switch here in EntityGadget.buildContent: image You will then need to make GadgetViewPoint.java that matches those other gadget types.

in onInteract(), you need to read the groupId and the ConfigId by doing something like:

        var entity = player.getScene().getEntityById(req.getGadgetEntityId());
        if(entity instanceof EntityGadget entityGadget){
            var groupId = entityGadget.getOwner().getGroupId();
            var configId = entityGadget.getOwner().getConfigId();
        }

You then look up this groupId and configId in ViewCodexExcelConfigData:

    {
        "Id": 70200016,
        "gadgetId": 70800028,
        "sceneId": 3,
        "groupId": 133107133,
        "configId": 133001,
        "nameTextMapHash": 3607590626,
        "descTextMapHash": 325052640,
        "image": "UI_Codex_Scenery_LYfeiyunpo",
        "cityId": 2,
        "worldAreaId": 2701,
        "SortOrder": 102
    }

All you care about is Id. pop that Id into a PacketCodexDataUpdateNotify and bob is your uncle: (7 is a CodexType of CODEX_TYPE_VIEW)

player.getScene().broadcastPacket(new PacketCodexDataUpdateNotify(7,Id));

image