public override void SetStaticDefaults() { base.SetStaticDefaults(); if (!Main.dedServ) { HeadLayer.RegisterData(Item.headSlot, new DrawLayerData() { Texture = ModContent.Request <Texture2D>(Texture + "_Head_Glow"), Color = (PlayerDrawSet drawInfo) => new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 75) * 0.8f }); } ClickEffect.ChromaticBurst = ClickerSystem.RegisterClickEffect(Mod, "ChromaticBurst", null, null, 20, () => Color.Lerp(Color.White, Main.DiscoColor, 0.5f), delegate(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, int type, int damage, float knockBack) { bool spawnEffects = true; int chromatic = ModContent.ProjectileType <RGBPro>(); float total = 7f; int i = 0; while (i < total) { float hasSpawnEffects = spawnEffects ? 1f : 0f; Vector2 toDir = Vector2.UnitX * 0f; toDir += -Vector2.UnitY.RotatedBy(i * (MathHelper.TwoPi / total)) * new Vector2(10f, 10f); int damageAmount = (int)(damage * 0.33f); damageAmount = damageAmount < 1 ? 1 : damageAmount; Projectile.NewProjectile(source, position, toDir.SafeNormalize(Vector2.UnitY) * 10f, chromatic, damageAmount, 1f, Main.myPlayer, 0f, hasSpawnEffects); i++; spawnEffects = false; } }); }
public override void SetStaticDefaults() { base.SetStaticDefaults(); if (!Main.dedServ) { HeadLayer.RegisterData(Item.headSlot, new DrawLayerData() { Texture = ModContent.Request <Texture2D>(Texture + "_Head_Glow"), Color = (PlayerDrawSet drawInfo) => Color.White * 0.8f * 0.75f }); } }
public override void SetStaticDefaults() { base.SetStaticDefaults(); if (!Main.dedServ) { glowmask = ModContent.Request <Texture2D>(Texture + "_Glow"); HeadLayer.RegisterData(Item.headSlot, new DrawLayerData() { Texture = ModContent.Request <Texture2D>(Texture + "_Head_Glow") }); } }
public IEnumerator CombineTest() { try { _dispatcher = new MessageDispatcher(1); _protobuf = new ProtobufLayer(12); _head = new HeadLayer(); _kcp = new KcpLayer(0); _udp = new UdpLayer(); _dispatcher.Link(_protobuf); _protobuf.Link(_head); _head.Link(_kcp); _kcp.Link(_udp); _dispatcher.AddListener <Person>(0, person => { _receivedObj = person; }); _head.BindMsgNumToType(0, typeof(Person)); _udp2 = new UdpLayer(); _udp2.Recv += pack => { var bytes = pack.ReadAllBytes(); var newPack = DataPackPool.GetDataPack(0, bytes); _udp2.Send(newPack); }; _udp.Connect("127.0.0.1", 10001, 10000); yield return(null); _udp2.Connect("127.0.0.1", 10000, 10001); yield return(null); var msgObj = new Person { Email = "*****@*****.**", Id = 1, Name = "Meow", Phone = new List <Person.PhoneNumber> { new Person.PhoneNumber { Number = "13512347890", Type = Person.PhoneType.HOME }, new Person.PhoneNumber { Number = "13823455678", Type = Person.PhoneType.MOBILE }, new Person.PhoneNumber { Number = "15867893456", Type = Person.PhoneType.WORK } } }; _dispatcher.Send(0, msgObj); yield return(null); for (var i = 0; i < 50; i++) { _kcp.Update(); _udp.Update(); _udp2.Update(); yield return(null); } } finally { _kcp.Dispose(); _udp.Dispose(); _udp2.Dispose(); } Assert.AreEqual("*****@*****.**", _receivedObj.Email); Assert.AreEqual(1, _receivedObj.Id); Assert.AreEqual("Meow", _receivedObj.Name); Assert.AreEqual("13512347890", _receivedObj.Phone[0].Number); Assert.AreEqual(Person.PhoneType.HOME, _receivedObj.Phone[0].Type); Assert.AreEqual("13823455678", _receivedObj.Phone[1].Number); Assert.AreEqual(Person.PhoneType.MOBILE, _receivedObj.Phone[1].Type); Assert.AreEqual("15867893456", _receivedObj.Phone[2].Number); Assert.AreEqual(Person.PhoneType.WORK, _receivedObj.Phone[2].Type); }
public IEnumerator UdpLayerSendBytesTest() { try { _head1 = new HeadLayer(); _head1.Recv += pack => { _head1VersionNum = (int)pack.DataDict["VersionNum"].Data; _head1MsgNum = (int)pack.DataDict["MsgNum"].Data; _head1MsgBodyLength = pack.DataDict["MsgBody"].Length; }; _head2 = new HeadLayer(); _head2.Recv += pack => { _head2VersionNum = (int)pack.DataDict["VersionNum"].Data; _head2MsgNum = (int)pack.DataDict["MsgNum"].Data; _head2MsgBodyLength = pack.DataDict["MsgBody"].Length; }; _udp1 = new UdpLayer(); _udp2 = new UdpLayer(); _head1.Link(_udp1); _head2.Link(_udp2); _udp1.Connect("127.0.0.1", 10001, 10000); yield return(null); _udp2.Connect("127.0.0.1", 10000, 10001); DataPack dataPack1 = new DataPack(); dataPack1.TryAddDataToDict("VersionNum", -1, -1, 0, typeof(int)); dataPack1.TryAddDataToDict("MsgNum", -1, -1, 10, typeof(int)); dataPack1.TryAddDataToDict("MsgBody", -1, 30, null, null); DataPack dataPack2 = new DataPack(); dataPack2.TryAddDataToDict("VersionNum", -1, -1, 1, typeof(int)); dataPack2.TryAddDataToDict("MsgNum", -1, -1, 11, typeof(int)); dataPack2.TryAddDataToDict("MsgBody", -1, 31, null, null); yield return(null); _head1.Send(dataPack1); yield return(null); _head2.Send(dataPack2); yield return(null); for (var i = 0; i < 50; i++) { yield return(null); _udp1.Update(); _udp2.Update(); } } finally { _udp1.Dispose(); _udp2.Dispose(); } Assert.AreEqual(0, _head2VersionNum); Assert.AreEqual(10, _head2MsgNum); Assert.AreEqual(30, _head2MsgBodyLength); Assert.AreEqual(1, _head1VersionNum); Assert.AreEqual(11, _head1MsgNum); Assert.AreEqual(31, _head1MsgBodyLength); }