Esempio n. 1
0
        private static bool HandleDumpLocalsEvent(NwPlayer dungeonMaster, CNWSMessage message)
        {
            DumpLocalsType type = (DumpLocalsType)message.PeekMessage <int>(0);

            NwObject target = type switch
            {
                DumpLocalsType.DumpLocals => (message.PeekMessage <uint>(4) & 0x7FFFFFFF).ToNwObject() !,
                DumpLocalsType.DumpAreaLocals => dungeonMaster.ControlledCreature !.Area !,
                DumpLocalsType.DumpModuleLocals => NwModule.Instance,
                _ => throw new ArgumentOutOfRangeException(),
            };

            OnDMDumpLocals eventData = ProcessEvent(new OnDMDumpLocals
            {
                DungeonMaster = dungeonMaster,
                Type          = type,
                Target        = target,
            });

            return(!eventData.Skip);
        }
Esempio n. 2
0
        private byte[] ConvertObject(ImportedObject obj)
        {
            var o = new NwObject();

            {
                o.Name = obj.Name;

                var texs = new List <NwTexture2D>();
                foreach (var t in obj.Textures)
                {
                    var bm = AssetConverter.ToNwTexture2D(t.SrcBitmap, t.Name);
                    texs.Add(bm);
                }

                var cubes = new List <NwCubemap>();

                var mats = new List <NwMaterial>();
                foreach (var m in obj.Materials)
                {
                    var mat = AssetConverter.ToNwMaterial(m, m.Name, ref texs, ref cubes);
                    mats.Add(mat);
                }
                o.Texture2Ds = texs.ToArray();
                o.Cubemaps   = cubes.ToArray();
                o.Materials  = mats.ToArray();
                o.Mesh       = AssetConverter.ToNwMesh(obj.Meshes[0]);

                //o.Height = 1.6f;
                //o.WidthRadius = 0.3f;

                o.PhysicalMaterial = new NwPhysicalMaterial();
            }
            var json = Util.SerializeJson(o);
            var comp = Util.Compress(Encoding.UTF8.GetBytes(json));

            return(comp);
        }
Esempio n. 3
0
 public DateTime GetLocal(NwObject nwObject, string name)
 {
     return(DateTime.UnixEpoch + TimeSpan.FromSeconds(NWScript.GetLocalInt(nwObject, name)));
 }
Esempio n. 4
0
 public VisibilityMode GetPersonalOverride(NwPlayer player, NwObject target)
 {
     return(InternalVariables.PlayerVisibilityOverride(player, target).Value);
 }
Esempio n. 5
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Creature = (NwCreature)objSelf;
     Item     = EventsPlugin.GetEventData("ITEM_OBJECT_ID").ParseObject <NwItem>();
     Result   = EventsPlugin.GetEventData("BEFORE_RESULT").ParseInt().ToBool();
 }
Esempio n. 6
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     CurrentSpeaker = (NwGameObject)objSelf;
     PlayerSpeaker  = NWScript.GetPCSpeaker().ToNwObject <NwPlayer>();
     LastSpeaker    = NWScript.GetLastSpeaker().ToNwObject <NwGameObject>();
 }
Esempio n. 7
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Player   = (NwPlayer)objSelf;
     Henchman = EventsPlugin.GetEventData("INVITED_BY").ParseObject <NwCreature>();
 }
Esempio n. 8
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Sender  = (NwPlayer)objSelf;
     Invited = EventsPlugin.GetEventData("INVITED").ParseObject <NwPlayer>();
 }
Esempio n. 9
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Module = (NwModule)objSelf;
     Old    = EventsPlugin.GetEventData("OLD").ParseInt();
     New    = EventsPlugin.GetEventData("NEW").ParseInt();
 }
Esempio n. 10
0
 private void ContinueWithNative(string scriptName, NwObject objSelf)
 {
     NativeScript.Execute(scriptName, objSelf);
 }
