public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { base.ClientSetupSkeleton(item, character, skeletonRenderer, skeletonComponents); if (!this.ItemLightConfig.IsLightEnabled) { return; } var sceneObject = Client.Scene.GetSceneObject(character); var componentLightSource = this.ClientCreateLightSource(item, character, sceneObject); var componentLightInSkeleton = sceneObject.AddComponent <ClientComponentLightInSkeleton>(); componentLightInSkeleton.Setup(character, skeletonRenderer, this.ItemLightConfig, componentLightSource, "Weapon", "Weapon"); skeletonComponents.Add(componentLightSource); skeletonComponents.Add(componentLightInSkeleton); }
public virtual void ClientSetupSkeleton( IItem item, ICharacter character, ProtoCharacterSkeleton protoCharacterSkeleton, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { protoCharacterSkeleton.ClientSetupItemInHand( skeletonRenderer, "WeaponMelee", this.GetCharacterTextureResource(item, character)); var isActive = GetPublicState(item).IsActive; this.ClientSetupSkeletonAnimation(isActive, item, character, skeletonRenderer, skeletonComponents); if (!isActive) { // not active light return; } var sceneObject = character.ClientSceneObject; var componentLightSource = this.ClientCreateLightSource(item, character); var componentLightInSkeleton = sceneObject.AddComponent <ClientComponentLightInSkeleton>(); componentLightInSkeleton.Setup(skeletonRenderer, this.ItemLightConfig, componentLightSource, "Weapon", isPrimaryLight: true); skeletonComponents.Add(componentLightInSkeleton); skeletonComponents.Add(componentLightSource); }
public void StartRecoil( ICharacter character, IProtoItemWeaponRanged weaponProto, IComponentSkeleton skeletonRenderer) { this.character = character; this.weaponProto = weaponProto; this.skeletonRenderer = skeletonRenderer; this.duration = weaponProto.CharacterAnimationAimingRecoilDuration; this.time = 0; // add recoil power this.power += this.RandomizeRecoilPower( this.weaponProto.CharacterAnimationAimingRecoilPower * this.weaponProto.CharacterAnimationAimingRecoilPowerAddCoef); if (this.power > this.weaponProto.CharacterAnimationAimingRecoilPower) { // clamp recoil power this.power = this.weaponProto.CharacterAnimationAimingRecoilPower; } if (!this.IsEnabled) { this.IsEnabled = true; } this.Update(0); }
public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { var isActive = GetPublicState(item).IsActive; if (!isActive) { // not active light return; } var sceneObject = Client.Scene.GetSceneObject(character); var componentLightSource = this.ClientCreateLightSource(item, character, sceneObject); if (componentLightSource == null) { return; } var componentLightInSkeleton = sceneObject.AddComponent <ClientComponentLightInSkeleton>(); componentLightInSkeleton.Setup(character, skeletonRenderer, this.ItemLightConfig, componentLightSource, "Head", "Head"); skeletonComponents.Add(componentLightSource); skeletonComponents.Add(componentLightInSkeleton); }
public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents, bool isPreview) { base.ClientSetupSkeleton(item, character, skeletonRenderer, skeletonComponents, isPreview); if (isPreview || character is null || !character.IsCurrentClientCharacter || !GetPublicState(item).IsActive) { return; } // setup night vision effect for current character var sceneObject = character.ClientSceneObject; var componentNightVisionEffect = sceneObject.AddComponent <ClientComponentNightVisionEffect2>(); skeletonComponents.Add(componentNightVisionEffect); // we need this to disable the light added by the PlayerCharacter class for the current character var componentLightInSkeleton = sceneObject.AddComponent <ClientComponentLightInSkeleton>(); componentLightInSkeleton.IsEnabled = false; skeletonComponents.Add(componentLightInSkeleton); }
public override void ClientSetupSkeleton( IItem item, ICharacter character, ProtoCharacterSkeleton protoCharacterSkeleton, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { base.ClientSetupSkeleton(item, character, protoCharacterSkeleton, skeletonRenderer, skeletonComponents); if (!this.ItemLightConfig.IsLightEnabled) { return; } var sceneObject = character.ClientSceneObject; var componentLightSource = this.ClientCreateLightSource(item, character, sceneObject); var componentLightInSkeleton = sceneObject.AddComponent <ClientComponentLightInSkeleton>(); componentLightInSkeleton.Setup(skeletonRenderer, this.ItemLightConfig, componentLightSource, "Weapon", isPrimaryLight: false); skeletonComponents.Add(componentLightInSkeleton); skeletonComponents.Add(componentLightSource); }
public override void ClientSetupSkeleton( IDynamicWorldObject vehicle, IProtoCharacterSkeleton protoSkeleton, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { var publicState = GetPublicState(vehicle); if (!vehicle.IsInitialized || publicState.PilotCharacter is null || !publicState.PilotCharacter.IsCurrentClientCharacter) { return; } var componentNightVision = vehicle.ClientSceneObject .AddComponent <ClientComponentNightVisionEffectMechNemesis>(); publicState.ClientSubscribe( _ => _.IsLightsEnabled, _ => RefreshNightVision(), subscriptionOwner: GetClientState(vehicle)); RefreshNightVision(); void RefreshNightVision() { componentNightVision.IsEnabled = publicState.IsLightsEnabled; } }
public override void OnSkeletonCreated(IComponentSkeleton skeleton) { base.OnSkeletonCreated(skeleton); // fast attack animation skeleton.SetMixDuration(null, "Attack", 0.0333f, 0.15f); }
public virtual void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents, bool isPreview) { if (this.ClientIsMustUseDefaultAppearance(character, isPreview)) { // the skin is not owned, apply base proto item's appearance instead ((IProtoItemEquipment)this.BaseProtoItem) .ClientSetupSkeleton(item, character, skeletonRenderer, skeletonComponents, isPreview: false); return; } var isMale = PlayerCharacter.GetPublicState(character).IsMale; var slotAttachments = isMale ? this.SlotAttachmentsMale : this.SlotAttachmentsFemale; ClientSkeletonAttachmentsLoader.SetAttachments(skeletonRenderer, slotAttachments); }
public static void SetAttachments( IComponentSkeleton skeletonRenderer, IReadOnlyList <SkeletonSlotAttachment> slotAttachments) { foreach (var skeleton in skeletonRenderer.AllSkeletons) { var skeletonName = skeleton.SkeletonName; foreach (var slotAttachment in slotAttachments) { if (slotAttachment.SkeletonName is not null && !slotAttachment.SkeletonName.Equals(skeletonName, StringComparison.Ordinal)) { // this attachment for different skeleton continue; } if (slotAttachment.AttachmentName.StartsWith("Head", StringComparison.Ordinal)) { // Head attachments are processed by ClientCharacterHeadSpriteComposer // when generating the head sprite. They're not assigned directly to skeleton. continue; } skeletonRenderer.SetAttachmentSprite( skeleton, // auto find slot slotName: null, attachmentName: slotAttachment.AttachmentName, textureResource: slotAttachment.TextureResource); } } }
public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents, bool isPreview) { base.ClientSetupSkeleton(item, character, skeletonRenderer, skeletonComponents, isPreview); if (isPreview || character is null || !character.IsCurrentClientCharacter) { return; } // setup artificial retina effect for current character var sceneObject = character.ClientSceneObject; var componentNightVisionEffect = sceneObject.AddComponent <ClientComponentArtificialRetinaEffect>(); skeletonComponents.Add(componentNightVisionEffect); }
public virtual void ClientSetupItemInHand( IComponentSkeleton skeletonRenderer, string attachmentName, TextureResource textureResource) { skeletonRenderer.SetAttachmentSprite(this.SlotNameItemInHand, attachmentName, textureResource); skeletonRenderer.SetAttachment(this.SlotNameItemInHand, attachmentName); }
public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { // do nothing }
public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { // we don't call basic implementation here //base.ClientSetupSkeleton(item, character, skeletonRenderer); }
public override void ClientSetupSkeleton( IItem item, ICharacter character, ProtoCharacterSkeleton protoCharacterSkeleton, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents, bool isPreview = false) { // do nothing }
public override void ClientResetItemInHand(IComponentSkeleton skeletonRenderer) { skeletonRenderer.SetAttachmentSprite(this.SlotNameItemInHand, attachmentName: "WeaponMelee", textureResource: null); skeletonRenderer.SetAttachmentSprite(this.SlotNameItemInHand, attachmentName: "WeaponRifle", textureResource: null); skeletonRenderer.SetAttachment(this.SlotNameItemInHand, attachmentName: null); }
public virtual void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { ClientSkeletonItemInHandHelper.Setup( skeletonRenderer, "WeaponMelee", this.CharacterTextureResource); }
private static void SetRecoilAnimation( ICharacter character, IProtoItemWeaponRanged weaponProto, IComponentSkeleton skeletonRenderer) { var sceneObject = Api.Client.Scene.GetSceneObject(character); var componentRecoil = sceneObject.FindComponent <ClientComponentCharacterWeaponRecoilAnimation>() ?? sceneObject.AddComponent <ClientComponentCharacterWeaponRecoilAnimation>(); componentRecoil.StartRecoil(character, weaponProto, skeletonRenderer); }
public virtual void ClientSetupSkeleton( IItem item, ICharacter character, ProtoCharacterSkeleton protoCharacterSkeleton, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { protoCharacterSkeleton.ClientSetupItemInHand( skeletonRenderer, "WeaponMelee", this.CharacterTextureResource); }
public override void ClientSetupItemInHand( IComponentSkeleton skeletonRenderer, string attachmentName, TextureResource textureResource) { skeletonRenderer.SetAttachmentSprite(this.SlotNameItemInHand, attachmentName, textureResource); skeletonRenderer.SetAttachment(this.SlotNameItemInHand, attachmentName); // set left hand to use special sprite (representing holding of the item in hand) skeletonRenderer.SetAttachment("HandLeft", "HandLeft2"); skeletonRenderer.SetAttachment("HandLeftEquipment", "HandLeft2Equipment"); }
public static void Setup( IComponentSkeleton skeletonRenderer, string attachmentName, TextureResource textureResource) { skeletonRenderer.SetAttachmentSprite(SlotNameWeapon, attachmentName, textureResource); skeletonRenderer.SetAttachment(SlotNameWeapon, attachmentName); // set left hand to use special sprite (representing holding of the item in hand) skeletonRenderer.SetAttachment(SlotNameHandLeft, "HandLeft2"); skeletonRenderer.SetAttachment(SlotNameHandLeft + "Equipment", "HandLeft2Equipment"); }
public void Setup(IComponentSkeleton skeleton, ICharacter characterPilot) { this.skeleton = skeleton; this.characterPublicState = characterPilot.GetPublicState <ICharacterPublicState>(); this.soundEmitter = Api.Client.Audio.CreateSoundEmitter(this.SceneObject, SoundResource, is3D: !characterPilot.IsCurrentClientCharacter, isLooped: true, isPlaying: true, volume: 0); this.lastAngleRad = this.GetCurrentAngleRad(); }
public virtual void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { var isMale = PlayerCharacter.GetPublicState(character).IsMale; var slotAttachments = isMale ? this.SlotAttachmentsMale : this.SlotAttachmentsFemale; ClientSkeletonAttachmentsLoader.SetAttachments(skeletonRenderer, slotAttachments); }
public override void OnSkeletonCreated(IComponentSkeleton skeleton) { base.OnSkeletonCreated(skeleton); skeleton.SetDefaultMixDuration(0.3f); // setup attack animations { var mixIn = 0.033333f; var mixInStatic = 0.15f; var mixOut = 0.15f; // fast mix-in into attacks, slower mix-out skeleton.SetMixDuration(null, "AttackMeleeHorizontal", mixIn, mixOut); skeleton.SetMixDuration(null, "AttackMeleeHorizontal_Static", mixInStatic, mixOut); skeleton.SetMixDuration(null, "AttackMeleeVertical", mixIn, mixOut); skeleton.SetMixDuration(null, "AttackMeleeVertical_Static", mixInStatic, mixOut); // fast mix between attacks skeleton.SetMixDuration("AttackMeleeHorizontal", "AttackMeleeVertical", mixIn, mixIn); skeleton.SetMixDuration("AttackMeleeHorizontal_Static", "AttackMeleeVertical_Static", mixIn, mixIn); } // disable mix for these movement animations DisableMoveMix("RunUp"); DisableMoveMix("RunDown"); DisableMoveMix("RunSide"); DisableMoveMix("RunSideBackward"); var verticalSpeedMultiplier = 1.1f; skeleton.SetAnimationDefaultSpeed("RunUp", verticalSpeedMultiplier); skeleton.SetAnimationDefaultSpeed("RunUpStart", verticalSpeedMultiplier); skeleton.SetAnimationDefaultSpeed("RunDown", verticalSpeedMultiplier); skeleton.SetAnimationDefaultSpeed("RunDownStart", verticalSpeedMultiplier); void DisableMoveMix(string primaryName) { var startName = primaryName + "Start"; var startAbortName = startName + "Abort"; var minMix = 0.05f; skeleton.SetMixDuration(startName, minMix); skeleton.SetMixDuration(startAbortName, minMix); skeleton.SetMixDuration("Idle", startName, minMix); skeleton.SetMixDuration(startName, primaryName, minMix); skeleton.SetMixDuration(startName, startAbortName, minMix); skeleton.SetMixDuration(startAbortName, "Idle", minMix); skeleton.SetAnimationDefaultSpeed(startAbortName, 1.3f); } }
public override void ClientSetupSkeleton( IItem item, ICharacter character, ProtoCharacterSkeleton protoCharacterSkeleton, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { base.ClientSetupSkeleton(item, character, protoCharacterSkeleton, skeletonRenderer, skeletonComponents); this.ClientRefreshWeaponInHandSprite(item); }
private static void SetFiringAnimation( IProtoItemWeapon weaponProto, IComponentSkeleton skeletonRenderer, byte trackIndex, string fireAnimationName, double fireAnimationDuration, double fireInterval, bool mixWithCurrent, bool isLooped) { var currentFireAnimation = skeletonRenderer.GetCurrentAnimationName(trackIndex); if (currentFireAnimation == fireAnimationName) { // the same firing animation is already playing Api.Logger.Warning( "Will overwrite current attack animation: " + currentFireAnimation + " - usually it means that the DamageApplyDelaySeconds+FireIntervalSeconds is lower than the attack animation duration for " + weaponProto + " (they must be matching perfectly)."); } if (currentFireAnimation != null) { if (mixWithCurrent) { skeletonRenderer.SetAnimationLoopMode(trackIndex, isLooped: false); skeletonRenderer.RemoveAnimationTrackNextEntries(trackIndex); } else { skeletonRenderer.RemoveAnimationTrack(trackIndex); } } // cooldown is a padding duration which makes animation "stuck" on the last frame for the specified duration var cooldownDuration = isLooped // in looped animation we need to match its total duration to fire interval by using cooldown ? Math.Max(0, fireInterval - fireAnimationDuration) : 0; // non-looped animation no cooldown is necessary skeletonRenderer.AddAnimation( trackIndex, animationName: fireAnimationName, isLooped: isLooped, customDuration: (float)fireAnimationDuration, cooldownDuration: (float)cooldownDuration); }
public void Setup( ICharacter character, IComponentSkeleton skeletonRenderer, IProtoItemWeaponRanged protoWeapon) { byte flashAtlasRow = 0, smokeAtlasRow = 1; this.character = character; this.skeletonRenderer = skeletonRenderer; this.protoWeapon = protoWeapon; this.description = protoWeapon.MuzzleFlashDescription; var muzzleFlashTextureAtlas = this.description.TextureAtlas; this.animationDuration = this.description.TextureAnimationDurationSeconds; this.lightDuration = this.description.LightDurationSeconds; // create light renderer this.lightSource = ClientLighting.CreateLightSourceSpot( this.SceneObject, color: this.description.LightColor, spritePivotPoint: (0.5, 0.5), size: (float)this.description.LightPower); this.CreateSpriteRendererAndAnimator( out this.spriteRendererSmoke, out var componentAnimatorSmoke, smokeAtlasRow, protoWeapon, muzzleFlashTextureAtlas); this.CreateSpriteRendererAndAnimator( out this.spriteRendererFlash, out var componentAnimatorFlash, flashAtlasRow, protoWeapon, muzzleFlashTextureAtlas); this.Destroy(this.animationDuration); this.lightSource.Destroy(this.animationDuration); this.spriteRendererFlash.Destroy(this.animationDuration); this.spriteRendererSmoke.Destroy(this.animationDuration); componentAnimatorFlash.Destroy(this.animationDuration); componentAnimatorSmoke.Destroy(this.animationDuration); this.Update(deltaTime: 0); }
protected override void ClientSetupSkeletonAnimation( bool isActive, IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents) { base.ClientSetupSkeletonAnimation(isActive, item, character, skeletonRenderer, skeletonComponents); if (!isActive) { return; } // create fire sprite renderer var sceneObject = skeletonRenderer.SceneObject; var fireRenderer = Client.Rendering.CreateSpriteRenderer( sceneObject, TextureResource.NoTexture, // draw origin is calculated so that the center // of the flame sprite will always stay on the end of the torch item spritePivotPoint: (0.5, 0.277), // please note: the torch X axis ("Weapon" slot) is oriented up because torch is held this way! positionOffset: (0.35, 0), scale: 0.9); var fireAnimator = sceneObject.AddComponent <ClientComponentSpriteSheetAnimator>(); fireAnimator.Setup( fireRenderer, ClientComponentSpriteSheetAnimator.CreateAnimationFrames(TextureAtlasFire), isLooped: true, frameDurationSeconds: 1 / 15.0, randomizeInitialFrame: true); var slotNameClone = "Weapon_Torch"; skeletonRenderer.CloneSlot("Weapon", slotNameClone); skeletonRenderer.SetAttachmentRenderer(slotNameClone, "WeaponMelee", fireRenderer, applyBoneRotation: false); skeletonRenderer.SetAttachment(slotNameClone, "WeaponMelee"); skeletonComponents.Add(fireRenderer); skeletonComponents.Add(fireAnimator); }
public override void OnSkeletonCreated(IComponentSkeleton skeleton) { base.OnSkeletonCreated(skeleton); if (skeleton.SceneObject.AttachedWorldObject is ICharacter characterPilot) { skeleton.SceneObject .AddComponent <ComponentSkeletonMechAimingSoundManager>() .Setup(skeleton, characterPilot); } skeleton.AnimationEvent += SkeletonOnAnimationEventFootstepMovement; // little offset to ensure mech can properly behind a grass // cannot make it further without making it to z-fight with a player character skeleton.DrawOrderOffsetY = -0.3; skeleton.SetDefaultMixDuration(0.3f); // disable mix for these animations DisableMix("RunUp"); DisableMix("RunDown"); DisableMix("RunSide"); DisableMix("RunSideBackward"); var verticalSpeedMultiplier = this.AnimationVerticalMovemementSpeedMultiplier; skeleton.SetAnimationDefaultSpeed("RunUp", verticalSpeedMultiplier); skeleton.SetAnimationDefaultSpeed("RunUpStart", verticalSpeedMultiplier); skeleton.SetAnimationDefaultSpeed("RunDown", verticalSpeedMultiplier); skeleton.SetAnimationDefaultSpeed("RunDownStart", verticalSpeedMultiplier); void DisableMix(string primaryName) { var startName = primaryName + "Start"; var startAbortName = startName + "Abort"; var minMix = 0.05f; skeleton.SetMixDuration(startName, minMix); skeleton.SetMixDuration(startAbortName, minMix); skeleton.SetMixDuration("Idle", startName, minMix); skeleton.SetMixDuration(startName, primaryName, 0); skeleton.SetMixDuration(startName, startAbortName, minMix); skeleton.SetMixDuration(startAbortName, "Idle", minMix); skeleton.SetAnimationDefaultSpeed(startAbortName, 1.3f); } }
public override void ClientSetupSkeleton( IItem item, ICharacter character, IComponentSkeleton skeletonRenderer, List <IClientComponent> skeletonComponents, bool isPreview) { var componentSight = ComponentCharacterLaserSight.TryCreateComponent(character, GetPublicState(item)); if (componentSight is not null) { skeletonComponents.Add(componentSight); } base.ClientSetupSkeleton(item, character, skeletonRenderer, skeletonComponents, isPreview); }