<commit_before>
--
-- Copyright (C) 2017 DBot
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- it is defined shared, but used clientside only

import PPM2 from _G

-- 0	LrigPelvis
-- 1	LrigSpine1
-- 2	LrigSpine2
-- 3	LrigRibcage
-- 4	LrigNeck1
-- 5	LrigNeck2
-- 6	LrigNeck3
-- 7	LrigScull
-- 8	Lrig_LEG_BL_Femur
-- 9	Lrig_LEG_BL_Tibia
-- 10	Lrig_LEG_BL_LargeCannon
-- 11	Lrig_LEG_BL_PhalanxPrima
-- 12	Lrig_LEG_BL_RearHoof
-- 13	Lrig_LEG_BR_Femur
-- 14	Lrig_LEG_BR_Tibia
-- 15	Lrig_LEG_BR_LargeCannon
-- 16	Lrig_LEG_BR_PhalanxPrima
-- 17	Lrig_LEG_BR_RearHoof
-- 18	Lrig_LEG_FL_Scapula
-- 19	Lrig_LEG_FL_Humerus
-- 20	Lrig_LEG_FL_Radius
-- 21	Lrig_LEG_FL_Metacarpus
-- 22	Lrig_LEG_FL_PhalangesManus
-- 23	Lrig_LEG_FL_FrontHoof
-- 24	Lrig_LEG_FR_Scapula
-- 25	Lrig_LEG_FR_Humerus
-- 26	Lrig_LEG_FR_Radius
-- 27	Lrig_LEG_FR_Metacarpus
-- 28	Lrig_LEG_FR_PhalangesManus
-- 29	Lrig_LEG_FR_FrontHoof
-- 30	Mane01
-- 31	Mane02
-- 32	Mane03
-- 33	Mane04
-- 34	Mane05
-- 35	Mane06
-- 36	Mane07
-- 37	Mane03_tip
-- 38	Tail01
-- 39	Tail02
-- 40	Tail03

class PonyWeightController extends PPM2.ControllerChildren
	@AVALIABLE_CONTROLLERS = {}
	@MODELS = {'models/ppm/player_default_base.mdl', 'models/ppm/player_default_base_nj.mdl', 'models/cppm/player_default_base.mdl', 'models/cppm/player_default_base_nj.mdl'}
	@HARD_LIMIT_MINIMAL = 0.1
	@HARD_LIMIT_MAXIMAL = 3

	@DEFAULT_BONE_SIZE = Vector(1, 1, 1)
	@NEXT_OBJ_ID = 0

	new: (data, applyWeight = true) =>
		@isValid = true
		@networkedData = data
		@ent = data.ent
		@objID = @@NEXT_OBJ_ID
		@@NEXT_OBJ_ID += 1
		@lastPAC3BoneReset = 0
		@SetWeight(data\GetWeight())
		@UpdateWeight() if IsValid(@ent) and applyWeight
		PPM2.DebugPrint('Created new weight controller for ', @ent, ' as part of ', data, '; internal ID is ', @objID)

	__tostring: => "[#{@@__name}:#{@objID}|#{@GetData()}]"
	IsValid: => IsValid(@ent) and @isValid
	GetEntity: => @ent
	GetData: => @networkedData
	GetController: => @networkedData
	GetModel: => @networkedData\GetModel()

	@WEIGHT_BONES = {
		{id: 0, scale: 1.1}
		{id: 1, scale: 0.7}
		{id: 2, scale: 0.7}
		{id: 3, scale: 0.7}
	}

	table.insert(@WEIGHT_BONES, {id: i, scale: 1}) for i = 8, 29

	DataChanges: (state) =>
		return if not IsValid(@ent) or not @isValid
		return if state\GetKey() ~= 'Weight'
		@SetWeight(state\GetValue())
		@UpdateWeight()

	SetWeight: (weight = 1) => @weight = math.Clamp(weight, @@HARD_LIMIT_MINIMAL, @@HARD_LIMIT_MAXIMAL)
	SlowUpdate: =>

	ResetBones: (ent = @ent) =>
		return if not IsValid(ent) or not @isValid
		for {:id} in *@@WEIGHT_BONES
			ent\ManipulateBoneScale(id, @@DEFAULT_BONE_SIZE)

	Reset: => @ResetBones()

	UpdateWeight: (ent = @ent) =>
		return if not IsValid(ent) or not @isValid
		return if not @ent\IsPony()

		for {:id, :scale} in *@@WEIGHT_BONES
			delta = 1 + (@weight - 1) * scale
			ent\ManipulateBoneScale(id, Vector(delta, delta, delta))

	Remove: =>
		@isValid = false

if CLIENT
	reset = (ent, data) ->
		if weight = data\GetWeightController()
			weight.ent = ent<commit_msg>Make Ponysize affect initial weight variable<commit_after>
--
-- Copyright (C) 2017 DBot
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- it is defined shared, but used clientside only

import PPM2 from _G