Esempio n. 11
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Player = (NwPlayer)objSelf;
     Target = EventsPlugin.GetEventData("BARTER_TARGET").ParseObject <NwPlayer>();
 }
 public RegistrationData(NwObject nwObject, bool callOriginal = true)
 {
     NwObject     = nwObject;
     CallOriginal = callOriginal;
 }
Esempio n. 13
0
    public TriggerHandlerService(NativeEventService eventService)
    {
        NwTrigger trigger = NwObject.FindObjectsWithTag <NwTrigger>("mytrigger").FirstOrDefault();

        eventService.Subscribe <NwTrigger, TriggerEvents.OnEnter>(trigger, OnTriggerEnter);
    }
Esempio n. 14
0
 public void ClearLocal(NwObject nwObject, string name)
 {
     NWScript.DeleteLocalInt(nwObject, name);
 }
Esempio n. 15
0
    public void SetLocal(NwObject nwObject, string name, DateTime value)
    {
        int seconds = (int)(value.ToUniversalTime() - DateTime.UnixEpoch).TotalSeconds;

        NWScript.SetLocalInt(nwObject, name, seconds);
    }
            public static void Signal(NwObject caster, NwPlaceable target, NwSpell spell, bool harmful = true)
            {
                Event nwEvent = NWScript.EventSpellCastAt(caster, spell.Id, harmful.ToInt()) !;

                NWScript.SignalEvent(target, nwEvent);
            }
Esempio n. 17
0
 protected override void PrepareEvent(NwObject objSelf)
 => Module = (NwModule)objSelf;
Esempio n. 18
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Creature = (NwCreature)objSelf;
     Item     = EventsPlugin.GetEventData("ITEM_OBJECT_ID").ParseObject <NwItem>();
 }
Esempio n. 19
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     PreviousLeader = (NwPlayer)objSelf;
     NewLeader      = EventsPlugin.GetEventData("NEW_LEADER").ParseObject <NwPlayer>();
 }
Esempio n. 20
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Container = (NwItem)objSelf;
     Owner     = EventsPlugin.GetEventData("OWNER").ParseObject <NwCreature>();
 }
Esempio n. 21
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     RejectedBy = (NwPlayer)objSelf;
     SentBy     = EventsPlugin.GetEventData("INVITED_BY").ParseObject <NwPlayer>();
 }
Esempio n. 22
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Player      = (NwPlayer)objSelf;
     Area        = EventsPlugin.GetEventData("AREA").ParseObject <NwArea>();
     NewToModule = EventsPlugin.GetEventData("IS_DM").ParseInt().ToBool();
 }
Esempio n. 23
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     PartyLeader = (NwPlayer)objSelf;
     Kicked      = EventsPlugin.GetEventData("KICKED").ParseObject <NwCreature>();
 }
Esempio n. 24
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Player   = (NwPlayer)objSelf;
     Password = EventsPlugin.GetEventData("PASSWORD");
 }
Esempio n. 25
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Creature = (NwCreature)objSelf;
     Item     = EventsPlugin.GetEventData("ITEM").ParseObject <NwItem>();
     Store    = EventsPlugin.GetEventData("STORE").ParseObject <NwStore>();
 }
Esempio n. 26
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Healer       = (NwCreature)objSelf;
     Target       = EventsPlugin.GetEventData("TARGET_OBJECT_ID").ParseObject <NwCreature>();
     AmountHealed = EventsPlugin.GetEventData("HEAL_AMOUNT").ParseInt();
 }
Esempio n. 27
0
 protected override void PrepareEvent(NwObject objSelf)
 => Player = (NwPlayer)objSelf;
Esempio n. 28
0
 protected override void PrepareEvent(NwObject objSelf)
 {
     Player = (NwPlayer)objSelf;
     Gold   = EventsPlugin.GetEventData("GOLD").ParseInt();
 }
Esempio n. 29
0
        public void SetPersonalOverride(NwPlayer player, NwObject target, VisibilityMode visibilityMode)
        {
            InternalVariableEnum <VisibilityMode> value = InternalVariables.PlayerVisibilityOverride(player, target);

            value.Value = visibilityMode;
        }
