Modding:Simple Particles: Difference between revisions

From Vintage Story Wiki
m
VeryGoodDog moved page Simple Particles to Modding:Simple Particles
No edit summary
m (VeryGoodDog moved page Simple Particles to Modding:Simple Particles)
(One intermediate revision by one other user not shown)
Line 9: Line 9:
</syntaxhighlight>
</syntaxhighlight>


Now we have the property, the only thing left to do is to set the position and spawn the particles into the world. I'm gonna use the <code>OnInteracting</code> method inside the Item class (you can read more about this in the [[Collectible|Collectibles Tutorial]]):
Now we have the property, the only thing left to do is to set the position and spawn the particles into the world. I'm gonna use the <code>OnHeldInteractStart</code> and *Step method inside a custom made Item class (you can read more about this in the [[Collectible|Collectibles Tutorial]]):
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
         public override bool OnInteracting(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        public override void OnHeldInteractStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handHandling)
        {
            handHandling = EnumHandHandling.Handled;
        }
 
         public override bool OnHeldInteractStep(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
         {
         {
             myParticles.minPos = byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight(), 0).Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw);
             myParticles.minPos = byEntity.Pos.XYZ.Add(0, byEntity.EyeHeight(), 0).Ahead(1f, byEntity.Pos.Pitch, byEntity.Pos.Yaw);
             byEntity.World.SpawnParticles(myParticles);
             byEntity.World.SpawnParticles(myParticles);
            return true;
         }
         }
</syntaxhighlight>
</syntaxhighlight>
Confirmedusers, Bureaucrats, editor, Administrators
1,522

edits