123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, State, _crd;
- function get_new_state() {
- return new State();
- }
- _export("default", get_new_state);
- return {
- setters: [function (_cc) {
- _cclegacy = _cc.cclegacy;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "d9db0FDjAhNuLA9MVTSVAgv", "State", undefined);
- /*enum states{
- Read = 1, //0001
- Write = 2, //0010
- Create = 4,//0100
- Delete = 8 //1000
- }/**状态类型不算合并的不超过32种
- export enum StateType {
- Unmatched = 1<<1,//无敌
- Swoon = 1<<2,//晕眩
- }*/
- /**状态对像*/
- State = class State {
- constructor() {
- this._state = 0;
- }
- //无状态
- Init() {
- this._state = 0;
- }
- /**是否满足传入的状态*/
- Meet(state) {
- return State.Has(this._state, state);
- }
- /**传入的状态是组合型时只要满足其一 */
- MeetAny(state) {
- let a = this._state & state;
- if (a === state) return true;
- if (a == 0) return false;
- return State.Has(state, a);
- }
- /**是否满足所有传入的状态*/
- MeetAll(...params) {
- let result = 0;
- for (let i = 0; i < params.length; i++) {
- result |= params[i];
- }
- return this.Meet(State.CombieState(result));
- }
- /**是否满足其中传入的状态*/
- MeetAnyOne(...params) {
- for (let i = 0; i < params.length; i++) {
- if (this.Meet(params[i])) return true;
- }
- return false;
- }
- /**加入状态*/
- Add(state) {
- this._state |= state;
- }
- /**删除状态*/
- Delete(state) {
- if (!this.Meet(state)) return;
- this._state ^= state;
- }
- /**转成状态*/
- static ToState(Id) {
- return 1 << Id;
- }
- /**合并状态*/
- static CombieState(...params) {
- let result = 0;
- for (let i = 0; i < params.length; i++) {
- result |= params[i];
- }
- return result;
- }
- static Has(statss, state) {
- return (statss & state) === state;
- }
- };
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=f8d148f31bf8ae088bac9cab5fd2990e8c8b41ec.js.map
|