Esempio n. 30
0
        public static WorldObject FromNwObject(NwObject obj)
        {
            var o = new WorldObject();

            o.nwObject    = obj;
            o.Name        = obj.Name;
            o.Desc        = obj.Description;
            o.Hash        = obj.Hash;
            o.ItemType    = obj.ItemType;
            o.MaxStack    = obj.MaxStack;
            o.Price       = (int)obj.ItemPrice;
            o.Consume     = obj.ItemConsume;
            o.Sync        = obj.Sync;
            o.Purchasable = obj.Purchasable;

            if (obj.Thumbnail != null)
            {
                o.Icon = Util.ToBitmap(obj.Thumbnail.Image);
            }

            if (!string.IsNullOrWhiteSpace(obj.Tags))
            {
                o.Tags = obj.Tags.Split(',');
            }

            o.Texture2Ds = new Texture2D[obj.Texture2Ds.Length];
            for (var i = 0; i < obj.Texture2Ds.Length; i++)
            {
                o.Texture2Ds[i]           = FromNwTexture2D(obj.Texture2Ds[i]);
                o.Texture2Ds[i].UseMipmap = true;
                o.Texture2Ds[i].MinFilter = OpenTK.Graphics.OpenGL4.TextureMinFilter.LinearMipmapLinear;
                o.Texture2Ds[i].MagFilter = OpenTK.Graphics.OpenGL4.TextureMagFilter.Linear;
                o.Texture2Ds[i].WrapMode  = OpenTK.Graphics.OpenGL4.TextureWrapMode.Repeat;
            }

            o.TextureCubes = new TextureCube[obj.Cubemaps.Length];
            for (var i = 0; i < obj.Cubemaps.Length; i++)
            {
                o.TextureCubes[i]           = FromNwTextureCube(obj.Cubemaps[i]);
                o.TextureCubes[i].UseMipmap = true;
                o.TextureCubes[i].MinFilter = OpenTK.Graphics.OpenGL4.TextureMinFilter.LinearMipmapLinear;
                o.TextureCubes[i].MagFilter = OpenTK.Graphics.OpenGL4.TextureMagFilter.Linear;
                o.TextureCubes[i].WrapMode  = OpenTK.Graphics.OpenGL4.TextureWrapMode.Repeat;
            }

            if (obj.Bones != null && obj.Bones.Length > 0)
            {
                o.Bones = FromNwBones(obj.Bones);
            }

            o.Mesh = FromNwMesh(obj.Mesh);

            o.Materials = new Material[obj.Materials.Length];
            for (var i = 0; i < obj.Materials.Length; i++)
            {
                o.Materials[i] = FromNwMaterial(obj.Materials[i], ref obj.Texture2Ds, ref o.Texture2Ds);
            }

            o.Sounds = new Sound[obj.Sounds.Length];
            for (var i = 0; i < o.Sounds.Length; i++)
            {
                o.Sounds[i] = FromNwSound(obj.Sounds[i]);
            }

            if (obj.Thumbnail != null)
            {
                o.Thumbnail = FromNwTexture2D(obj.Thumbnail);
            }

            o.CollisionShape   = FromNwCollisionShape(obj.CollisionShape);
            o.PhysicalMaterial = FromNwPhysicalMaterial(obj.PhysicalMaterial);

            o.Motions = new Motion[obj.Motions.Length];
            for (var i = 0; i < o.Motions.Length; i++)
            {
                o.Motions[i] = FromNwMotion(obj.Motions[i]);
            }

            var scripts = new List <Assembly>();

            foreach (var s in obj.Scripts)
            {
                try
                {
                    var asm = Assembly.Load(s.Assembly);
                    scripts.Add(asm);
                }
                catch { }
            }
            o.Scripts = scripts.ToArray();

            o.Properties = obj.Properties;

            return(o);
        }