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); }
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); }
public DateTime GetLocal(NwObject nwObject, string name) { return(DateTime.UnixEpoch + TimeSpan.FromSeconds(NWScript.GetLocalInt(nwObject, name))); }
public VisibilityMode GetPersonalOverride(NwPlayer player, NwObject target) { return(InternalVariables.PlayerVisibilityOverride(player, target).Value); }
protected override void PrepareEvent(NwObject objSelf) { Creature = (NwCreature)objSelf; Item = EventsPlugin.GetEventData("ITEM_OBJECT_ID").ParseObject <NwItem>(); Result = EventsPlugin.GetEventData("BEFORE_RESULT").ParseInt().ToBool(); }
protected override void PrepareEvent(NwObject objSelf) { CurrentSpeaker = (NwGameObject)objSelf; PlayerSpeaker = NWScript.GetPCSpeaker().ToNwObject <NwPlayer>(); LastSpeaker = NWScript.GetLastSpeaker().ToNwObject <NwGameObject>(); }
protected override void PrepareEvent(NwObject objSelf) { Player = (NwPlayer)objSelf; Henchman = EventsPlugin.GetEventData("INVITED_BY").ParseObject <NwCreature>(); }
protected override void PrepareEvent(NwObject objSelf) { Sender = (NwPlayer)objSelf; Invited = EventsPlugin.GetEventData("INVITED").ParseObject <NwPlayer>(); }
protected override void PrepareEvent(NwObject objSelf) { Module = (NwModule)objSelf; Old = EventsPlugin.GetEventData("OLD").ParseInt(); New = EventsPlugin.GetEventData("NEW").ParseInt(); }
private void ContinueWithNative(string scriptName, NwObject objSelf) { NativeScript.Execute(scriptName, objSelf); }
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; }
public TriggerHandlerService(NativeEventService eventService) { NwTrigger trigger = NwObject.FindObjectsWithTag <NwTrigger>("mytrigger").FirstOrDefault(); eventService.Subscribe <NwTrigger, TriggerEvents.OnEnter>(trigger, OnTriggerEnter); }
public void ClearLocal(NwObject nwObject, string name) { NWScript.DeleteLocalInt(nwObject, name); }
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); }
protected override void PrepareEvent(NwObject objSelf) => Module = (NwModule)objSelf;
protected override void PrepareEvent(NwObject objSelf) { Creature = (NwCreature)objSelf; Item = EventsPlugin.GetEventData("ITEM_OBJECT_ID").ParseObject <NwItem>(); }
protected override void PrepareEvent(NwObject objSelf) { PreviousLeader = (NwPlayer)objSelf; NewLeader = EventsPlugin.GetEventData("NEW_LEADER").ParseObject <NwPlayer>(); }
protected override void PrepareEvent(NwObject objSelf) { Container = (NwItem)objSelf; Owner = EventsPlugin.GetEventData("OWNER").ParseObject <NwCreature>(); }
protected override void PrepareEvent(NwObject objSelf) { RejectedBy = (NwPlayer)objSelf; SentBy = EventsPlugin.GetEventData("INVITED_BY").ParseObject <NwPlayer>(); }
protected override void PrepareEvent(NwObject objSelf) { Player = (NwPlayer)objSelf; Area = EventsPlugin.GetEventData("AREA").ParseObject <NwArea>(); NewToModule = EventsPlugin.GetEventData("IS_DM").ParseInt().ToBool(); }
protected override void PrepareEvent(NwObject objSelf) { PartyLeader = (NwPlayer)objSelf; Kicked = EventsPlugin.GetEventData("KICKED").ParseObject <NwCreature>(); }
protected override void PrepareEvent(NwObject objSelf) { Player = (NwPlayer)objSelf; Password = EventsPlugin.GetEventData("PASSWORD"); }
protected override void PrepareEvent(NwObject objSelf) { Creature = (NwCreature)objSelf; Item = EventsPlugin.GetEventData("ITEM").ParseObject <NwItem>(); Store = EventsPlugin.GetEventData("STORE").ParseObject <NwStore>(); }
protected override void PrepareEvent(NwObject objSelf) { Healer = (NwCreature)objSelf; Target = EventsPlugin.GetEventData("TARGET_OBJECT_ID").ParseObject <NwCreature>(); AmountHealed = EventsPlugin.GetEventData("HEAL_AMOUNT").ParseInt(); }
protected override void PrepareEvent(NwObject objSelf) => Player = (NwPlayer)objSelf;
protected override void PrepareEvent(NwObject objSelf) { Player = (NwPlayer)objSelf; Gold = EventsPlugin.GetEventData("GOLD").ParseInt(); }
public void SetPersonalOverride(NwPlayer player, NwObject target, VisibilityMode visibilityMode) { InternalVariableEnum <VisibilityMode> value = InternalVariables.PlayerVisibilityOverride(player, target); value.Value = visibilityMode; }
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); }