1. Hello. Working on a plugin, and running into an issue trying to get the MapMarkerCH47 for a CH47Helicopter (or vice versa). The frustrating part is that at one point I did get the related objects, but I mistakenly deleted the code that would have allowed me to find this association. I don't know if I had the entire object but I at least found the reference. I know this because I saw both the CH47Helicopter and some AI component in my debug printing. :(

    Code:
            void DumpToConsole(object obj)
            {
                Puts(JsonConvert.SerializeObject(obj));
            }        void OnEntitySpawned(BaseNetworkable entity)
            {
                // Puts(entity.GetType().Name);
                if (entity is CH47Helicopter)
                {
                    // DumpToConsole(entity.GetType().GetMethods());
                    var links = (entity as CH47Helicopter).GetEntityLinks(true);
                    Puts("*");
                    DumpToConsole(links);
                    Puts("**");
                }
            }
    The reason I want to do this is because I can check the prefab on the CH47Helicopter and determine if I can remove the marker for it if it's player spawned (
    assets/prefabs/npc/ch47/ch47.entity.prefab)

    Thanks in advance!
     
  2. I'm still learns how to do this all so I'm just gonna throw out ideas and i have no idea if any of them are possible and i cant look into the assemble im not at my computer atm.

    1. Track children when you spawn the CH47 and any child data

    2.Use wild cards of map markers
     
  3. Thanks for the response, I appreciate it.

    Worth looking into, I suppose, if they're there. The frustrating thing is that I had the way to find the association at some point, but lost it because I was just noodling around.

    Sadly, this would remove the regular chinook as well.
     
  4. The CH47Helicopter class has a CreateMapMarker function. This function sets the mapMarkerInstance field. Even though this field is private, you can still access it with a bit of reflection. (Note: rust has been exposing variables over the last few patches, the code below will work if this field is swapped to public, however, it should be changed for optimization)

    [​IMG]

    Code:
    CH47Helicopter heli = (CH47Helicopter)entity;
                  
    MapMarkerCH47 mapMarker = (MapMarkerCH47)heli.GetType().GetField("mapMarkerInstance", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(heli);
    Where heli is the CH47Helicopter entity.

    In this, GetField is using BindingFlags Public and NonPublic, this prevents the code from erroring in the event that rust changes the field to public.

    As a side note, I did not check if the field actually contains a MapMarkerCh47 object. It is a BaseEntity by default, however, it should cast just find.

    As another note, You can also set the value of private variables with code like this

    Code:
    light.GetType().GetField("secondsRemaining", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).SetValue(light, 100000f);
     
  5. Thanks and sorry about the super late response; I was dealing with my server not showing on the server list for a while and had nearly given up on development. Just curious, how did you get the class information? In my attempts, I have been getting far less from the classes. :(
     
  6. Sorry for my late response as well. I downloaded dnSpy by 0xd4d and opened the Assembly-CSharp.dll provided by Oxide in it.

    To find the class name for the Helicopter, I created a plugin that ran the following.


    Code:
    BaseEntity entity = player.GetCursorObject();
    player.ChatMessage(entity.GetType().Name);
    Where player.GetCursorObject is an extensible function with this definition

    Code:
    public static class PlayerExtensibles
        {
            public static BaseEntity GetCursorObject(this BasePlayer player)
            {
                RaycastHit RayHit;
                bool flag1 = Physics.Raycast(player.eyes.HeadRay(), out RayHit, 5f);
                BaseEntity TargetEntity = flag1 ? RayHit.GetEntity() : null;
                return TargetEntity;
            }
        }
    From this, I had the class name of the entity and within dnSpy I could find that class in the assembly and view all of the code I could access.