-- 0	LrigPelvis
-- 1	LrigSpine1
-- 2	LrigSpine2
-- 3	LrigRibcage
-- 4	LrigNeck1
-- 5	LrigNeck2
-- 6	LrigNeck3
-- 7	LrigScull
-- 8	Lrig_LEG_BL_Femur
-- 9	Lrig_LEG_BL_Tibia
-- 10	Lrig_LEG_BL_LargeCannon
-- 11	Lrig_LEG_BL_PhalanxPrima
-- 12	Lrig_LEG_BL_RearHoof
-- 13	Lrig_LEG_BR_Femur
-- 14	Lrig_LEG_BR_Tibia
-- 15	Lrig_LEG_BR_LargeCannon
-- 16	Lrig_LEG_BR_PhalanxPrima
-- 17	Lrig_LEG_BR_RearHoof
-- 18	Lrig_LEG_FL_Scapula
-- 19	Lrig_LEG_FL_Humerus
-- 20	Lrig_LEG_FL_Radius
-- 21	Lrig_LEG_FL_Metacarpus
-- 22	Lrig_LEG_FL_PhalangesManus
-- 23	Lrig_LEG_FL_FrontHoof
-- 24	Lrig_LEG_FR_Scapula
-- 25	Lrig_LEG_FR_Humerus
-- 26	Lrig_LEG_FR_Radius
-- 27	Lrig_LEG_FR_Metacarpus
-- 28	Lrig_LEG_FR_PhalangesManus
-- 29	Lrig_LEG_FR_FrontHoof
-- 30	Mane01
-- 31	Mane02
-- 32	Mane03
-- 33	Mane04
-- 34	Mane05
-- 35	Mane06
-- 36	Mane07
-- 37	Mane03_tip
-- 38	Tail01
-- 39	Tail02
-- 40	Tail03

class PonyWeightController extends PPM2.ControllerChildren
	@AVALIABLE_CONTROLLERS = {}
	@MODELS = {'models/ppm/player_default_base.mdl', 'models/ppm/player_default_base_nj.mdl', 'models/cppm/player_default_base.mdl', 'models/cppm/player_default_base_nj.mdl'}
	@HARD_LIMIT_MINIMAL = 0.1
	@HARD_LIMIT_MAXIMAL = 3

	@DEFAULT_BONE_SIZE = Vector(1, 1, 1)
	@NEXT_OBJ_ID = 0

	new: (data, applyWeight = true) =>
		@isValid = true
		@networkedData = data
		@ent = data.ent
		@objID = @@NEXT_OBJ_ID
		@@NEXT_OBJ_ID += 1
		@lastPAC3BoneReset = 0
		@scale = 1
		@SetWeight(data\GetWeight())
		@UpdateWeight() if IsValid(@ent) and applyWeight
		PPM2.DebugPrint('Created new weight controller for ', @ent, ' as part of ', data, '; internal ID is ', @objID)

	__tostring: => "[#{@@__name}:#{@objID}|#{@GetData()}]"
	IsValid: => IsValid(@ent) and @isValid
	GetEntity: => @ent
	GetData: => @networkedData
	GetController: => @networkedData
	GetModel: => @networkedData\GetModel()

	@WEIGHT_BONES = {
		{id: 0, scale: 1.1}
		{id: 1, scale: 0.7}
		{id: 2, scale: 0.7}
		{id: 3, scale: 0.7}
	}

	table.insert(@WEIGHT_BONES, {id: i, scale: 1}) for i = 8, 29

	DataChanges: (state) =>
		return if not IsValid(@ent) or not @isValid

		if state\GetKey() == 'Weight'
			@SetWeight(state\GetValue())

		if state\GetKey() == 'PonySize'
			@SetSize(state\GetValue())

	SetWeight: (weight = 1) => @weight = math.Clamp(weight, @@HARD_LIMIT_MINIMAL, @@HARD_LIMIT_MAXIMAL)
	SetSize: (scale = 1) => @scale = math.Clamp(math.sqrt(scale), @@HARD_LIMIT_MINIMAL, @@HARD_LIMIT_MAXIMAL)
	SlowUpdate: =>

	ResetBones: (ent = @ent) =>
		return if not IsValid(ent) or not @isValid
		for {:id} in *@@WEIGHT_BONES
			ent\ManipulateBoneScale(id, @@DEFAULT_BONE_SIZE)

	Reset: => @ResetBones()

	UpdateWeight: (ent = @ent) =>
		return if not IsValid(ent) or not @isValid
		return if not @ent\IsPony()

		for {:id, :scale} in *@@WEIGHT_BONES
			delta = 1 + (@weight * @scale - 1) * scale
			ent\ManipulateBoneScale(id, Vector(delta, delta, delta))

	Remove: =>
		@isValid = false

if CLIENT
	reset = (ent, data) ->
		if weight = data\GetWeightController()
			weight.ent = ent
{'fraction_non_alphanumeric': 0.13120176405733186, 'fraction_numerical': 0.03858875413450937, 'mean_word_length': 3.873740765614506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4550228', 'n_tokens_mistral': 3299, 'n_tokens_neox': 2962, 'n_words': 726}